forked-synapse/synapse/handlers
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
..
ui_auth Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
__init__.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
account_data.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
account_validity.py Require direct references to configuration variables. (#10985) 2021-10-06 10:47:41 -04:00
admin.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
appservice.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
auth.py Port the Password Auth Providers module interface to the new generic interface (#10548) 2021-10-13 11:21:52 +00:00
cas.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
deactivate_account.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
device.py Add type hints to synapse.storage.databases.main.client_ips (#10972) 2021-10-12 13:50:34 +01:00
devicemessage.py Use direct references for some configuration variables (#10798) 2021-09-13 13:07:12 -04:00
directory.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
e2e_keys.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
e2e_room_keys.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
event_auth.py Split event_auth.check into two parts (#10940) 2021-09-29 18:59:15 +01:00
events.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
federation_event.py Fix 500 error on /messages when we accumulate more than 5 backward extremities (#11027) 2021-10-14 18:53:45 -05:00
federation.py Fix 500 error on /messages when we accumulate more than 5 backward extremities (#11027) 2021-10-14 18:53:45 -05:00
groups_local.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
identity.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
initial_sync.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
message.py Resolve and share state_groups for all historical events in batch (MSC2716) (#10975) 2021-10-13 17:44:00 -05:00
oidc.py Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
pagination.py Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
password_policy.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
presence.py Fix issue causing sending presence to ASes to fail (due to incomplete type annotations) (#10944) 2021-09-30 11:06:47 +01:00
profile.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
read_marker.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
receipts.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
register.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
room_batch.py Resolve and share state_groups for all historical events in batch (MSC2716) (#10975) 2021-10-13 17:44:00 -05:00
room_list.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
room_member_worker.py Implement knock feature (#6739) 2021-06-09 19:39:51 +01:00
room_member.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
room_summary.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
room.py Add type hints to synapse.events.*. (#11066) 2021-10-13 07:24:07 -04:00
saml.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
search.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
send_email.py Pass str to twisted's IReactorTCP (#10895) 2021-09-30 12:51:47 +01:00
set_password.py Remove the deprecated BaseHandler. (#11005) 2021-10-08 07:44:43 -04:00
sso.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
state_deltas.py Easy refactors of the user directory (#10789) 2021-09-10 10:54:38 +01:00
stats.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
sync.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
typing.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
user_directory.py Rearrange the user_directory's _handle_deltas function (#11035) 2021-10-13 12:50:00 +00:00