From d40aff7343fdd1da90335baa421ca330aad70f3e Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 29 Sep 2020 07:47:28 -0400 Subject: [PATCH] Do not require the background worker instance to be in the instance map. --- docs/workers.md | 11 ++++------- synapse/config/workers.py | 13 +++---------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/docs/workers.md b/docs/workers.md index 3bb679fa37..87c10f7fd3 100644 --- a/docs/workers.md +++ b/docs/workers.md @@ -310,15 +310,12 @@ worker. Background tasks are run periodically or started via replication. Exactl which tasks are configured to run depends on your Synapse configuration (e.g. if stats is enabled). -To enable this, the worker must have a `worker_name` and be listed in the -`instance_map` config. For example, to move background tasks to a dedicated -worker, the shared configuration would include: +To enable this, the worker must have a `worker_name` and can be configured to run +background tasks. For example, to move background tasks to a dedicated worker, +the shared configuration would include: ```yaml -instance_map: - background_worker: null - -run_background_tasks: background_worker +run_background_tasks_on: background_worker ``` ### `synapse.app.pusher` diff --git a/synapse/config/workers.py b/synapse/config/workers.py index 6c566ad429..3034eef456 100644 --- a/synapse/config/workers.py +++ b/synapse/config/workers.py @@ -109,12 +109,10 @@ class WorkerConfig(Config): federation_sender_instances ) - # A map from instance name to host/port of their HTTP replication endpoint - # (or None if there's no HTTP replication endpoint). + # A map from instance name to host/port of their HTTP replication endpoint. instance_map = config.get("instance_map") or {} self.instance_map = { - name: InstanceLocationConfig(**c) if c else None - for name, c in instance_map.items() + name: InstanceLocationConfig(**c) for name, c in instance_map.items() } # Map from type of streams to source, c.f. WriterLocations. @@ -140,14 +138,9 @@ class WorkerConfig(Config): # be able to run on only a single instance (meaning that they don't # depend on any in-memory state of a particular worker). # - # Effort is not made to ensure only a single instance of these tasks is + # No effort is made to ensure only a single instance of these tasks is # running. instance = config.get("run_background_tasks_on") or "master" - if instance != "master" and instance not in self.instance_map: - raise ConfigError( - "Instance %r is configured to run background tasks but does not appear in `instance_map` config." - % (instance,) - ) self.run_background_tasks = ( self.worker_name is None and instance == "master" ) or self.worker_name == instance