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

Commit caf43c3

Browse files
authored
Faster joins: Fix spurious errors on incremental sync (#15232)
When pushing events in partial state rooms down incremental /sync, we try to find the `m.room.member` state event for their senders by digging through their auth events, so that we can present the membership to the client. Events usually have a membership event in their auth events, with the exception of the `m.room.create` event and a user's first join into the room. When implementing #13477, we took the case of a user's first join into account, but forgot to handle the `m.room.create` case. This change fixes that. Signed-off-by: Sean Quah <[email protected]>
1 parent 3d060ea commit caf43c3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

changelog.d/15232.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Faster joins: Fix a bug introduced in Synapse 1.66 where spurious "Failed to find memberships ..." errors would be logged.

synapse/handlers/sync.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,16 +1226,21 @@ async def _find_missing_partial_state_memberships(
12261226
continue
12271227

12281228
event_with_membership_auth = events_with_membership_auth[member]
1229+
is_create = (
1230+
event_with_membership_auth.is_state()
1231+
and event_with_membership_auth.type == EventTypes.Create
1232+
)
12291233
is_join = (
12301234
event_with_membership_auth.is_state()
12311235
and event_with_membership_auth.type == EventTypes.Member
12321236
and event_with_membership_auth.state_key == member
12331237
and event_with_membership_auth.content.get("membership")
12341238
== Membership.JOIN
12351239
)
1236-
if not is_join:
1240+
if not is_create and not is_join:
12371241
# The event must include the desired membership as an auth event, unless
1238-
# it's the first join event for a given user.
1242+
# it's the `m.room.create` event for a room or the first join event for
1243+
# a given user.
12391244
missing_members.add(member)
12401245
auth_event_ids.update(event_with_membership_auth.auth_event_ids())
12411246

0 commit comments

Comments
 (0)