summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2018-07-25 13:24:04 +0100
committerGitHub <noreply@github.com>2018-07-25 13:24:04 +0100
commit3849f7f69fe02113be519b630a2c43ece4dadc44 (patch)
tree9f3259b313fe18a5deae12b8d911c748d74869b6
parentMerge pull request #3606 from matrix-org/rav/logcontext_fixes_once_more (diff)
parentActually fix it by adding continue (diff)
downloadsynapse-3849f7f69fe02113be519b630a2c43ece4dadc44.tar.xz
Merge pull request #3603 from matrix-org/erikj/handle_outliers
 Correctly handle outliers during persist events
-rw-r--r--changelog.d/3601.bugfix1
-rw-r--r--synapse/storage/events.py14
2 files changed, 9 insertions, 6 deletions
diff --git a/changelog.d/3601.bugfix b/changelog.d/3601.bugfix
new file mode 100644
index 0000000000..1678b261d0
--- /dev/null
+++ b/changelog.d/3601.bugfix
@@ -0,0 +1 @@
+Fix failure to persist events over federation under load
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index d39796f5ba..200f5ec95f 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -574,11 +574,13 @@ class EventsStore(EventsWorkerStore):
 
         for ev, ctx in events_context:
             if ctx.state_group is None:
-                # I don't think this can happen, but let's double-check
-                raise Exception(
-                    "Context for new extremity event %s has no state "
-                    "group" % (ev.event_id, ),
-                )
+                # This should only happen for outlier events.
+                if not ev.internal_metadata.is_outlier():
+                    raise Exception(
+                        "Context for new event %s has no state "
+                        "group" % (ev.event_id, ),
+                    )
+                continue
 
             if ctx.state_group in state_groups_map:
                 continue
@@ -606,7 +608,7 @@ class EventsStore(EventsWorkerStore):
         for event_id in new_latest_event_ids:
             # First search in the list of new events we're adding.
             for ev, ctx in events_context:
-                if event_id == ev.event_id:
+                if event_id == ev.event_id and ctx.state_group is not None:
                     event_id_to_state_group[event_id] = ctx.state_group
                     break
             else: