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

Commit

Permalink
Exclude outliers in on_backfill_request
Browse files Browse the repository at this point in the history
When we are processing a `/backfill` request from a remote server, exclude any
outliers from consideration early on. We can't return outliers anyway (since we
don't know the state at the outlier), and filtering them out earlier means that
we won't attempt to calulate the state for them.
  • Loading branch information
richvdh committed Mar 28, 2022
1 parent 8b7b371 commit 3940871
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/12314.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid trying to calculate the state at outlier events.
12 changes: 9 additions & 3 deletions synapse/storage/databases/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,15 @@ def _get_connected_prev_event_backfill_results_txn(
/* Get the depth and stream_ordering of the prev_event_id from the events table */
INNER JOIN events
ON prev_event_id = events.event_id
/* exclude outliers from the results (we don't have the state, so cannot
* verify if the requesting server can see them).
*/
WHERE NOT events.outlier
/* Look for an edge which matches the given event_id */
WHERE event_edges.event_id = ?
AND event_edges.is_state = ?
AND event_edges.event_id = ? AND NOT event_edges.is_state
/* Because we can have many events at the same depth,
* we want to also tie-break and sort on stream_ordering */
ORDER BY depth DESC, stream_ordering DESC
Expand All @@ -1084,7 +1090,7 @@ def _get_connected_prev_event_backfill_results_txn(

txn.execute(
connected_prev_event_query,
(event_id, False, limit),
(event_id, limit),
)
return [
BackfillQueueNavigationItem(
Expand Down

0 comments on commit 3940871

Please sign in to comment.