anonymousland-synapse/synapse/storage/databases/main
Eric Eastwood fa8616e65c
Fix MSC3030 /timestamp_to_event returning outliers that it has no idea whether are near a gap or not (#14215)
Fix MSC3030 `/timestamp_to_event` endpoint returning `outliers` that it has no idea whether are near a gap or not (and therefore unable to determine whether it's actually the closest event). The reason Synapse doesn't know whether an `outlier` is next to a gap is because our gap checks rely on entries in the `event_edges`, `event_forward_extremeties`, and `event_backward_extremities` tables which is [not the case for `outliers`](2c63cdcc3f/docs/development/room-dag-concepts.md (outliers)).

Also fixes MSC3030 Complement `can_paginate_after_getting_remote_event_from_timestamp_to_event_endpoint` test flake.  Although this acted flakey in Complement, if `sync_partial_state` raced and beat us before `/timestamp_to_event`, then even if we retried the failing `/context` request it wouldn't work until we made this Synapse change. With this PR, Synapse will never return an `outlier` event so that test will always go and ask over federation.

Fix  https://github.com/matrix-org/synapse/issues/13944


### Why did this fail before? Why was it flakey?

Sleuthing the server logs on the [CI failure](https://github.com/matrix-org/synapse/actions/runs/3149623842/jobs/5121449357#step:5:5805), it looks like `hs2:/timestamp_to_event` found `$NP6-oU7mIFVyhtKfGvfrEQX949hQX-T-gvuauG6eurU` as an `outlier` event locally. Then when we went and asked for it via `/context`, since it's an `outlier`, it was filtered out of the results -> `You don't have permission to access that event.`

This is reproducible when `sync_partial_state` races and persists `$NP6-oU7mIFVyhtKfGvfrEQX949hQX-T-gvuauG6eurU` as an `outlier` before we evaluate `get_event_for_timestamp(...)`. To consistently reproduce locally, just add a delay at the [start of `get_event_for_timestamp(...)`](cb20b885cb/synapse/handlers/room.py (L1470-L1496)) so it always runs after `sync_partial_state` completes.

```py
from twisted.internet import task as twisted_task
d = twisted_task.deferLater(self.hs.get_reactor(), 3.5)
await d
```

In a run where it passes, on `hs2`, `get_event_for_timestamp(...)` finds a different event locally which is next to a gap and we request from a closer one from `hs1` which gets backfilled. And since the backfilled event is not an `outlier`, it's returned as expected during `/context`.

With this PR, Synapse will never return an `outlier` event so that test will always go and ask over federation.
2022-10-18 19:46:25 -05:00
..
__init__.py Allow admins to require a manual approval process before new accounts can be used (using MSC3866) (#13556) 2022-09-29 15:23:24 +02:00
account_data.py Speed up fetching large numbers of push rules (#13592) 2022-08-23 13:15:43 +01:00
appservice.py
cache.py Invalidate rooms for user caches when receiving membership events (#14155) 2022-10-17 13:27:51 +01:00
censor_events.py
client_ips.py
deviceinbox.py
devices.py Fix hiding devices names over federation (#10015) 2022-10-18 20:54:27 +00:00
directory.py
e2e_room_keys.py
end_to_end_keys.py Refactor _get_e2e_device_keys_txn to split large queries (#13956) 2022-10-03 13:46:36 +01:00
event_federation.py Stop getting missing prev_events after we already know their signature is invalid (#13816) 2022-10-15 00:36:49 -05:00
event_push_actions.py Update the thread_id right before use (in case the bg update hasn't finished) (#14222) 2022-10-18 14:55:41 +00:00
events_bg_updates.py
events_forward_extremities.py
events_worker.py Fix MSC3030 /timestamp_to_event returning outliers that it has no idea whether are near a gap or not (#14215) 2022-10-18 19:46:25 -05:00
events.py Add an API for listing threads in a room. (#13394) 2022-10-13 08:02:11 -04:00
filtering.py
keys.py
lock.py Require SQLite >= 3.27.0 (#13760) 2022-09-09 11:14:10 +01:00
media_repository.py
metrics.py
monthly_active_users.py
openid.py
presence.py
profile.py
purge_events.py Add support to purge rows from MSC2716 and other tables when purging a room (#13825) 2022-09-16 10:56:56 -05:00
push_rule.py Remove the experimental implementation of MSC3772. (#14094) 2022-10-12 06:26:39 -04:00
pusher.py Track device IDs for pushers (#13831) 2022-09-21 15:31:53 +00:00
receipts.py Properly return the thread ID down sync. (#14159) 2022-10-13 12:15:41 -04:00
registration.py Allow admins to require a manual approval process before new accounts can be used (using MSC3866) (#13556) 2022-09-29 15:23:24 +02:00
rejections.py
relations.py Accept threaded receipts for events related to the root event. (#14174) 2022-10-14 18:05:25 +00:00
room_batch.py
room.py When restarting a partial join resync, prioritise the server which actioned a partial join (#14126) 2022-10-18 12:33:18 +01:00
roommember.py Batch up calls to get_rooms_for_users (#14109) 2022-10-12 11:36:22 +01:00
search.py Update mypy and mypy-zope, attempt 3 (#13993) 2022-09-30 17:36:28 +01:00
session.py
signatures.py
state_deltas.py
state.py Instrument get_metadata_for_events for tracing (#13730) 2022-09-07 11:41:52 -05:00
stats.py Require SQLite >= 3.27.0 (#13760) 2022-09-09 11:14:10 +01:00
stream.py Support filtering the /messages API by relation type (MSC3874). (#14148) 2022-10-17 11:32:11 -04:00
tags.py
transactions.py Require SQLite >= 3.27.0 (#13760) 2022-09-09 11:14:10 +01:00
ui_auth.py
user_directory.py
user_erasure_store.py