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

Commit a701c08

Browse files
authored
Fix schema delta error in 1.85 (#15738)
There appears to be a race where you can end up with entries in `event_push_summary` with both a `NULL` and `main` thread ID. Fixes #15736 Introduced in #15597
1 parent ec71214 commit a701c08

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

changelog.d/15738.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug in schema delta that broke upgrades for some deployments. Introduced in v1.85.0.

synapse/storage/schema/main/delta/77/05thread_notifications_backfill.sql

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ DELETE FROM background_updates WHERE update_name = 'event_push_backfill_thread_i
2121
-- Overwrite any null thread_id values.
2222
UPDATE event_push_actions_staging SET thread_id = 'main' WHERE thread_id IS NULL;
2323
UPDATE event_push_actions SET thread_id = 'main' WHERE thread_id IS NULL;
24+
25+
-- Empirically we can end up with entries in the push summary table with both a
26+
-- `NULL` and `main` thread ID, which causes the update below to fail. We fudge
27+
-- this by deleting any `NULL` rows that have a corresponding `main`.
28+
DELETE FROM event_push_summary AS a WHERE thread_id IS NULL AND EXISTS (
29+
SELECT 1 FROM event_push_summary AS b
30+
WHERE b.thread_id = 'main' AND a.user_id = b.user_id AND a.room_id = b.room_id
31+
);
2432
UPDATE event_push_summary SET thread_id = 'main' WHERE thread_id IS NULL;
2533

2634
-- Drop the background updates to calculate the indexes used to find null thread_ids.

0 commit comments

Comments
 (0)