From 1617f7881df51e8cc9fbf0d30c098a6b586138b7 Mon Sep 17 00:00:00 2001 From: "lakwinder.singh" Date: Thu, 9 Feb 2023 15:57:29 +0400 Subject: [PATCH 1/4] adding support for redis logical db --- contrib/docker_compose_workers/README.md | 1 + docs/usage/configuration/config_documentation.md | 3 +++ synapse/config/redis.py | 1 + synapse/server.py | 1 + 4 files changed, 6 insertions(+) diff --git a/contrib/docker_compose_workers/README.md b/contrib/docker_compose_workers/README.md index bdd3dd32e07f..d3cdfe5614bb 100644 --- a/contrib/docker_compose_workers/README.md +++ b/contrib/docker_compose_workers/README.md @@ -68,6 +68,7 @@ redis: enabled: true host: redis port: 6379 + # dbid: # password: ``` diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 2883f76a26cd..8570d16a944c 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -3927,6 +3927,8 @@ This setting has the following sub-options: * `host` and `port`: Optional host and port to use to connect to redis. Defaults to localhost and 6379 * `password`: Optional password if configured on the Redis instance. +* `dbid`: Optional redis dbid if needs to connect to specific redis logical db. + Example configuration: ```yaml @@ -3935,6 +3937,7 @@ redis: host: localhost port: 6379 password: + dbid: ``` --- ## Individual worker configuration diff --git a/synapse/config/redis.py b/synapse/config/redis.py index b42dd2e93a39..e6a75be43429 100644 --- a/synapse/config/redis.py +++ b/synapse/config/redis.py @@ -33,4 +33,5 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: self.redis_host = redis_config.get("host", "localhost") self.redis_port = redis_config.get("port", 6379) + self.redis_dbid = redis_config.get("dbid", None) self.redis_password = redis_config.get("password") diff --git a/synapse/server.py b/synapse/server.py index 9d6d268f490c..92686baa77a5 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -829,6 +829,7 @@ def get_outbound_redis_connection(self) -> "ConnectionHandler": hs=self, host=self.config.redis.redis_host, port=self.config.redis.redis_port, + dbid=self.config.redis.redis_dbid, password=self.config.redis.redis_password, reconnect=True, ) From 6ea81c25305559fddd5e29d44549ce35e8f96c57 Mon Sep 17 00:00:00 2001 From: "lakwinder.singh" Date: Fri, 10 Feb 2023 11:07:54 +0400 Subject: [PATCH 2/4] adding change log file Signed-off-by: lakwinder.singh --- changelog.d/15034.feature | 0 docs/usage/configuration/config_documentation.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 changelog.d/15034.feature diff --git a/changelog.d/15034.feature b/changelog.d/15034.feature new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 8570d16a944c..9636a5161825 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -3928,7 +3928,7 @@ This setting has the following sub-options: localhost and 6379 * `password`: Optional password if configured on the Redis instance. * `dbid`: Optional redis dbid if needs to connect to specific redis logical db. - + _Added in Synapse 1.78.0 Example configuration: ```yaml From 968e2260910c0a6cb930beb87aea5eac0b755dcb Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 10 Feb 2023 12:23:47 +0000 Subject: [PATCH 3/4] Update docs/usage/configuration/config_documentation.md --- docs/usage/configuration/config_documentation.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 9636a5161825..75483bfb125a 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -3928,7 +3928,8 @@ This setting has the following sub-options: localhost and 6379 * `password`: Optional password if configured on the Redis instance. * `dbid`: Optional redis dbid if needs to connect to specific redis logical db. - _Added in Synapse 1.78.0 + + _Added in Synapse 1.78.0._ Example configuration: ```yaml From 6157d01ad04474b3b197d10cf07ff969004e4ab7 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 10 Feb 2023 12:33:42 +0000 Subject: [PATCH 4/4] Update 15034.feature --- changelog.d/15034.feature | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.d/15034.feature b/changelog.d/15034.feature index e69de29bb2d1..34f320da9200 100644 --- a/changelog.d/15034.feature +++ b/changelog.d/15034.feature @@ -0,0 +1 @@ +Allow Synapse to use a specific Redis [logical database](https://redis.io/commands/select/) in worker-mode deployments.