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

Commit 8c28252

Browse files
authored
Skip waiting for full state for incoming events (#13144)
When we receive an event over federation during a faster join, there is no need to wait for full state, since we have a whole reconciliation process designed to take the partial state into account.
1 parent c0efc68 commit 8c28252

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

changelog.d/13144.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Faster joins: skip waiting for full state when processing incoming events over federation.

synapse/state/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,12 @@ async def compute_event_context(
249249
partial_state = True
250250

251251
logger.debug("calling resolve_state_groups from compute_event_context")
252+
# we've already taken into account partial state, so no need to wait for
253+
# complete state here.
252254
entry = await self.resolve_state_groups_for_events(
253-
event.room_id, event.prev_event_ids()
255+
event.room_id,
256+
event.prev_event_ids(),
257+
await_full_state=False,
254258
)
255259

256260
state_ids_before_event = entry.state
@@ -335,22 +339,24 @@ async def compute_event_context(
335339

336340
@measure_func()
337341
async def resolve_state_groups_for_events(
338-
self, room_id: str, event_ids: Collection[str]
342+
self, room_id: str, event_ids: Collection[str], await_full_state: bool = True
339343
) -> _StateCacheEntry:
340344
"""Given a list of event_ids this method fetches the state at each
341345
event, resolves conflicts between them and returns them.
342346
343347
Args:
344348
room_id
345349
event_ids
350+
await_full_state: if true, will block if we do not yet have complete
351+
state at these events.
346352
347353
Returns:
348354
The resolved state
349355
"""
350356
logger.debug("resolve_state_groups event_ids %s", event_ids)
351357

352358
state_groups = await self._state_storage_controller.get_state_group_for_events(
353-
event_ids
359+
event_ids, await_full_state=await_full_state
354360
)
355361

356362
state_group_ids = state_groups.values()

tests/test_state.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def register_event_id_state_group(self, event_id, state_group):
131131
async def get_room_version_id(self, room_id):
132132
return RoomVersions.V1.identifier
133133

134-
async def get_state_group_for_events(self, event_ids):
134+
async def get_state_group_for_events(
135+
self, event_ids, await_full_state: bool = True
136+
):
135137
res = {}
136138
for event in event_ids:
137139
res[event] = self._event_to_state_group[event]

0 commit comments

Comments
 (0)