Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sliding Sync: bugfix: ensure we can sync with SSS even with missing rooms #17727

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

kegsay
Copy link
Contributor

@kegsay kegsay commented Sep 18, 2024

Fixes element-hq/element-x-ios#3300

Some rooms are missing from sliding_sync_joined_rooms. When this happens, the first call will succeed, but any subsequent calls for this room ID will cause the cache to return None for the room ID, rather than not having the key at all. This then causes the <= check to throw.

Root cause: #17726

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

@kegsay kegsay requested a review from a team as a code owner September 18, 2024 14:31
if stream is None:
# Despite the function not directly setting None, the cache can!
# See: https://github.com/element-hq/synapse/issues/17726
continue
Copy link
Member

Choose a reason for hiding this comment

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

Is continuing the right thing to do here?
Or should this fall into the else case below for further processing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm following the same semantics as if the room was not in uncapped_results at all, which seems to just ignore the room entirely.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that makes sense to me. (This is my first time reading through all this code & it seems to jump around / duplicate itself in places which was a little confusing)

Copy link
Member

Choose a reason for hiding this comment

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

The caller of this function seems to expect an entry for each room ID?

joined_room_positions = (
await self.store.bulk_get_last_event_pos_in_room_before_stream_ordering(
[
room_id
for room_id, room_for_user in sync_room_map.items()
if room_for_user.membership == Membership.JOIN
],
to_token.room_key,
)
)
last_activity_in_room_map.update(joined_room_positions)
return sorted(
sync_room_map.values(),
# Sort by the last activity (stream_ordering) in the room
key=lambda room_info: last_activity_in_room_map[room_info.room_id],
# We want descending order
reverse=True,
)

It looks to me that things have gotten a bit confused here around what to do if a bump stamp can't be found, as we are probably assuming we can always find a bump stamp?

I guess the right thing to do is actually handle missing bump stamps at the call site (on top of this change)

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this was due to room with an unknown room version.

Have fixed and added regression test in #17733

Copy link
Member

@devonh devonh left a comment

Choose a reason for hiding this comment

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

Yikes. We'll need to look much closer at #17726.
But this should alleviate the immediate issue.

@MadLittleMods MadLittleMods changed the title bugfix: ensure we can sync with SSS even with missing rooms Sliding Sync: bugfix: ensure we can sync with SSS even with missing rooms Sep 18, 2024
@devonh devonh merged commit 3c8a116 into develop Sep 18, 2024
39 checks passed
@devonh devonh deleted the kegan/fix-sss-sync branch September 18, 2024 16:25
erikjohnston added a commit that referenced this pull request Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stuck on syncing with SSS
4 participants