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

Fix a rare bug where initial /syncs would fail #15383

Merged
Merged
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,9 @@ async def compute_state_delta(
# sync's timeline and the start of the current sync's timeline.
# See the docstring above for details.
state_ids: StateMap[str]

# We need to know whether the state we fetch may be partial, so check
# whether the room is partial stated *before* fetching it.
is_partial_state_room = await self.store.is_partial_state_room(room_id)
Comment on lines +1003 to +1005
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess to make this 100% robust we'd need to atomically fetch is_partial_state_room while we fetch the state ids?

(To be explicit, I don't think we should do this.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work, yes. I wonder if partial state-dness should really be a property of state rather than events or rooms.

if full_state:
if batch:
state_at_timeline_end = (
Expand Down Expand Up @@ -1119,7 +1121,7 @@ async def compute_state_delta(
# If we only have partial state for the room, `state_ids` may be missing the
# memberships we wanted. We attempt to find some by digging through the auth
# events of timeline events.
if lazy_load_members and await self.store.is_partial_state_room(room_id):
if lazy_load_members and is_partial_state_room:
assert members_to_fetch is not None
assert first_event_by_sender_map is not None

Expand Down