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

Commit 606b2d9

Browse files
authored
Add cache to get_partial_state_servers_at_join (#14013)
1 parent d65862c commit 606b2d9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

changelog.d/14013.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Faster room joins: Send device list updates to most servers in rooms with partial state.

synapse/storage/databases/main/room.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ def get_rooms_for_retention_period_in_range_txn(
11341134
get_rooms_for_retention_period_in_range_txn,
11351135
)
11361136

1137+
@cached(iterable=True)
11371138
async def get_partial_state_servers_at_join(self, room_id: str) -> Sequence[str]:
11381139
"""Gets the list of servers in a partial state room at the time we joined it.
11391140
@@ -1216,6 +1217,9 @@ def _clear_partial_state_room_txn(
12161217
keyvalues={"room_id": room_id},
12171218
)
12181219
self._invalidate_cache_and_stream(txn, self.is_partial_state_room, (room_id,))
1220+
self._invalidate_cache_and_stream(
1221+
txn, self.get_partial_state_servers_at_join, (room_id,)
1222+
)
12191223

12201224
# We now delete anything from `device_lists_remote_pending` with a
12211225
# stream ID less than the minimum
@@ -1862,6 +1866,9 @@ def _store_partial_state_room_txn(
18621866
values=((room_id, s) for s in servers),
18631867
)
18641868
self._invalidate_cache_and_stream(txn, self.is_partial_state_room, (room_id,))
1869+
self._invalidate_cache_and_stream(
1870+
txn, self.get_partial_state_servers_at_join, (room_id,)
1871+
)
18651872

18661873
async def write_partial_state_rooms_join_event_id(
18671874
self,

0 commit comments

Comments
 (0)