diff options
-rw-r--r-- | changelog.d/13194.bugfix | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/event_push_actions.py | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/changelog.d/13194.bugfix b/changelog.d/13194.bugfix new file mode 100644 index 0000000000..2c2e8bb21b --- /dev/null +++ b/changelog.d/13194.bugfix @@ -0,0 +1 @@ +Fix bug where rows were not deleted from `event_push_actions` table on large servers. Introduced in v1.62.0. diff --git a/synapse/storage/databases/main/event_push_actions.py b/synapse/storage/databases/main/event_push_actions.py index 32536430aa..a3edcbb398 100644 --- a/synapse/storage/databases/main/event_push_actions.py +++ b/synapse/storage/databases/main/event_push_actions.py @@ -1114,7 +1114,7 @@ class EventPushActionsWorkerStore(ReceiptsWorkerStore, StreamWorkerStore, SQLBas txn.execute( """ SELECT stream_ordering FROM event_push_actions - WHERE stream_ordering < ? AND highlight = 0 + WHERE stream_ordering <= ? AND highlight = 0 ORDER BY stream_ordering ASC LIMIT 1 OFFSET ? """, ( @@ -1129,10 +1129,12 @@ class EventPushActionsWorkerStore(ReceiptsWorkerStore, StreamWorkerStore, SQLBas else: stream_ordering = max_stream_ordering_to_delete + # We need to use a inclusive bound here to handle the case where a + # single stream ordering has more than `batch_size` rows. txn.execute( """ DELETE FROM event_push_actions - WHERE stream_ordering < ? AND highlight = 0 + WHERE stream_ordering <= ? AND highlight = 0 """, (stream_ordering,), ) |