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

Fix logging context warnings when losing replication connection #10984

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10984.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix spurious "Expected logging context replication_command_handler-############### was lost" warnings when losing the replication connection.
5 changes: 3 additions & 2 deletions synapse/replication/tcp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ def on_connection_closed(self):
if self.transport:
self.transport.unregisterProducer()

# mark the logging context as finished
self._logging_context.__exit__(None, None, None)
# mark the logging context as finished by triggering `__exit__()`
with self._logging_context:
pass

def __str__(self):
addr = None
Expand Down
5 changes: 3 additions & 2 deletions synapse/replication/tcp/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ def connectionLost(self, reason):
super().connectionLost(reason)
self.synapse_handler.lost_connection(self)

# mark the logging context as finished
self._logging_context.__exit__(None, None, None)
# mark the logging context as finished by triggering `__exit__()`
with self._logging_context:
pass

def send_command(self, cmd: Command):
"""Send a command if connection has been established.
Expand Down