MatrixSynapse/tests
Eric Eastwood daf498e099
Fix 500 error on `/messages` when we accumulate more than 5 backward extremities (#11027)
Found while working on the Gitter backfill script and noticed
it only happened after we sent 7 batches, https://gitlab.com/gitterHQ/webapp/-/merge_requests/2229#note_665906390

When there are more than 5 backward extremities for a given depth,
backfill will throw an error because we sliced the extremity list
to 5 but then try to iterate over the full list. This causes
us to look for state that we never fetched and we get a `KeyError`.

Before when calling `/messages` when there are more than 5 backward extremities:
```
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 258, in _async_render_wrapper
    callback_return = await self._async_render(request)
  File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 446, in _async_render
    callback_return = await raw_callback_return
  File "/usr/local/lib/python3.8/site-packages/synapse/rest/client/room.py", line 580, in on_GET
    msgs = await self.pagination_handler.get_messages(
  File "/usr/local/lib/python3.8/site-packages/synapse/handlers/pagination.py", line 396, in get_messages
    await self.hs.get_federation_handler().maybe_backfill(
  File "/usr/local/lib/python3.8/site-packages/synapse/handlers/federation.py", line 133, in maybe_backfill
    return await self._maybe_backfill_inner(room_id, current_depth, limit)
  File "/usr/local/lib/python3.8/site-packages/synapse/handlers/federation.py", line 386, in _maybe_backfill_inner
    likely_extremeties_domains = get_domains_from_state(states[e_id])
KeyError: '$zpFflMEBtZdgcMQWTakaVItTLMjLFdKcRWUPHbbSZJl'
```
2021-10-14 18:53:45 -05:00
..
api
app
appservice
config Reset global cache state before cache tests. (#11036) 2021-10-12 12:55:33 +00:00
crypto
events
federation
handlers Fix 500 error on `/messages` when we accumulate more than 5 backward extremities (#11027) 2021-10-14 18:53:45 -05:00
http
logging Include exception in json logging (#11028) 2021-10-08 13:08:25 +02:00
module_api
push
replication
rest Fix-up some type hints in the relations tests. (#11076) 2021-10-14 09:19:35 -04:00
scripts
server_notices
state
storage Stop user directory from failing if it encounters users not in the `users` table. (#11053) 2021-10-13 09:38:22 +00:00
test_utils
util
__init__.py
server.py Fix-up some type hints in the relations tests. (#11076) 2021-10-14 09:19:35 -04:00
test_distributor.py
test_event_auth.py
test_federation.py
test_mau.py Add functionality to remove deactivated users from the monthly_active_users table (#10947) 2021-10-04 08:34:42 -07:00
test_metrics.py
test_phone_home.py
test_preview.py Ensure each charset is attempted only once during media preview. (#11089) 2021-10-14 18:51:44 +00:00
test_server.py
test_state.py
test_terms_auth.py
test_test_utils.py
test_types.py
test_visibility.py
unittest.py Fix-up some type hints in the relations tests. (#11076) 2021-10-14 09:19:35 -04:00
utils.py