Add a shortcut return when there are no events to purge. (#19093)

Fixes: #13417

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
This commit is contained in:
reivilibre
2025-11-13 14:26:37 +00:00
committed by GitHub
parent e67ba69f20
commit 938c97416d
2 changed files with 11 additions and 0 deletions

1
changelog.d/19093.misc Normal file
View File

@@ -0,0 +1 @@
Add a shortcut return when there are no events to purge.

View File

@@ -239,6 +239,16 @@ class PurgeEventsStore(StateGroupWorkerStore, CacheInvalidationWorkerStore):
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),