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

Commit

Permalink
Exclude soft-failed events from fwd-extremity candidates. (#5146)
Browse files Browse the repository at this point in the history
When considering the candidates to be forward-extremities, we must exclude soft
failures.

Hopefully fixes #5090.
  • Loading branch information
richvdh authored May 21, 2019
1 parent bab3edd commit c4aef54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/5146.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Exclude soft-failed events from forward-extremity candidates: fixes "No forward extremities left!" error.
7 changes: 6 additions & 1 deletion synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,11 @@ def _check_for_soft_fail(self, event, state, backfilled):
event.room_id, latest_event_ids=extrem_ids,
)

logger.debug(
"Doing soft-fail check for %s: state %s",
event.event_id, current_state_ids,
)

# Now check if event pass auth against said current state
auth_types = auth_types_for_event(event)
current_state_ids = [
Expand All @@ -1932,7 +1937,7 @@ def _check_for_soft_fail(self, event, state, backfilled):
self.auth.check(room_version, event, auth_events=current_auth_events)
except AuthError as e:
logger.warn(
"Failed current state auth resolution for %r because %s",
"Soft-failing %r because %s",
event, e,
)
event.internal_metadata.soft_failed = True
Expand Down
9 changes: 7 additions & 2 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,11 @@ def _get_events_which_are_prevs(self, event_ids):

def _get_events(txn, batch):
sql = """
SELECT prev_event_id
SELECT prev_event_id, internal_metadata
FROM event_edges
INNER JOIN events USING (event_id)
LEFT JOIN rejections USING (event_id)
LEFT JOIN event_json USING (event_id)
WHERE
prev_event_id IN (%s)
AND NOT events.outlier
Expand All @@ -588,7 +589,11 @@ def _get_events(txn, batch):
)

txn.execute(sql, batch)
results.extend(r[0] for r in txn)
results.extend(
r[0]
for r in txn
if not json.loads(r[1]).get("soft_failed")
)

for chunk in batch_iter(event_ids, 100):
yield self.runInteraction("_get_events_which_are_prevs", _get_events, chunk)
Expand Down

0 comments on commit c4aef54

Please sign in to comment.