From 09298cbf0500dec885f5c4c0d08c891b35f051eb Mon Sep 17 00:00:00 2001 From: Brad Murray Date: Thu, 25 Aug 2022 13:17:37 -0400 Subject: [PATCH 1/4] Move retention purge_jobs running to the main worker --- synapse/handlers/pagination.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index 74e944bce72d..a0c39778abba 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -159,11 +159,9 @@ def __init__(self, hs: "HomeServer"): self._retention_allowed_lifetime_max = ( hs.config.retention.retention_allowed_lifetime_max ) + self._is_master = hs.config.worker.worker_app is None - if ( - hs.config.worker.run_background_tasks - and hs.config.retention.retention_enabled - ): + if hs.config.retention.retention_enabled and self._is_master: # Run the purge jobs described in the configuration file. for job in hs.config.retention.retention_purge_jobs: logger.info("Setting up purge job with config: %s", job) From 9e3aa941d0e015773f47956e7557572ab313b0e3 Mon Sep 17 00:00:00 2001 From: Brad Murray Date: Thu, 25 Aug 2022 13:39:16 -0400 Subject: [PATCH 2/4] Add changelog --- changelog.d/13632.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13632.bugfix diff --git a/changelog.d/13632.bugfix b/changelog.d/13632.bugfix new file mode 100644 index 000000000000..748ef39bb521 --- /dev/null +++ b/changelog.d/13632.bugfix @@ -0,0 +1 @@ +Fix the running of MSC1763 retention purge_jobs in multi-worker setups by only running them on the main worker. Contributed by Brad @ Beeper From 0c8d96378f3bce454b9244a59dc4c04e0c3955d0 Mon Sep 17 00:00:00 2001 From: Brad Murray Date: Thu, 25 Aug 2022 13:42:35 -0400 Subject: [PATCH 3/4] Add a period to the changelog --- changelog.d/13632.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13632.bugfix b/changelog.d/13632.bugfix index 748ef39bb521..d059e5774c38 100644 --- a/changelog.d/13632.bugfix +++ b/changelog.d/13632.bugfix @@ -1 +1 @@ -Fix the running of MSC1763 retention purge_jobs in multi-worker setups by only running them on the main worker. Contributed by Brad @ Beeper +Fix the running of MSC1763 retention purge_jobs in multi-worker setups by only running them on the main worker. Contributed by Brad @ Beeper. From 8df87957c8acf7e96281505614d282814c24be59 Mon Sep 17 00:00:00 2001 From: Brad Murray Date: Thu, 25 Aug 2022 15:10:00 -0400 Subject: [PATCH 4/4] Update changelog.d/13632.bugfix --- changelog.d/13632.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13632.bugfix b/changelog.d/13632.bugfix index d059e5774c38..e4b7b403cd33 100644 --- a/changelog.d/13632.bugfix +++ b/changelog.d/13632.bugfix @@ -1 +1 @@ -Fix the running of MSC1763 retention purge_jobs in multi-worker setups by only running them on the main worker. Contributed by Brad @ Beeper. +Fix the running of MSC1763 retention purge_jobs in deployments with background jobs running on a worker by forcing them back onto the main worker. Contributed by Brad @ Beeper.