From eb67ce16ac5fee13eb6c72369e1d32af3d847db8 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 3 Mar 2021 15:29:20 +0000 Subject: [PATCH 1/2] Fix 'rejected_events_metadata' background update --- synapse/storage/databases/main/events_bg_updates.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/synapse/storage/databases/main/events_bg_updates.py b/synapse/storage/databases/main/events_bg_updates.py index c1626ccf28d1..cb6b1f8a0c17 100644 --- a/synapse/storage/databases/main/events_bg_updates.py +++ b/synapse/storage/databases/main/events_bg_updates.py @@ -696,7 +696,9 @@ def get_rejected_events( ) if not has_event_auth: - for auth_id in event.auth_event_ids(): + # Old, dodgy, events may have duplicate auth events, which we + # need to deduplicate as we have a unique constraint. + for auth_id in set(event.auth_event_ids()): auth_events.append( { "room_id": event.room_id, From 69d5139729df25fafb1cca9b5ddbf337c1f7a217 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 3 Mar 2021 15:37:21 +0000 Subject: [PATCH 2/2] Newsfile --- changelog.d/9537.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/9537.bugfix diff --git a/changelog.d/9537.bugfix b/changelog.d/9537.bugfix new file mode 100644 index 000000000000..033ab1c939d4 --- /dev/null +++ b/changelog.d/9537.bugfix @@ -0,0 +1 @@ +Fix rare edge case that caused a background update to fail if the server had rejected an event that had duplicate auth events.