From 350421e0589606f422df22d9901330776fa5ed5f Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 4 May 2020 14:04:09 +0100 Subject: [PATCH 1/3] Fix redis password support. (#7401) We forgot to set the password on the subscriber connection, as well as not calling super methods for overridden connectionMade/connectionLost functions. --- changelog.d/7401.feature | 1 + stubs/txredisapi.pyi | 3 +++ synapse/replication/tcp/redis.py | 3 +++ 3 files changed, 7 insertions(+) create mode 100644 changelog.d/7401.feature diff --git a/changelog.d/7401.feature b/changelog.d/7401.feature new file mode 100644 index 000000000..ce6140fdd --- /dev/null +++ b/changelog.d/7401.feature @@ -0,0 +1 @@ +Add support for running replication over Redis when using workers. diff --git a/stubs/txredisapi.pyi b/stubs/txredisapi.pyi index 763d3fb40..cac689d4f 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 = ..., diff --git a/synapse/replication/tcp/redis.py b/synapse/replication/tcp/redis.py index 617e860f9..41c623d73 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 @@ class RedisSubscriber(txredisapi.SubscriberProtocol, AbstractConnection): 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 @@ class RedisDirectTcpReplicationClientFactory(txredisapi.SubscriberFactory): 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 068da604c2142e173817dc508dc510bee7ab6b64 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Mon, 4 May 2020 13:15:39 +0200 Subject: [PATCH 2/3] Fix MANIFEST.in An update of check-manifest shone some light on some issues with MANIFEST.in, specifically that we didn't ignore/prune the contrib directory, and that we were using prune instead of exclude for files. This fixes both issues. Fixes #7403 --- MANIFEST.in | 7 ++++--- changelog.d/7404.misc | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog.d/7404.misc diff --git a/MANIFEST.in b/MANIFEST.in index 156d6f04f..9bdfd82f4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -35,18 +35,19 @@ exclude .dockerignore exclude test_postgresql.sh exclude .editorconfig exclude sytest-blacklist +exclude mypy.ini +exclude .codecov.yml +exclude .coveragerc include pyproject.toml recursive-include changelog.d * prune .buildkite prune .circleci -prune .codecov.yml -prune .coveragerc prune .github prune debian prune demo/etc prune docker -prune mypy.ini prune snap prune stubs +prune contrib diff --git a/changelog.d/7404.misc b/changelog.d/7404.misc new file mode 100644 index 000000000..9ac17958c --- /dev/null +++ b/changelog.d/7404.misc @@ -0,0 +1 @@ +Fix issues with the Python package manifest. From 9858d5c362123050ee6826e1c72fe9dd34dc6600 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Mon, 4 May 2020 16:33:30 +0200 Subject: [PATCH 3/3] Fix ordering in MANIFEST.in --- MANIFEST.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 9bdfd82f4..120ce5b77 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -30,14 +30,14 @@ recursive-include synapse/static *.gif recursive-include synapse/static *.html recursive-include synapse/static *.js -exclude Dockerfile -exclude .dockerignore -exclude test_postgresql.sh -exclude .editorconfig -exclude sytest-blacklist -exclude mypy.ini exclude .codecov.yml exclude .coveragerc +exclude .dockerignore +exclude .editorconfig +exclude Dockerfile +exclude mypy.ini +exclude sytest-blacklist +exclude test_postgresql.sh include pyproject.toml recursive-include changelog.d * @@ -45,9 +45,9 @@ recursive-include changelog.d * prune .buildkite prune .circleci prune .github +prune contrib prune debian prune demo/etc prune docker prune snap prune stubs -prune contrib