Open bwindels opened 3 years ago
suspect this has the same cause as https://github.com/matrix-org/synapse/issues/1995
This happens in this bit of code, where loaded_recents
already contains your join membership event. recents
is a list containing it as well. When loaded_recents
is extended with recents
, you end up with the same event in the list twice.
current_state_ids
includes the join membership as well. Thus passing it in to filter_events_for_client
via alyways_include_ids
guarantees that you'll end up with that membership in loaded_recents
.
I'm not sure whether recents
should contain your membership, or if loaded_recents
is expected not to. The event is inserted into recents
when recents
is created here:
Which only runs because potential_recents
contains that same event. FYI limited
is set to True
, and block_all_timeline
is False
.
Just in case I tested with lazy-loading disabled and still found the same issue.
One hacky fix would just be to these things sets.
I tried to reproduce this with a complement test. This failed. I can reproduce it on matrix.org, however. I suspect that this doesn't show up if you're running Synapse as a monolith.
I tried to reproduce this with a complement test. This failed. I can reproduce it on matrix.org, however. I suspect that this doesn't show up if you're running Synapse as a monolith.
This was incorrect. I can reproduce it in complement, but only when I do a sync with a since
parameter provided. I suspect there's some difference between these two code paths:
From printf debugging, it looks like _load_filtered_recents
returns a TimelineBatch with the duplicate event.
I've narrowed it down to here:
Unfamiliar with this. It looks like potential_recents
is of size 1 and and loaded_recents
both contain the duplicate event.
Oh god, I completely missed Andrew's comment https://github.com/matrix-org/synapse/issues/9768#issuecomment-816680734
I don't really understand the purpose of potential_recents
, to be honest. Let's assume that both, recents
and loaded_recents
are correct. Is there a way to deduplicate when we extend loaded_recents
with recents
?
loaded_recents
is a subset of events
which is returned by either get_room_events_stream_for_room
or get_recent_events_for_room
.get_recent_events_for_room
claims to use topological ordering, and seems to tie-break on stream ordering.get_room_events_stream_for_room
uses stream ordering.I'm not sure how to merge recents
into loaded_events
in the former case---I don't think an EventBase
knows about a topological ordering.
The spec notes the following:
Further, like other members, the user’s own membership event is eligible for being considered redundant by the server. When a sync is limited, the server MUST return membership events for events in the gap (between since and the start of the returned timeline), regardless as to whether or not they are redundant. This ensures that joins/leaves and profile changes which occur during the gap are not lost.
Note that the default behaviour of state is to include all membership events, alongside other state, when lazy-loading is not enabled.
So I think that might explain what potential_recents
is trying to do.
As for ordering, there's a warning infobox here which says
Events are ordered in this API according to the arrival time of the event on the homeserver.
which is presumably the stream ordering.
I think #1597 is the oldest report of this. #1995 is related.
When accepting an invite to a new DM, I consistently (on matrix.org) see the last two events of the timeline being my own member event, duplicated. The request URL for this is https://matrix.org/_matrix/client/r0/sync?since=m1932336751~1.1932336915_757284961_312592_815559230_699804110_2214631_242549737_904922611_187106&timeout=30000&filter=2&_cacheBuster=1532609541718558