From 8d81fd25c482227c952164ee7042e63644be38e1 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 6 Apr 2020 14:41:49 +0100 Subject: [PATCH] Handle errors when sending commands to connections --- synapse/replication/tcp/handler.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/synapse/replication/tcp/handler.py b/synapse/replication/tcp/handler.py index d895626802..494c5ddba6 100644 --- a/synapse/replication/tcp/handler.py +++ b/synapse/replication/tcp/handler.py @@ -315,7 +315,17 @@ class ReplicationCommandHandler: """ if self._connections: for connection in self._connections: - connection.send_command(cmd) + try: + connection.send_command(cmd) + except Exception: + # We probably want to catch some types of exceptions here + # and log them as warnings (e.g. connection gone), but I + # can't find what those exception types they would be. + logger.exception( + "Failed to write command %s to connection %s", + cmd.NAME, + connection, + ) else: logger.warning("Dropping command as not connected: %r", cmd.NAME)