Skip to content

Commit cef9f5f

Browse files
committed
Add a shortcut exit when no events to purge
1 parent fc244bb commit cef9f5f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

synapse/storage/databases/main/purge_events.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ def _purge_history_txn(
239239

240240
txn.execute("SELECT event_id, should_delete FROM events_to_purge")
241241
event_rows = txn.fetchall()
242+
243+
if len(event_rows) == 0:
244+
logger.info("[purge] no events found to purge")
245+
246+
# For the sake of cleanliness: drop the temp table.
247+
# This will commit the txn in sqlite, so make sure to keep this actually last.
248+
txn.execute("DROP TABLE events_to_purge")
249+
return
250+
242251
logger.info(
243252
"[purge] found %i events before cutoff, of which %i can be deleted",
244253
len(event_rows),

0 commit comments

Comments
 (0)