From c98eb4d34dd8f60224d06b8b5562eac99407cbab Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 4 May 2020 11:33:48 +0100 Subject: [PATCH 1/3] Fix redis password support. We forgot to set the password on the subscriber connection, as well as not calling super methods for overridden connectionMade/connectionLost functions. --- synapse/replication/tcp/redis.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/replication/tcp/redis.py b/synapse/replication/tcp/redis.py index 617e860f95d0..41c623d73735 100644 --- a/synapse/replication/tcp/redis.py +++ b/synapse/replication/tcp/redis.py @@ -61,6 +61,7 @@ class RedisSubscriber(txredisapi.SubscriberProtocol, AbstractConnection): outbound_redis_connection = None # type: txredisapi.RedisProtocol def connectionMade(self): + super().connectionMade() logger.info("Connected to redis instance") self.subscribe(self.stream_name) self.send_command(ReplicateCommand()) @@ -119,6 +120,7 @@ async def handle_command(self, cmd: Command): logger.warning("Unhandled command: %r", cmd) def connectionLost(self, reason): + super().connectionLost(reason) logger.info("Lost connection to redis instance") self.handler.lost_connection(self) @@ -189,5 +191,6 @@ def buildProtocol(self, addr): p.handler = self.handler p.outbound_redis_connection = self.outbound_redis_connection p.stream_name = self.stream_name + p.password = self.password return p From e2a9fb85c5d33af39289f944b3d22f89647ea50b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 4 May 2020 11:38:09 +0100 Subject: [PATCH 2/3] Newsfile --- changelog.d/7401.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7401.feature diff --git a/changelog.d/7401.feature b/changelog.d/7401.feature new file mode 100644 index 000000000000..ce6140fdd111 --- /dev/null +++ b/changelog.d/7401.feature @@ -0,0 +1 @@ +Add support for running replication over Redis when using workers. From 4b75998c5dcee9aea263c0d16abaa906bcfeecfb Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 4 May 2020 11:46:09 +0100 Subject: [PATCH 3/3] Fix mypy --- stubs/txredisapi.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/txredisapi.pyi b/stubs/txredisapi.pyi index 763d3fb40467..cac689d4f32e 100644 --- a/stubs/txredisapi.pyi +++ b/stubs/txredisapi.pyi @@ -22,7 +22,10 @@ class RedisProtocol: def publish(self, channel: str, message: bytes): ... class SubscriberProtocol: + password: Optional[str] def subscribe(self, channels: Union[str, List[str]]): ... + def connectionMade(self): ... + def connectionLost(self, reason): ... def lazyConnection( host: str = ...,