Skip to content
Snippets Groups Projects
Unverified Commit 8c282527 authored by Richard van der Hoff's avatar Richard van der Hoff Committed by GitHub
Browse files

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.
parent c0efc689
No related branches found
No related tags found
No related merge requests found
Faster joins: skip waiting for full state when processing incoming events over federation.
...@@ -249,8 +249,12 @@ class StateHandler: ...@@ -249,8 +249,12 @@ class StateHandler:
partial_state = True partial_state = True
logger.debug("calling resolve_state_groups from compute_event_context") logger.debug("calling resolve_state_groups from compute_event_context")
# we've already taken into account partial state, so no need to wait for
# complete state here.
entry = await self.resolve_state_groups_for_events( entry = await self.resolve_state_groups_for_events(
event.room_id, event.prev_event_ids() event.room_id,
event.prev_event_ids(),
await_full_state=False,
) )
state_ids_before_event = entry.state state_ids_before_event = entry.state
...@@ -335,7 +339,7 @@ class StateHandler: ...@@ -335,7 +339,7 @@ class StateHandler:
@measure_func() @measure_func()
async def resolve_state_groups_for_events( async def resolve_state_groups_for_events(
self, room_id: str, event_ids: Collection[str] self, room_id: str, event_ids: Collection[str], await_full_state: bool = True
) -> _StateCacheEntry: ) -> _StateCacheEntry:
"""Given a list of event_ids this method fetches the state at each """Given a list of event_ids this method fetches the state at each
event, resolves conflicts between them and returns them. event, resolves conflicts between them and returns them.
...@@ -343,6 +347,8 @@ class StateHandler: ...@@ -343,6 +347,8 @@ class StateHandler:
Args: Args:
room_id room_id
event_ids event_ids
await_full_state: if true, will block if we do not yet have complete
state at these events.
Returns: Returns:
The resolved state The resolved state
...@@ -350,7 +356,7 @@ class StateHandler: ...@@ -350,7 +356,7 @@ class StateHandler:
logger.debug("resolve_state_groups event_ids %s", event_ids) logger.debug("resolve_state_groups event_ids %s", event_ids)
state_groups = await self._state_storage_controller.get_state_group_for_events( state_groups = await self._state_storage_controller.get_state_group_for_events(
event_ids event_ids, await_full_state=await_full_state
) )
state_group_ids = state_groups.values() state_group_ids = state_groups.values()
......
...@@ -131,7 +131,9 @@ class _DummyStore: ...@@ -131,7 +131,9 @@ class _DummyStore:
async def get_room_version_id(self, room_id): async def get_room_version_id(self, room_id):
return RoomVersions.V1.identifier return RoomVersions.V1.identifier
async def get_state_group_for_events(self, event_ids): async def get_state_group_for_events(
self, event_ids, await_full_state: bool = True
):
res = {} res = {}
for event in event_ids: for event in event_ids:
res[event] = self._event_to_state_group[event] res[event] = self._event_to_state_group[event]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment