From 7723b4caa4a1d4e0ee252165dcfaf910bda31ef2 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 8 Feb 2017 14:48:06 +0000 Subject: [PATCH 1/2] Ignore new rejected events when working out forward extremeties. --- synapse/storage/events.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index 8659f605a5..c88f689d3a 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -302,7 +302,7 @@ class EventsStore(SQLBaseStore): room_id ) new_latest_event_ids = yield self._calculate_new_extremeties( - room_id, [ev for ev, _ in ev_ctx_rm] + room_id, ev_ctx_rm, latest_event_ids ) if new_latest_event_ids == set(latest_event_ids): @@ -329,27 +329,24 @@ class EventsStore(SQLBaseStore): persist_event_counter.inc_by(len(chunk)) @defer.inlineCallbacks - def _calculate_new_extremeties(self, room_id, events): + def _calculate_new_extremeties(self, room_id, event_contexts, latest_event_ids): """Calculates the new forward extremeties for a room given events to persist. Assumes that we are only persisting events for one room at a time. """ - latest_event_ids = yield self.get_latest_event_ids_in_room( - room_id - ) new_latest_event_ids = set(latest_event_ids) # First, add all the new events to the list new_latest_event_ids.update( - event.event_id for event in events - if not event.internal_metadata.is_outlier() + event.event_id for event, ctx in event_contexts + if not event.internal_metadata.is_outlier() and not ctx.rejected ) # Now remove all events that are referenced by the to-be-added events new_latest_event_ids.difference_update( e_id - for event in events + for event, ctx in event_contexts for e_id, _ in event.prev_events - if not event.internal_metadata.is_outlier() + if not event.internal_metadata.is_outlier() and not ctx.rejected ) # And finally remove any events that are referenced by previously added From 505bfd82bbf1ff51e8f08a98c72b9d214a269d33 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 9 Feb 2017 10:41:02 +0000 Subject: [PATCH 2/2] Update version and changelog --- CHANGES.rst | 7 +++++++ synapse/__init__.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index da241666d6..22aa7cb9b4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,10 @@ +Changes in synapse v0.19.1 (2017-02-09) +======================================= + +* Fix bug where state was incorrectly reset in a room when synapse received an + event over federation that did not pass auth checks (PR #1892) + + Changes in synapse v0.19.0 (2017-02-04) ======================================= diff --git a/synapse/__init__.py b/synapse/__init__.py index d3f445be9c..da8ef90a77 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -16,4 +16,4 @@ """ This is a reference implementation of a Matrix home server. """ -__version__ = "0.19.0" +__version__ = "0.19.1"