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

Disable statement timeout whilst purging rooms #16455

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/16455.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent the purging of large rooms from timing out when Postgres is in use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know when this was introduced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!

5 changes: 5 additions & 0 deletions synapse/storage/databases/main/purge_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def _purge_history_txn(
# furthermore, we might already have the table from a previous (failed)
# purge attempt, so let's drop the table first.

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")

txn.execute("DROP TABLE IF EXISTS events_to_purge")

txn.execute(
Expand Down