summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-01-07 11:33:36 +0000
committerGitHub <noreply@github.com>2021-01-07 11:33:36 +0000
commiteee3c3c52f59661a95f2f626edc97fac295817d6 (patch)
tree4814b72d6d575c073380f8f0748da6c81f7d33bc /synapse/storage
parentEmpty iterables should count towards cache usage. (#9028) (diff)
downloadsynapse-eee3c3c52f59661a95f2f626edc97fac295817d6.tar.xz
Handle updating schema version without any deltas. (#9033)
This can happen when using a split out state database and we've upgraded
the schema version without there being any changes in the state schema.
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/prepare_database.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/synapse/storage/prepare_database.py b/synapse/storage/prepare_database.py

index f91a2eae7a..6684403a0a 100644 --- a/synapse/storage/prepare_database.py +++ b/synapse/storage/prepare_database.py
@@ -375,7 +375,16 @@ def _upgrade_existing_database( specific_engine_extensions = (".sqlite", ".postgres") for v in range(start_ver, SCHEMA_VERSION + 1): - logger.info("Applying schema deltas for v%d", v) + if not is_worker: + logger.info("Applying schema deltas for v%d", v) + + cur.execute("DELETE FROM schema_version") + cur.execute( + "INSERT INTO schema_version (version, upgraded) VALUES (?,?)", + (v, True), + ) + else: + logger.info("Checking schema deltas for v%d", v) # We need to search both the global and per data store schema # directories for schema updates. @@ -489,12 +498,6 @@ def _upgrade_existing_database( (v, relative_path), ) - cur.execute("DELETE FROM schema_version") - cur.execute( - "INSERT INTO schema_version (version, upgraded) VALUES (?,?)", - (v, True), - ) - logger.info("Schema now up to date")