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

synapse_port_db generates an unusable database #9979

Closed
richvdh opened this issue May 13, 2021 · 3 comments · Fixed by #9991
Closed

synapse_port_db generates an unusable database #9979

richvdh opened this issue May 13, 2021 · 3 comments · Fixed by #9991
Assignees
Labels
S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@richvdh
Copy link
Member

richvdh commented May 13, 2021

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)

@richvdh richvdh added S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels May 13, 2021
@richvdh richvdh self-assigned this May 13, 2021
@richvdh
Copy link
Member Author

richvdh commented May 13, 2021

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

@vulet
Copy link

vulet commented May 20, 2021

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.

@vulet
Copy link

vulet commented May 20, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants