From 322481cd2d694eb5fe6107f3c0cd8d48252439bc Mon Sep 17 00:00:00 2001 From: Devon Hudson Date: Mon, 17 Nov 2025 15:32:21 +0000 Subject: [PATCH] Run background updates on all databases (#19181) Fixes #18322 This PR changes synapse startup to run background updates against all databases instead of just the "main" database. This follows [what the admin api does](https://github.com/element-hq/synapse/blob/develop/synapse/rest/admin/background_updates.py#L71-L77). See the above linked issue for further details of why this is beneficial. ### Pull Request Checklist * [X] Pull request is based on the develop branch * [X] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [X] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters)) --- changelog.d/19181.bugfix | 1 + synapse/app/homeserver.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog.d/19181.bugfix diff --git a/changelog.d/19181.bugfix b/changelog.d/19181.bugfix new file mode 100644 index 000000000..af3c988b0 --- /dev/null +++ b/changelog.d/19181.bugfix @@ -0,0 +1 @@ +Run background updates on all databases. diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 8fb906cdf..bd2956d9e 100644 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -450,7 +450,8 @@ async def start( await _base.start(hs, freeze=freeze) # TODO: Feels like this should be moved somewhere else. - hs.get_datastores().main.db_pool.updates.start_doing_background_updates() + for db in hs.get_datastores().databases: + db.updates.start_doing_background_updates() def start_reactor(