Skip to content

Commit

Permalink
Also batch persist
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Feb 14, 2024
1 parent 24ac3bb commit 6fa13b4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions synapse/handlers/federation_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,9 +1367,9 @@ async def _get_state_ids_after_missing_prev_event(
)

if remote_event.is_state() and remote_event.rejected_reason is None:
state_map[
(remote_event.type, remote_event.state_key)
] = remote_event.event_id
state_map[(remote_event.type, remote_event.state_key)] = (
remote_event.event_id
)

return state_map

Expand Down Expand Up @@ -1766,14 +1766,16 @@ async def prep(event: EventBase) -> None:
if (i + 1) % 1000 == 0:
await self._clock.sleep(0)

await self.persist_events_and_notify(
room_id,
events_and_contexts_to_persist,
# Mark these events backfilled as they're historic events that will
# eventually be backfilled. For example, missing events we fetch
# during backfill should be marked as backfilled as well.
backfilled=True,
)
# Also persist the new event in batches for similar reasons as above.
for batch in batch_iter(events_and_contexts_to_persist, 1000):
await self.persist_events_and_notify(
room_id,
batch,
# Mark these events backfilled as they're historic events that will
# eventually be backfilled. For example, missing events we fetch
# during backfill should be marked as backfilled as well.
backfilled=True,
)

@trace
async def _check_event_auth(
Expand Down

0 comments on commit 6fa13b4

Please sign in to comment.