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

Commit 1474431

Browse files
committed
Disallow outliers from being used with the gap checks
See #14096 (comment)
1 parent 2c63cdc commit 1474431

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

synapse/storage/databases/main/events_worker.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,12 +1976,17 @@ async def is_event_next_to_backward_gap(self, event: EventBase) -> bool:
19761976
19771977
Args:
19781978
room_id: room where the event lives
1979-
event_id: event to check
1979+
event: event to check (can't be an `outlier`)
19801980
19811981
Returns:
19821982
Boolean indicating whether it's an extremity
19831983
"""
19841984

1985+
assert not event.internal_metadata.is_outlier(), (
1986+
"is_event_next_to_backward_gap(...) can't be used with `outlier` events. "
1987+
"This function relies on `event_backward_extremities` which won't be filled in for `outliers`."
1988+
)
1989+
19851990
def is_event_next_to_backward_gap_txn(txn: LoggingTransaction) -> bool:
19861991
# If the event in question has any of its prev_events listed as a
19871992
# backward extremity, it's next to a gap.
@@ -2031,12 +2036,17 @@ async def is_event_next_to_forward_gap(self, event: EventBase) -> bool:
20312036
20322037
Args:
20332038
room_id: room where the event lives
2034-
event_id: event to check
2039+
event: event to check (can't be an `outlier`)
20352040
20362041
Returns:
20372042
Boolean indicating whether it's an extremity
20382043
"""
20392044

2045+
assert not event.internal_metadata.is_outlier(), (
2046+
"is_event_next_to_forward_gap(...) can't be used with `outlier` events. "
2047+
"This function relies on `event_edges` and `event_forward_extremities` which won't be filled in for `outliers`."
2048+
)
2049+
20402050
def is_event_next_to_gap_txn(txn: LoggingTransaction) -> bool:
20412051
# If the event in question is a forward extremity, we will just
20422052
# consider any potential forward gap as not a gap since it's one of

0 commit comments

Comments
 (0)