From 775b2de9f036a34c37d6c9a58d67cc1269288c06 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Mon, 9 Dec 2024 16:46:55 +0100 Subject: [PATCH] Disable statement timeout during room purge --- changelog.d/18017.misc | 1 + synapse/storage/databases/main/purge_events.py | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 changelog.d/18017.misc diff --git a/changelog.d/18017.misc b/changelog.d/18017.misc new file mode 100644 index 0000000000..6b943a5bed --- /dev/null +++ b/changelog.d/18017.misc @@ -0,0 +1 @@ +Disable DB statement timeout when doing a purge room since it can be quite long. diff --git a/synapse/storage/databases/main/purge_events.py b/synapse/storage/databases/main/purge_events.py index 08244153a3..c195685af8 100644 --- a/synapse/storage/databases/main/purge_events.py +++ b/synapse/storage/databases/main/purge_events.py @@ -376,6 +376,11 @@ class PurgeEventsStore(StateGroupWorkerStore, CacheInvalidationWorkerStore): (room_id,), ) + if isinstance(self.database_engine, PostgresEngine): + # Disable statement timeouts for this transaction; purging rooms can + # take a while! + txn.execute("SET LOCAL statement_timeout = 0") + # First, fetch all the state groups that should be deleted, before # we delete that information. txn.execute(