From ad332bd56a5c8f8ccbbd41521d14dd4ed857fbd6 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 24 Sep 2018 14:32:45 +0100 Subject: [PATCH 1/3] only try to LL members after a non-gappy incr sync if the timeline has events. This was okay until we started to try to LL ourselves, which would then cause us to try to add LL members even if the timeline was empty. This caused an out of bounds exception --- synapse/handlers/sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index b598916b215c..9d221e573b15 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -794,7 +794,7 @@ def compute_state_delta(self, room_id, batch, sync_config, since_token, now_toke else: state_ids = {} if lazy_load_members: - if types: + if types and batch.events: # We're returning an incremental sync, with no # "gap" since the previous sync, so normally there would be # no state to return. From 807c30929d6ee6e7b122bff1e1336207926da4d3 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 24 Sep 2018 15:11:39 +0100 Subject: [PATCH 2/3] changelog --- changelog.d/3936.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/3936.bugfix diff --git a/changelog.d/3936.bugfix b/changelog.d/3936.bugfix new file mode 100644 index 000000000000..49b02b9e2781 --- /dev/null +++ b/changelog.d/3936.bugfix @@ -0,0 +1 @@ +Fix out-of-bounds error when LLing yourself From 6ce888b8bdd14344fb595039924492a6fbde2254 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 24 Sep 2018 23:54:53 +0100 Subject: [PATCH 3/3] only LL self in initial sync --- synapse/handlers/sync.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 9d221e573b15..c7d69d9d805c 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -713,10 +713,6 @@ def compute_state_delta(self, room_id, batch, sync_config, since_token, now_toke ) ] - # always make sure we LL ourselves so we know we're in the room - # (if we are), to fix https://github.com/vector-im/riot-web/issues/7209 - types.append((EventTypes.Member, sync_config.user.to_string())) - # only apply the filtering to room members filtered_types = [EventTypes.Member] @@ -726,6 +722,13 @@ def compute_state_delta(self, room_id, batch, sync_config, since_token, now_toke } if full_state: + if lazy_load_members: + # always make sure we LL ourselves so we know we're in the room + # (if we are) to fix https://github.com/vector-im/riot-web/issues/7209 + # We only need apply this on full state syncs given we disabled + # LL for incr syncs in #3840. + types.append((EventTypes.Member, sync_config.user.to_string())) + if batch: current_state_ids = yield self.store.get_state_ids_for_event( batch.events[-1].event_id, types=types,