diff options
author | Erik Johnston <erik@matrix.org> | 2022-10-11 16:13:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-11 15:13:32 +0000 |
commit | 02086e1da0e3fa3d5002bf2eb7560c043ad47187 (patch) | |
tree | 9e9e676f286a4b1142b344f9b6efaf42034909c3 /synapse/storage | |
parent | Fallback if 'approved' isn't included in a registration replication request (... (diff) | |
download | synapse-02086e1da0e3fa3d5002bf2eb7560c043ad47187.tar.xz |
Fix rotating existing notifications in push summary (#14138)
Broke by #14045. Fixes #14120. Introduced in v1.69.0rc2.
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/databases/main/event_push_actions.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/synapse/storage/databases/main/event_push_actions.py b/synapse/storage/databases/main/event_push_actions.py index c9724d7345..87d07f7d9b 100644 --- a/synapse/storage/databases/main/event_push_actions.py +++ b/synapse/storage/databases/main/event_push_actions.py @@ -1104,11 +1104,13 @@ class EventPushActionsWorkerStore(ReceiptsWorkerStore, StreamWorkerStore, SQLBas ) # First ensure that the existing rows have an updated thread_id field. - self.db_pool.simple_update_txn( - txn, - table="event_push_summary", - keyvalues={"room_id": room_id, "user_id": user_id, "thread_id": None}, - updatevalues={"thread_id": "main"}, + txn.execute( + """ + UPDATE event_push_summary + SET thread_id = ? + WHERE room_id = ? AND user_id = ? AND thread_id is NULL + """, + ("main", room_id, user_id), ) # Replace the previous summary with the new counts. @@ -1272,6 +1274,14 @@ class EventPushActionsWorkerStore(ReceiptsWorkerStore, StreamWorkerStore, SQLBas logger.info("Rotating notifications, handling %d rows", len(summaries)) # Ensure that any updated threads have an updated thread_id. + txn.execute_batch( + """ + UPDATE event_push_summary + SET thread_id = ? + WHERE room_id = ? AND user_id = ? AND thread_id is NULL + """, + [("main", room_id, user_id) for user_id, room_id in summaries], + ) self.db_pool.simple_update_many_txn( txn, table="event_push_summary", |