diff options
author | Erik Johnston <erik@matrix.org> | 2020-05-13 09:57:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 09:57:15 +0100 |
commit | 8ca79613e62201f0990a482130527fc88c4ffd40 (patch) | |
tree | 165ff43a8cf7bd954ac6b0ec6e65bf5db5fe5edc /synapse/replication/tcp/redis.py | |
parent | Update documentation about SSO mapping providers (#7458) (diff) | |
download | synapse-8ca79613e62201f0990a482130527fc88c4ffd40.tar.xz |
Fix Redis reconnection logic (#7482)
Proactively send out `POSITION` commands (as if we had just received a `REPLICATE`) when we connect to Redis. This is important as other instances won't notice we've connected to issue a `REPLICATE` command (unlike for direct TCP connections). This is only currently an issue if master process reconnects without restarting (if it restarts then it won't have written anything and so other instances probably won't have missed anything).
Diffstat (limited to '')
-rw-r--r-- | synapse/replication/tcp/redis.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/replication/tcp/redis.py b/synapse/replication/tcp/redis.py index 55bfa71dfd..e776b63183 100644 --- a/synapse/replication/tcp/redis.py +++ b/synapse/replication/tcp/redis.py @@ -70,7 +70,6 @@ class RedisSubscriber(txredisapi.SubscriberProtocol, AbstractConnection): logger.info("Connected to redis") super().connectionMade() run_as_background_process("subscribe-replication", self._send_subscribe) - self.handler.new_connection(self) async def _send_subscribe(self): # it's important to make sure that we only send the REPLICATE command once we @@ -81,9 +80,15 @@ class RedisSubscriber(txredisapi.SubscriberProtocol, AbstractConnection): logger.info( "Successfully subscribed to redis stream, sending REPLICATE command" ) + self.handler.new_connection(self) await self._async_send_command(ReplicateCommand()) logger.info("REPLICATE successfully sent") + # We send out our positions when there is a new connection in case the + # other side missed updates. We do this for Redis connections as the + # otherside won't know we've connected and so won't issue a REPLICATE. + self.handler.send_positions_to_connection(self) + def messageReceived(self, pattern: str, channel: str, message: str): """Received a message from redis. """ |