diff --git a/changelog.d/19093.misc b/changelog.d/19093.misc new file mode 100644 index 00000000000..39ada26b685 --- /dev/null +++ b/changelog.d/19093.misc @@ -0,0 +1 @@ +Add a shortcut return when there are no events to purge. \ No newline at end of file diff --git a/synapse/storage/databases/main/purge_events.py b/synapse/storage/databases/main/purge_events.py index 10de1b35a6e..d55ea5cf7d4 100644 --- a/synapse/storage/databases/main/purge_events.py +++ b/synapse/storage/databases/main/purge_events.py @@ -239,6 +239,16 @@ def _purge_history_txn( txn.execute("SELECT event_id, should_delete FROM events_to_purge") event_rows = txn.fetchall() + + if len(event_rows) == 0: + logger.info("[purge] no events found to purge") + + # For the sake of cleanliness: drop the temp table. + # This will commit the txn in sqlite, so make sure to keep this actually last. + txn.execute("DROP TABLE events_to_purge") + # no referenced state groups + return set() + logger.info( "[purge] found %i events before cutoff, of which %i can be deleted", len(event_rows),