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

Commit ff0e894

Browse files
authored
Drop federation transmission queues during a significant remote outage. (#7864)
* Empty federation transmission queues when we are backing off. Fixes #7828. Signed-off-by: Olivier Wilkinson (reivilibre) <[email protected]> * Address feedback Signed-off-by: Olivier Wilkinson (reivilibre) <[email protected]> * Reword newsfile
1 parent dd8f28b commit ff0e894

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

changelog.d/7864.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a memory leak by limiting the length of time that messages will be queued for a remote server that has been unreachable.

synapse/federation/sender/per_destination_queue.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,28 @@ async def _transaction_transmission_loop(self) -> None:
337337
(e.retry_last_ts + e.retry_interval) / 1000.0
338338
),
339339
)
340+
341+
if e.retry_interval > 60 * 60 * 1000:
342+
# we won't retry for another hour!
343+
# (this suggests a significant outage)
344+
# We drop pending PDUs and EDUs because otherwise they will
345+
# rack up indefinitely.
346+
# Note that:
347+
# - the EDUs that are being dropped here are those that we can
348+
# afford to drop (specifically, only typing notifications,
349+
# read receipts and presence updates are being dropped here)
350+
# - Other EDUs such as to_device messages are queued with a
351+
# different mechanism
352+
# - this is all volatile state that would be lost if the
353+
# federation sender restarted anyway
354+
355+
# dropping read receipts is a bit sad but should be solved
356+
# through another mechanism, because this is all volatile!
357+
self._pending_pdus = []
358+
self._pending_edus = []
359+
self._pending_edus_keyed = {}
360+
self._pending_presence = {}
361+
self._pending_rrs = {}
340362
except FederationDeniedError as e:
341363
logger.info(e)
342364
except HttpResponseException as e:

0 commit comments

Comments
 (0)