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

Commit

Permalink
Improve diagnostics on database upgrade failure (#6570)
Browse files Browse the repository at this point in the history
`Failed to upgrade database` is not helpful, and it's unlikely that UPGRADE.rst
has anything useful.
  • Loading branch information
richvdh authored Dec 19, 2019
1 parent 0b794cb commit bca30ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/6570.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve diagnostics on database upgrade failure.
9 changes: 2 additions & 7 deletions synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,8 @@ def setup(config_options):
hs.setup()
except IncorrectDatabaseSetup as e:
quit_with_error(str(e))
except UpgradeDatabaseException:
sys.stderr.write(
"\nFailed to upgrade database.\n"
"Have you checked for version specific instructions in"
" UPGRADES.rst?\n"
)
sys.exit(1)
except UpgradeDatabaseException as e:
quit_with_error("Failed to upgrade database: %s" % (e,))

hs.setup_master()

Expand Down
5 changes: 4 additions & 1 deletion synapse/storage/prepare_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def prepare_database(db_conn, database_engine, config, data_stores=["main"]):
if user_version != SCHEMA_VERSION:
# If we don't pass in a config file then we are expecting to
# have already upgraded the DB.
raise UpgradeDatabaseException("Database needs to be upgraded")
raise UpgradeDatabaseException(
"Expected database schema version %i but got %i"
% (SCHEMA_VERSION, user_version)
)
else:
_upgrade_existing_database(
cur,
Expand Down

0 comments on commit bca30ce

Please sign in to comment.