synapse/tests/rest/client
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
test_account.py Use Pydantic to systematically validate a first batch of endpoints in synapse.rest.client.account. (#13188) 2022-08-15 19:05:57 +00:00
test_account_data.py
test_auth.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
test_capabilities.py
test_consent.py
test_devices.py
test_directory.py
test_ephemeral_message.py
test_events.py
test_filter.py Use literals in place of HTTPStatus constants in tests (#13463) 2022-08-05 16:59:09 +02:00
test_identity.py Drop support for calling /_matrix/client/v3/rooms/{roomId}/invite without an id_access_token (#13241) 2022-08-31 12:10:25 +00:00
test_keys.py Cancel the processing of key query requests when they time out. (#13680) 2022-09-07 12:03:32 +01:00
test_login.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
test_login_token_request.py Expose MSC3882 only be under an unstable endpoint. (#13868) 2022-09-29 07:22:27 -04:00
test_models.py A third batch of Pydantic validation for rest/client/account.py (#13736) 2022-09-15 18:36:02 +01:00
test_mutual_rooms.py
test_notifications.py
test_password_policy.py
test_power_levels.py
test_presence.py
test_profile.py
test_push_rule_attrs.py
test_redactions.py Use literals in place of HTTPStatus constants in tests (#13463) 2022-08-05 16:59:09 +02:00
test_register.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
test_relations.py Support filtering the /messages API by relation type (MSC3874). (#14148) 2022-10-17 11:32:11 -04:00
test_rendezvous.py Implementation of HTTP 307 response for MSC3886 POST endpoint (#14018) 2022-10-18 15:52:25 +00:00
test_report_event.py Use literals in place of HTTPStatus constants in tests (#13463) 2022-08-05 16:59:09 +02:00
test_retention.py synapse.api.auth.Auth cleanup: make permission-related methods use Requester instead of the UserID (#13024) 2022-08-22 14:17:59 +01:00
test_room_batch.py
test_rooms.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
test_sendtodevice.py
test_shadow_banned.py Drop support for calling /_matrix/client/v3/rooms/{roomId}/invite without an id_access_token (#13241) 2022-08-31 12:10:25 +00:00
test_sync.py Remove support for unstable private read receipts (#13653) 2022-09-01 13:31:54 +01:00
test_third_party_rules.py Use literals in place of HTTPStatus constants in tests (#13463) 2022-08-05 16:59:09 +02:00
test_transactions.py
test_typing.py Do not allow a None-limit on PaginationConfig. (#14146) 2022-10-14 12:30:05 +00:00
test_upgrade_room.py
utils.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