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

Fix 500 error on /messages when we accumulate more than 5 backward extremities #11027

Commits on Oct 8, 2021

  1. Fix 500 error on /messages when we accumulate more than 5 backwards e…

    …xtremeties
    
    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 backwards 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.
    
    When calling `/messages`:
    ```
    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'
    ```
    MadLittleMods committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    4cb7d09 View commit details
    Browse the repository at this point in the history
  2. Remove debug logging

    MadLittleMods committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    94b9efb View commit details
    Browse the repository at this point in the history
  3. Add changelog

    MadLittleMods committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    7364b81 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0ceaf25 View commit details
    Browse the repository at this point in the history
  5. Add test

    MadLittleMods committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    694ca81 View commit details
    Browse the repository at this point in the history
  6. Fix lint

    MadLittleMods committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    4e75ea3 View commit details
    Browse the repository at this point in the history
  7. Fix lint from CI

    MadLittleMods committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    85748bd View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2021

  1. Configuration menu
    Copy the full SHA
    6a119a4 View commit details
    Browse the repository at this point in the history
  2. Revert code change and opt to change type hint

    See #11027 (comment)
    
    Dict[str, Any] will behave as an Iterable[str] when iterating on it
    MadLittleMods committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    391bc73 View commit details
    Browse the repository at this point in the history