Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit d40aff7

Browse files
committed
Do not require the background worker instance to be in the instance map.
1 parent 0c9e970 commit d40aff7

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

docs/workers.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,12 @@ worker. Background tasks are run periodically or started via replication. Exactl
310310
which tasks are configured to run depends on your Synapse configuration (e.g. if
311311
stats is enabled).
312312

313-
To enable this, the worker must have a `worker_name` and be listed in the
314-
`instance_map` config. For example, to move background tasks to a dedicated
315-
worker, the shared configuration would include:
313+
To enable this, the worker must have a `worker_name` and can be configured to run
314+
background tasks. For example, to move background tasks to a dedicated worker,
315+
the shared configuration would include:
316316

317317
```yaml
318-
instance_map:
319-
background_worker: null
320-
321-
run_background_tasks: background_worker
318+
run_background_tasks_on: background_worker
322319
```
323320

324321
### `synapse.app.pusher`

synapse/config/workers.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,10 @@ def read_config(self, config, **kwargs):
109109
federation_sender_instances
110110
)
111111

112-
# A map from instance name to host/port of their HTTP replication endpoint
113-
# (or None if there's no HTTP replication endpoint).
112+
# A map from instance name to host/port of their HTTP replication endpoint.
114113
instance_map = config.get("instance_map") or {}
115114
self.instance_map = {
116-
name: InstanceLocationConfig(**c) if c else None
117-
for name, c in instance_map.items()
115+
name: InstanceLocationConfig(**c) for name, c in instance_map.items()
118116
}
119117

120118
# Map from type of streams to source, c.f. WriterLocations.
@@ -140,14 +138,9 @@ def read_config(self, config, **kwargs):
140138
# be able to run on only a single instance (meaning that they don't
141139
# depend on any in-memory state of a particular worker).
142140
#
143-
# Effort is not made to ensure only a single instance of these tasks is
141+
# No effort is made to ensure only a single instance of these tasks is
144142
# running.
145143
instance = config.get("run_background_tasks_on") or "master"
146-
if instance != "master" and instance not in self.instance_map:
147-
raise ConfigError(
148-
"Instance %r is configured to run background tasks but does not appear in `instance_map` config."
149-
% (instance,)
150-
)
151144
self.run_background_tasks = (
152145
self.worker_name is None and instance == "master"
153146
) or self.worker_name == instance

0 commit comments

Comments
 (0)