matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Migrated from apt version to Matrix version on new server and now fails on DB upgrade #16225

Closed sbrooke closed 1 year ago

sbrooke commented 1 year ago

Did a pgdump on old server and a "cat > db" on new server. I've also tried DROPping the DB and cat'ing it back in again and it still gets stuck on upgrading. Getting the following error:

2023-09-02 14:51:54,761 - synapse.app.homeserver - 350 - INFO - main - Setting up server 2023-09-02 14:51:54,761 - synapse.server - 338 - INFO - main - Setting up. 2023-09-02 14:51:54,786 - synapse.storage.databases - 66 - INFO - main - [database config 'master']: Checking database server 2023-09-02 14:51:54,788 - synapse.storage.databases - 69 - INFO - main - [database config 'master']: Preparing for databases ['main', 'state'] 2023-09-02 14:51:54,789 - synapse.storage.prepare_database - 128 - INFO - main - ['main', 'state']: Checking existing schema version 2023-09-02 14:51:54,792 - synapse.storage.prepare_database - 132 - INFO - main - ['main', 'state']: Existing schema is 68 (+6 deltas) 2023-09-02 14:51:54,792 - synapse.storage.databases.main - 335 - INFO - main - Checking database for consistency with configuration... 2023-09-02 14:51:54,793 - synapse.storage.prepare_database - 426 - INFO - main - Applying schema deltas for v68 2023-09-02 14:51:54,795 - synapse.storage.prepare_database - 534 - INFO - main - Applying schema 68/06_msc3202_add_device_list_appservice_stream_type.sql 2023-09-02 14:51:54,797 - synapse.storage.prepare_database - 426 - INFO - main - Applying schema deltas for v69 2023-09-02 14:51:54,799 - synapse.storage.prepare_database - 517 - INFO - main - Running 69/01as_txn_seq.py:run_create 2023-09-02 14:51:54,801 - synapse.app._base - 215 - ERROR - main - Exception during startup Traceback (most recent call last): File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/app/homeserver.py", line 353, in setup hs.setup() File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/server.py", line 340, in setup self.datastores = Databases(self.DATASTORE_CLASS, self) File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/storage/databases/init.py", line 74, in init prepare_database( File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 149, in prepare_database _upgrade_existing_database( File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 518, in _upgrade_existing_database module.run_create(cur, database_engine) File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/storage/schema/main/delta/69/01as_txn_seq.py", line 44, in run_create cur.execute( File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/storage/database.py", line 417, in execute self._do_execute(self.txn.execute, sql, parameters) File "/opt/venvs/matrix-synapse/lib/python3.10/site-packages/synapse/storage/database.py", line 469, in _do_execute return func(sql, *args, **kwargs) psycopg2.errors.DuplicateTable: relation "application_services_txn_id_seq" already exists

sbrooke commented 1 year ago

This was untenable and we decided to abandon the old server and start over from scratch. For what it's worth, the Ubuntu Repo version should be removed so others don't make this mistake.

DMRobertson commented 1 year ago

Related: https://bugs.launchpad.net/ubuntu/+source/matrix-synapse/+bug/1848709