mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-06 12:15:02 -04:00
Avoid checking the event cache when backfilling events (#14164)
This commit is contained in:
parent
828b5502cf
commit
dc02d9f8c5
4 changed files with 140 additions and 15 deletions
|
@ -798,9 +798,42 @@ class FederationEventHandler:
|
|||
],
|
||||
)
|
||||
|
||||
# Check if we already any of these have these events.
|
||||
# Note: we currently make a lookup in the database directly here rather than
|
||||
# checking the event cache, due to:
|
||||
# https://github.com/matrix-org/synapse/issues/13476
|
||||
existing_events_map = await self._store._get_events_from_db(
|
||||
[event.event_id for event in events]
|
||||
)
|
||||
|
||||
new_events = []
|
||||
for event in events:
|
||||
event_id = event.event_id
|
||||
|
||||
# If we've already seen this event ID...
|
||||
if event_id in existing_events_map:
|
||||
existing_event = existing_events_map[event_id]
|
||||
|
||||
# ...and the event itself was not previously stored as an outlier...
|
||||
if not existing_event.event.internal_metadata.is_outlier():
|
||||
# ...then there's no need to persist it. We have it already.
|
||||
logger.info(
|
||||
"_process_pulled_event: Ignoring received event %s which we "
|
||||
"have already seen",
|
||||
event.event_id,
|
||||
)
|
||||
continue
|
||||
|
||||
# While we have seen this event before, it was stored as an outlier.
|
||||
# We'll now persist it as a non-outlier.
|
||||
logger.info("De-outliering event %s", event_id)
|
||||
|
||||
# Continue on with the events that are new to us.
|
||||
new_events.append(event)
|
||||
|
||||
# We want to sort these by depth so we process them and
|
||||
# tell clients about them in order.
|
||||
sorted_events = sorted(events, key=lambda x: x.depth)
|
||||
sorted_events = sorted(new_events, key=lambda x: x.depth)
|
||||
for ev in sorted_events:
|
||||
with nested_logging_context(ev.event_id):
|
||||
await self._process_pulled_event(origin, ev, backfilled=backfilled)
|
||||
|
@ -852,18 +885,6 @@ class FederationEventHandler:
|
|||
|
||||
event_id = event.event_id
|
||||
|
||||
existing = await self._store.get_event(
|
||||
event_id, allow_none=True, allow_rejected=True
|
||||
)
|
||||
if existing:
|
||||
if not existing.internal_metadata.is_outlier():
|
||||
logger.info(
|
||||
"_process_pulled_event: Ignoring received event %s which we have already seen",
|
||||
event_id,
|
||||
)
|
||||
return
|
||||
logger.info("De-outliering event %s", event_id)
|
||||
|
||||
try:
|
||||
self._sanity_check_event(event)
|
||||
except SynapseError as err:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue