element-hq / element-hq/synapse
relation "background_updates" already exists when trying to run a hot-spare synapse
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#15484](https://github.com/matrix-org/synapse/issues/15484).
---
Child issue of https://github.com/matrix-org/synapse/issues/15478
When investigating if synapse could support running a hot spare node, we ran into the following error:
```
INFO [2023-03-20T10:25:05.183573Z] synapse.storage.prepare_database: %r: Checking existing schema version (lineno: 116, process: 133) (args: [[main state]], trace: main, unsafeMessage: [main, state]: Checking existing schema version)
{"type":"service.1","time":"2023-03-20T10:25:06.353991000Z","level":"ERROR","origin":"synapse.app._base","message":"Exception during startup","params":{"lineno":"194","process":"133"},"unsafeParams":{"unsafeMessage":"Exception during startup","stacktrace":"Traceback (most recent call last):
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/app/homeserver.py\", line 386, in setup
hs.setup()
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/server.py\", line 320, in setup
self.datastores = Databases(self.DATASTORE_CLASS, self)
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/storage/databases/**init**.py\", line 74, in **init**
prepare_database(
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/storage/prepare_database.py\", line 117, in prepare_database
version_info = _get_or_create_schema_state(cur, database_engine)
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/storage/prepare_database.py\", line 670, in _get_or_create_schema_state
executescript(txn, sql_path)
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/storage/prepare_database.py\", line 657, in executescript
execute_statements_from_stream(txn, f)
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/storage/prepare_database.py\", line 662, in execute_statements_from_stream
cur.execute(statement)
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/storage/database.py\", line 317, in execute
self._do_execute(self.txn.execute, sql, *args)
File \"/opt/synapse/service/synapse/lib/python3.9/site-packages/synapse/storage/database.py\", line 350, in _do_execute
return func(sql,* args)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint \"pg_type_typname_nsp_index\"
DETAIL: Key (typname, typnamespace)=(schema_version, 2200) already exists.
","trace":"main"},"safe":true,"thread":"MainThread"}
** ** *****Error***** *during initialisation******:***
** *duplicate key value violates unique constraint* *****"pg_type_typname_nsp_index"***
** *DETAIL******:***** ** *****Key***** ** *****(******typname******,***** *typnamespace******)=(******schema_version******,***** ** *****2200******)***** *already exists******.***
** ** **
** ** *****There***** *may be more information* *****in***** *the logs******.*****
synapse.app.homeserver(/opt/synapse/var/conf/homeserver.yaml) failed to start (exit code: 1). Check the Synapse logfile, or run synctl with —no-daemonize.
Fail
cat: /opt/synapse/var/run/synapse.pid: No such file or directory
```
Contributor guide
Assessment
This issue has not been assessed yet.