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

Commit 02086e1

Browse files
authored
Fix rotating existing notifications in push summary (#14138)
Broke by #14045. Fixes #14120. Introduced in v1.69.0rc2.
1 parent 422cff7 commit 02086e1

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

changelog.d/14138.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix error in background update when rotating existing notifications. Introduced in v1.69.0rc2.

synapse/storage/databases/main/event_push_actions.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,11 +1104,13 @@ def _handle_new_receipts_for_notifs_txn(self, txn: LoggingTransaction) -> bool:
11041104
)
11051105

11061106
# First ensure that the existing rows have an updated thread_id field.
1107-
self.db_pool.simple_update_txn(
1108-
txn,
1109-
table="event_push_summary",
1110-
keyvalues={"room_id": room_id, "user_id": user_id, "thread_id": None},
1111-
updatevalues={"thread_id": "main"},
1107+
txn.execute(
1108+
"""
1109+
UPDATE event_push_summary
1110+
SET thread_id = ?
1111+
WHERE room_id = ? AND user_id = ? AND thread_id is NULL
1112+
""",
1113+
("main", room_id, user_id),
11121114
)
11131115

11141116
# Replace the previous summary with the new counts.
@@ -1272,6 +1274,14 @@ def _rotate_notifs_before_txn(
12721274
logger.info("Rotating notifications, handling %d rows", len(summaries))
12731275

12741276
# Ensure that any updated threads have an updated thread_id.
1277+
txn.execute_batch(
1278+
"""
1279+
UPDATE event_push_summary
1280+
SET thread_id = ?
1281+
WHERE room_id = ? AND user_id = ? AND thread_id is NULL
1282+
""",
1283+
[("main", room_id, user_id) for user_id, room_id in summaries],
1284+
)
12751285
self.db_pool.simple_update_many_txn(
12761286
txn,
12771287
table="event_push_summary",

0 commit comments

Comments
 (0)