mirror of
https://github.com/element-hq/synapse
synced 2024-08-31 23:20:21 +00:00
Correctly handle outliers during persist events
We incorrectly asserted that all contexts must have a non None state group without consider outliers. This would usually be fine as the assertion would never be hit, as there is a shortcut during persistence if the forward extremities don't change. However, if the outlier is being persisted with non-outlier events, the function would be called and the assertion would be hit. Fixes #3601
This commit is contained in:
parent
1e5dbdcbb1
commit
ec56121b0d
1 changed files with 7 additions and 6 deletions
|
@ -575,9 +575,10 @@ class EventsStore(EventsWorkerStore):
|
||||||
|
|
||||||
for ev, ctx in events_context:
|
for ev, ctx in events_context:
|
||||||
if ctx.state_group is None:
|
if ctx.state_group is None:
|
||||||
# I don't think this can happen, but let's double-check
|
# This should only happen for outlier events.
|
||||||
|
if not event.internal_metadata.is_outlier():
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Context for new extremity event %s has no state "
|
"Context for new event %s has no state "
|
||||||
"group" % (ev.event_id, ),
|
"group" % (ev.event_id, ),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -607,7 +608,7 @@ class EventsStore(EventsWorkerStore):
|
||||||
for event_id in new_latest_event_ids:
|
for event_id in new_latest_event_ids:
|
||||||
# First search in the list of new events we're adding.
|
# First search in the list of new events we're adding.
|
||||||
for ev, ctx in events_context:
|
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
|
event_id_to_state_group[event_id] = ctx.state_group
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue