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

When loading current ids, sort by stream_id to avoid incorrect overwrite and avoid errors caused by sorting alphabetical instance name which can be null #13585

Merged
merged 4 commits into from
Aug 24, 2022

Commits on Aug 22, 2022

  1. Configuration menu
    Copy the full SHA
    d58a6fe View commit details
    Browse the repository at this point in the history

Commits on Aug 23, 2022

  1. Sort by stream_id to not overwrite our current position to something …

    …lower than we're actually at
    
    See #13585 (comment)
    
    When loading current ids, sort by stream ID so that we don't want to overwrite
    the `current_position` of an instance to a lower stream ID than we're actually at.
    Previously, it sorted alphabetically by instance name which can be `null` and
    throw errors but more importantly, accomplishes nothing.
    
    Fixes the following startup error which is why I started looking into this area:
    
    ```
    $ poetry run synapse_homeserver --config-path homeserver.yaml
    ****************************************************************
     Error during initialisation:
        '<' not supported between instances of 'NoneType' and 'str'
     There may be more information in the logs.
    ****************************************************************
    ```
    
    Somehow my database ended up looking like the following:
    ```
    $ psql synapse
    synapse=# SELECT * FROM stream_positions;
       stream_name   | instance_name | stream_id
    -----------------+---------------+-----------
     account_data    | master        |      1242
     events          | master        |      1787
     to_device       | master        |        58
     presence_stream | master        |    485638
     receipts        | master        |       341
     backfill        | master        |   -139106
    (6 rows)
    synapse=# SELECT instance_name, stream_id FROM receipts_linearized;
     instance_name | stream_id
    ---------------+-----------
                   |       211
                   |         3
                   |         4
                   |       212
                   |       213
                   |       224
                   |       228
                   |       164
                   |       313
                   |       253
                   |        38
                   |       321
                   |       324
                   |       189
                   |       192
                   |       193
                   |       194
                   |       195
                   |       197
                   |       198
                   |       275
                   |        79
                   |       339
                   |       340
                   |        82
                   |       341
                   |        84
                   |        85
                   |        91
                   |       119
    ```
    MadLittleMods committed Aug 23, 2022
    Configuration menu
    Copy the full SHA
    15d725a View commit details
    Browse the repository at this point in the history
  2. Add changelog

    MadLittleMods committed Aug 23, 2022
    Configuration menu
    Copy the full SHA
    1a8d48b View commit details
    Browse the repository at this point in the history

Commits on Aug 24, 2022

  1. Configuration menu
    Copy the full SHA
    6c714ed View commit details
    Browse the repository at this point in the history