diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2023-05-10 18:12:34 +0100 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2023-05-10 18:26:13 +0100 |
commit | 48f2eb9da46fb4ddbc01362c34256dd81ebe5a1a (patch) | |
tree | 5b2d74c592fd03df91d9ad277be4949b4ecbc194 | |
parent | Merge remote-tracking branch 'origin/release-v1.83' into matrix-org-hotfixes (diff) | |
download | synapse-anoa/redirect_instances.tar.xz |
Redirect event persistence traffic to a particular event persister worker github/anoa/redirect_instances anoa/redirect_instances
-rw-r--r-- | synapse/config/workers.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/config/workers.py b/synapse/config/workers.py index 95b4047f1d..658588a7f7 100644 --- a/synapse/config/workers.py +++ b/synapse/config/workers.py @@ -276,6 +276,24 @@ class WorkerConfig(Config): self.writers.events ) + # Patch the event shard config to point specific rooms to a specific worker. + # All other rooms should have events persisted by a different worker. + chosen_worker_instance = "event_persister-4" + self.events_shard_config.instances.remove(chosen_worker_instance) + + def get_instance_patched(self, key: str) -> str: + rooms_to_repoint = [ + "!ioWEdTBHIhOGYVKWyq:libera.chat", + "!bBgnAGciIvrtPXkHkp:libera.chat", + ] + if key in rooms_to_repoint: + return chosen_worker_instance + + # Return another, deterministic instance. + return self._get_instance(key) + + self.events_shard_config.get_instance = get_instance_patched + # Handle sharded push pusher_instances = self._worker_names_performing_this_duty( config, |