From d399d7649aedaeb3cd9edbc258917c407893c172 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 10 Oct 2025 14:30:38 -0500 Subject: [PATCH] Move `start_doing_background_updates()` to `SynapseHomeServer.start_background_tasks()` (#19036) (more sane standard location for this sort of thing) The one difference here is that previously, `start_doing_background_updates ()` only ran on the main Synapse instance. But since it now lives in `start_background_tasks()`, it will run on the worker that supposed to `run_background_tasks`. Doesn't seem like a problem though. --- changelog.d/19036.misc | 1 + synapse/app/homeserver.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelog.d/19036.misc diff --git a/changelog.d/19036.misc b/changelog.d/19036.misc new file mode 100644 index 000000000..95b8daab9 --- /dev/null +++ b/changelog.d/19036.misc @@ -0,0 +1 @@ +Move `start_doing_background_updates()` to `SynapseHomeServer.start_background_tasks()`. diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 8d9b76e08..b9ac86c2f 100644 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -317,6 +317,11 @@ class SynapseHomeServer(HomeServer): # during parsing logger.warning("Unrecognized listener type: %s", listener.type) + def start_background_tasks(self) -> None: + super().start_background_tasks() + + self.get_datastores().main.db_pool.updates.start_doing_background_updates() + def load_or_generate_config(argv_options: List[str]) -> HomeServerConfig: """ @@ -430,11 +435,6 @@ def setup( await _base.start(hs, freeze) - # TODO: This should be moved to `SynapseHomeServer.start_background_tasks` (not - # `HomeServer.start_background_tasks`) (this way it matches the behavior of only - # running on `main`) - hs.get_datastores().main.db_pool.updates.start_doing_background_updates() - # Register a callback to be invoked once the reactor is running register_start(hs, _start_when_reactor_running)