Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Limit the number of events sent over replication when persisting even…
Browse files Browse the repository at this point in the history
…ts. (#10082)
  • Loading branch information
babolivier committed May 27, 2021
1 parent 8e132fe commit f828a70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.d/10082.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug causing replication requests to fail when receiving a lot of events via federation.
17 changes: 10 additions & 7 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
get_domain_from_id,
)
from synapse.util.async_helpers import Linearizer, concurrently_execute
from synapse.util.iterutils import batch_iter
from synapse.util.retryutils import NotRetryingDestination
from synapse.util.stringutils import shortstr
from synapse.visibility import filter_events_for_server
Expand Down Expand Up @@ -3053,13 +3054,15 @@ async def persist_events_and_notify(
"""
instance = self.config.worker.events_shard_config.get_instance(room_id)
if instance != self._instance_name:
result = await self._send_events(
instance_name=instance,
store=self.store,
room_id=room_id,
event_and_contexts=event_and_contexts,
backfilled=backfilled,
)
# Limit the number of events sent over federation.
for batch in batch_iter(event_and_contexts, 1000):
result = await self._send_events(
instance_name=instance,
store=self.store,
room_id=room_id,
event_and_contexts=batch,
backfilled=backfilled,
)
return result["max_stream_id"]
else:
assert self.storage.persistence
Expand Down

0 comments on commit f828a70

Please sign in to comment.