1
0

Fix potential lost logcontext when PerDestinationQueue.shutdown(...) (#19178)

Spawning from looking at the logs in
https://github.com/element-hq/synapse/issues/19165#issuecomment-3527452941
which mention the `federation_transaction_transmission_loop`. I don't
think it's the source of the lost logcontext that person in the issue is
experiencing because this only applies when you try to `shutdown` the
homeserver.

Problem code introduced in
https://github.com/element-hq/synapse/pull/18828

To explain the fix, see the [*Deferred
callbacks*](https://github.com/element-hq/synapse/blob/3b59ac3b69f6a2f73a504699b30313d8dcfe4709/docs/log_contexts.md#deferred-callbacks)
section of our logcontext docs for more info (specifically using
solution 2).
This commit is contained in:
Eric Eastwood
2025-11-13 15:17:15 -06:00
committed by GitHub
parent 5d545d1626
commit 408a05ebbc
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Fix potential lost logcontext when `PerDestinationQueue.shutdown(...)`.
@@ -41,6 +41,7 @@ from synapse.events import EventBase
from synapse.federation.units import Edu
from synapse.handlers.presence import format_user_presence_state
from synapse.logging import issue9533_logger
from synapse.logging.context import PreserveLoggingContext
from synapse.logging.opentracing import SynapseTags, set_tag
from synapse.metrics import SERVER_NAME_LABEL, sent_transactions_counter
from synapse.types import JsonDict, ReadReceipt
@@ -186,7 +187,8 @@ class PerDestinationQueue:
self._transaction_manager.shutdown()
try:
if self.active_transmission_loop is not None:
self.active_transmission_loop.cancel()
with PreserveLoggingContext():
self.active_transmission_loop.cancel()
except Exception:
pass