This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Remove _get_events_cache
check optimisation from _have_seen_events_dict
#14161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #11521, credit to @richvdh for the idea!
When we join a room in Synapse (
/send_join
), we receive the auth chain and the current set of state from the room. Those events are passed throughEventWorkerStore.have_seen_events()
(viaFederationEventHandler._auth_and_persist_outliers
), and any events that we think we've already seen, we drop. Seems sensible.As an optimisation,
_have_seen_events_dict
(called fromhave_seen_events
) checks the_get_events_cache
before checking the database:synapse/synapse/storage/databases/main/events_worker.py
Lines 1498 to 1510 in 29269d9
Unfortunately, due to #13476, the
_get_event_cache
does not have entries for events invalidated in case of a room purge. What that means is that you'll:_get_event_cache
_get_event_cache
have_seen_events
thinks those events are already persistedm.room.create
event!).Ideally we'd fix things so that entries in
_get_event_cache
are correctly invalidated when a room is purged. There is a WIP plan to do so, but it's a big job. For now, we can just remove this optimisation as a quick win, as it's causing more harm than good. (The optimisation was originally added in #9601).(If you look closely, you'll notice that
_have_seen_events_dict
has a cache as well. Not to worry, that cache is correctly cleared when a room is purged.)Note that when you backfill (for non-state events) from a remote homeserver, those also go through
_get_event_cache
and will still be dropped on the floor. #14164 is the fix for that part.