Skip to content

Commit ea6b3ca

Browse files
committed
Prune the right number of excess finalised events
1 parent 96ed87a commit ea6b3ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

synapse/storage/databases/main/delayed_events.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ def _prune_excess_finalised_delayed_events_for_user(
307307
keyvalues={"user_localpart": user_localpart},
308308
retcol="COUNT(*)",
309309
)
310-
if num_existing > retention_limit:
310+
num_excess = num_existing - retention_limit
311+
if num_existing > 0:
311312
txn.execute(
312313
"""
313314
DELETE FROM delayed_events
@@ -321,7 +322,7 @@ def _prune_excess_finalised_delayed_events_for_user(
321322
""",
322323
(
323324
user_localpart,
324-
num_existing - retention_limit,
325+
num_existing - num_existing,
325326
),
326327
)
327328

0 commit comments

Comments
 (0)