From 072382bff9cbc5aa699f6bd2bbda5b3992108ad6 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 3 Jun 2021 13:47:35 +0100 Subject: [PATCH 1/4] Limit number of events in a replication request --- synapse/handlers/federation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 49ed7cabcc8d..8ab6a74dc0bb 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -3056,8 +3056,9 @@ async def persist_events_and_notify( """ instance = self.config.worker.events_shard_config.get_instance(room_id) if instance != self._instance_name: - # Limit the number of events sent over federation. - for batch in batch_iter(event_and_contexts, 1000): + # Limit the number of events sent over federation. We choose 200 + # here as that is what we default to in `max_request_body_size(..)` + for batch in batch_iter(event_and_contexts, 200): result = await self._send_events( instance_name=instance, store=self.store, From b9554ff9c92c5de6dd9d627d3cc98c5f386b7569 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 3 Jun 2021 13:50:58 +0100 Subject: [PATCH 2/4] Newsfile --- changelog.d/10118.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/10118.bugfix diff --git a/changelog.d/10118.bugfix b/changelog.d/10118.bugfix new file mode 100644 index 000000000000..6c54e6eebadc --- /dev/null +++ b/changelog.d/10118.bugfix @@ -0,0 +1 @@ +Fix a bug causing replication requests to fail when receiving a lot of very large events via federation. From 42de8c479f48f1ddbc4b289811412d57b813e091 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 4 Jun 2021 10:00:28 +0100 Subject: [PATCH 3/4] Update synapse/handlers/federation.py Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- synapse/handlers/federation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 8ab6a74dc0bb..f3f97db2fab9 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -3056,7 +3056,7 @@ async def persist_events_and_notify( """ instance = self.config.worker.events_shard_config.get_instance(room_id) if instance != self._instance_name: - # Limit the number of events sent over federation. We choose 200 + # Limit the number of events sent over replication. We choose 200 # here as that is what we default to in `max_request_body_size(..)` for batch in batch_iter(event_and_contexts, 200): result = await self._send_events( From 57b5e162af654041e100f2e4d8436c61686a7bec Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Fri, 4 Jun 2021 10:07:06 +0100 Subject: [PATCH 4/4] Update changelog.d/10118.bugfix --- changelog.d/10118.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/10118.bugfix b/changelog.d/10118.bugfix index 6c54e6eebadc..db62b50e0b6a 100644 --- a/changelog.d/10118.bugfix +++ b/changelog.d/10118.bugfix @@ -1 +1 @@ -Fix a bug causing replication requests to fail when receiving a lot of very large events via federation. +Fix a bug introduced in Synapse 1.33.0 which caused replication requests to fail when receiving a lot of very large events via federation.