mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-23 22:29:38 -05:00
Limit the number of events sent over replication when persisting events. (#10082)
This commit is contained in:
parent
1641c5c707
commit
9408b86f5c
1
changelog.d/10082.bugfix
Normal file
1
changelog.d/10082.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fixed a bug causing replication requests to fail when receiving a lot of events via federation.
|
@ -91,6 +91,7 @@ from synapse.types import (
|
|||||||
get_domain_from_id,
|
get_domain_from_id,
|
||||||
)
|
)
|
||||||
from synapse.util.async_helpers import Linearizer, concurrently_execute
|
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.retryutils import NotRetryingDestination
|
||||||
from synapse.util.stringutils import shortstr
|
from synapse.util.stringutils import shortstr
|
||||||
from synapse.visibility import filter_events_for_server
|
from synapse.visibility import filter_events_for_server
|
||||||
@ -3053,13 +3054,15 @@ class FederationHandler(BaseHandler):
|
|||||||
"""
|
"""
|
||||||
instance = self.config.worker.events_shard_config.get_instance(room_id)
|
instance = self.config.worker.events_shard_config.get_instance(room_id)
|
||||||
if instance != self._instance_name:
|
if instance != self._instance_name:
|
||||||
result = await self._send_events(
|
# Limit the number of events sent over federation.
|
||||||
instance_name=instance,
|
for batch in batch_iter(event_and_contexts, 1000):
|
||||||
store=self.store,
|
result = await self._send_events(
|
||||||
room_id=room_id,
|
instance_name=instance,
|
||||||
event_and_contexts=event_and_contexts,
|
store=self.store,
|
||||||
backfilled=backfilled,
|
room_id=room_id,
|
||||||
)
|
event_and_contexts=batch,
|
||||||
|
backfilled=backfilled,
|
||||||
|
)
|
||||||
return result["max_stream_id"]
|
return result["max_stream_id"]
|
||||||
else:
|
else:
|
||||||
assert self.storage.persistence
|
assert self.storage.persistence
|
||||||
|
Loading…
Reference in New Issue
Block a user