Faster room joins: `device_lists.left` not emitted in `/sync` response when completing the join and discovering that a user is actually not in the room
See the commented out check in the TestPartialStateJoin/Device_list_tracking/Device_list_no_longer_tracked_for_user_incorrectly_believed_to_be_in_room complement test.
That test case is roughly:
- A room starts with
@charlie:remote,@derek:remote(moderator) and@fred:remote(admin) -
@fred:remoteleaves the room. -
@alice:localpartial state joins the room. -
@elsie:remotejoins the room. -
@fred:remote"bans"@derek:remote, citing their join event as auth. The local homeserver does not know that@fred:remoteis no longer in the room and accepts the event. -
@derek:remotekicks@elsie:remote. The local homeserver incorrectly rejects the kick because it thinks@derek:remotehas been banned. - The partial state join completes and
@elsie:remoteis discovered to really have been kicked. - No
device_lists.leftentry is emitted.
This bug likely also applies to /keys/changes both ways (missing changed when discovering a user is actually in a room and missing left when a user is actually not in a room). We only have a complement test for the missing left scenario.
This is likely already an issue if the user is state-reset out.
See also #13650
I think https://github.com/matrix-org/synapse/actions/runs/3369422572/jobs/5589123694 hit this problem(?)