Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add cache to get_partial_state_servers_at_join #14013

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/14013.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Faster room joins: Send device list updates to most servers in rooms with partial state.
7 changes: 7 additions & 0 deletions synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ def get_rooms_for_retention_period_in_range_txn(
get_rooms_for_retention_period_in_range_txn,
)

@cached(iterable=True)
async def get_partial_state_servers_at_join(self, room_id: str) -> Sequence[str]:
"""Gets the list of servers in a partial state room at the time we joined it.

Expand Down Expand Up @@ -1216,6 +1217,9 @@ def _clear_partial_state_room_txn(
keyvalues={"room_id": room_id},
)
self._invalidate_cache_and_stream(txn, self.is_partial_state_room, (room_id,))
self._invalidate_cache_and_stream(
txn, self.get_partial_state_servers_at_join, (room_id,)
)

# We now delete anything from `device_lists_remote_pending` with a
# stream ID less than the minimum
Expand Down Expand Up @@ -1862,6 +1866,9 @@ def _store_partial_state_room_txn(
values=((room_id, s) for s in servers),
)
self._invalidate_cache_and_stream(txn, self.is_partial_state_room, (room_id,))
self._invalidate_cache_and_stream(
txn, self.get_partial_state_servers_at_join, (room_id,)
)

async def write_partial_state_rooms_join_event_id(
self,
Expand Down