Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Ignore new rejected events when working out forward extremities. #1892

Merged
merged 1 commit into from
Feb 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def _persist_events(self, events_and_contexts, backfilled=False,
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):
Expand All @@ -329,27 +329,24 @@ def _persist_events(self, events_and_contexts, backfilled=False,
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
Expand Down