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

synapse_port_db generates an unusable database #9979

Closed

Description

@richvdh

After running synapse_port_db following the instructions, attempting to start synapse pointing to the generated database results in an error along the lines of:

2021-05-13 17:48:23,671 - synapse.storage.util.sequence - 173 - WARNING - main - Postgres sequence event_auth_chain_id is behind table event_auth_chains: 224 < 225
2021-05-13 17:48:23,671 - twisted - 258 - ERROR - main - *******************************************************************************
2021-05-13 17:48:23,671 - twisted - 258 - ERROR - main -  
2021-05-13 17:48:23,671 - twisted - 258 - ERROR - main -  Postgres sequence 'event_auth_chain_id' is inconsistent with associated
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -  table 'event_auth_chains'. This can happen if Synapse has been downgraded and
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -  then upgraded again, or due to a bad migration.
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -  
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -  To fix this error, shut down Synapse (including any and all workers)
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -  and run the following SQL:
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -  
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -      SELECT setval('event_auth_chain_id', (
2021-05-13 17:48:23,672 - twisted - 258 - ERROR - main -          SELECT GREATEST(MAX(chain_id), 0) FROM event_auth_chains
2021-05-13 17:48:23,673 - twisted - 258 - ERROR - main -      ));
2021-05-13 17:48:23,673 - twisted - 258 - ERROR - main -  
2021-05-13 17:48:23,673 - twisted - 258 - ERROR - main -  See docs/postgres.md for more information.
2021-05-13 17:48:23,673 - twisted - 258 - ERROR - main -  
2021-05-13 17:48:23,673 - twisted - 258 - ERROR - main - *******************************************************************************

(attempting to re-run synapse_port_db produces a similar error)

Activity

  1. added
    S-MajorMajor functionality / product severely impaired, no satisfactory workaround.
    T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.
    on May 13, 2021
  2. self-assigned this
    on May 13, 2021
  3. richvdh commented on May 13, 2021

    @richvdh
    MemberAuthor

    It looks like this is still #9382. #9449 attempted to fix it, but got an off-by-one-error.

  4. vulet commented on May 20, 2021

    @vulet

    I just ran into this issue. curr_chain_id + 1 in #9991 resolved it, in addition to running:

            SELECT setval('event_auth_chain_id', (
            SELECT GREATEST(MAX(chain_id), 0) FROM event_auth_chains
        ));

    Thanks.

  5. vulet commented on May 20, 2021

    @vulet

    It actually seems like a lot of my messages are delayed now. I didn't restart the whole migration process with the change, instead re-ran the script. I suppose I might just restart the whole process.

    edit: Everything worked this time around. I guess the database was corrupted, or the SQL statement borked things.

  6. added a commit that references this issue on May 24, 2021
    daca7b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

S-MajorMajor functionality / product severely impaired, no satisfactory workaround.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions