From b03dc0a9978837ffc0bd258bb90638c4efc5c678 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 2 Sep 2024 10:33:39 +0100 Subject: [PATCH] Ignore leave events for bg updates --- synapse/storage/databases/main/events_bg_updates.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/synapse/storage/databases/main/events_bg_updates.py b/synapse/storage/databases/main/events_bg_updates.py index 743200471b..a5d04c719f 100644 --- a/synapse/storage/databases/main/events_bg_updates.py +++ b/synapse/storage/databases/main/events_bg_updates.py @@ -1927,10 +1927,11 @@ class EventsBackgroundUpdatesStore(StreamWorkerStore, StateDeltasStore, SQLBaseS LEFT JOIN rooms AS r ON (c.room_id = r.room_id) WHERE (c.room_id, c.user_id) > (?, ?) AND (m.user_id IS NULL OR c.event_id != m.membership_event_id) + AND (c.membership != ? OR c.user_id != e.sender) ORDER BY c.room_id ASC, c.user_id ASC LIMIT ? """, - (last_room_id, last_user_id, batch_size), + (last_room_id, last_user_id, Membership.LEAVE, batch_size), ) elif last_event_stream_ordering is not None: # It's important to sort by `event_stream_ordering` *ascending* (oldest to @@ -1961,10 +1962,11 @@ class EventsBackgroundUpdatesStore(StreamWorkerStore, StateDeltasStore, SQLBaseS LEFT JOIN rooms AS r ON (c.room_id = r.room_id) WHERE c.event_stream_ordering > ? AND (m.user_id IS NULL OR c.event_id != m.membership_event_id) + AND (c.membership != ? OR c.user_id != e.sender) ORDER BY c.event_stream_ordering ASC LIMIT ? """, - (last_event_stream_ordering, batch_size), + (last_event_stream_ordering, Membership.LEAVE, batch_size), ) else: raise Exception("last_event_stream_ordering should not be None")