Skip to content

Commit a4fa044

Browse files
authored
Fix 'rejected_events_metadata' background update (matrix-org#9537)
Turns out matrix.org has an event that has duplicate auth events (which really isn't supposed to happen, but here we are). This caused the background update to fail due to `UniqueViolation`.
1 parent 922788c commit a4fa044

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

changelog.d/9537.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix rare edge case that caused a background update to fail if the server had rejected an event that had duplicate auth events.

synapse/storage/databases/main/events_bg_updates.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,9 @@ def get_rejected_events(
696696
)
697697

698698
if not has_event_auth:
699-
for auth_id in event.auth_event_ids():
699+
# Old, dodgy, events may have duplicate auth events, which we
700+
# need to deduplicate as we have a unique constraint.
701+
for auth_id in set(event.auth_event_ids()):
700702
auth_events.append(
701703
{
702704
"room_id": event.room_id,

0 commit comments

Comments
 (0)