From 5c760d3422239e0172b88fc59acbb9736f44552f Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 6 Jul 2022 11:08:31 +0100 Subject: [PATCH 1/3] Fix bug where we failed to delete old push actions This happened if we encountered a stream ordering in `event_push_actions` that had more rows than the batch size of the delete. --- synapse/storage/databases/main/event_push_actions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/synapse/storage/databases/main/event_push_actions.py b/synapse/storage/databases/main/event_push_actions.py index 32536430aa1c..a3edcbb39892 100644 --- a/synapse/storage/databases/main/event_push_actions.py +++ b/synapse/storage/databases/main/event_push_actions.py @@ -1114,7 +1114,7 @@ def remove_old_push_actions_that_have_rotated_txn( 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 @@ def remove_old_push_actions_that_have_rotated_txn( 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,), ) From 4485a56f7715a1c5d5325c1b24150241029d1bf8 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 6 Jul 2022 11:10:58 +0100 Subject: [PATCH 2/3] Newsfile --- changelog.d/13194.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13194.bugfix diff --git a/changelog.d/13194.bugfix b/changelog.d/13194.bugfix new file mode 100644 index 000000000000..d4b1fcff6db1 --- /dev/null +++ b/changelog.d/13194.bugfix @@ -0,0 +1 @@ +Fix bug where rows where not delete from `event_push_actions` table on large servers. Introduced in v1.62.0. From 4daaeb3bdf71c1d1ebd34575af50fcffed90ccb4 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 6 Jul 2022 11:29:05 +0100 Subject: [PATCH 3/3] Update changelog.d/13194.bugfix Co-authored-by: reivilibre --- changelog.d/13194.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13194.bugfix b/changelog.d/13194.bugfix index d4b1fcff6db1..2c2e8bb21b6c 100644 --- a/changelog.d/13194.bugfix +++ b/changelog.d/13194.bugfix @@ -1 +1 @@ -Fix bug where rows where not delete from `event_push_actions` table on large servers. Introduced in v1.62.0. +Fix bug where rows were not deleted from `event_push_actions` table on large servers. Introduced in v1.62.0.