Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix bug where we failed to delete old push actions #13194

Merged
merged 3 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13194.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where rows where not delete from `event_push_actions` table on large servers. Introduced in v1.62.0.
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 4 additions & 2 deletions synapse/storage/databases/main/event_push_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
""",
(
Expand All @@ -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,),
)
Expand Down