Add more logging to debug slow startup (#8264)

I'm hoping this will provide some pointers for debugging
https://github.com/matrix-org/synapse/issues/7968.
This commit is contained in:
Richard van der Hoff 2020-09-07 13:36:02 +01:00 committed by GitHub
parent 96312536f2
commit 0dae7d80bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 7 deletions

View file

@ -82,10 +82,18 @@ def prepare_database(db_conn, database_engine, config, databases=["main", "state
try:
cur = db_conn.cursor()
logger.info("%r: Checking existing schema version", databases)
version_info = _get_or_create_schema_state(cur, database_engine)
if version_info:
user_version, delta_files, upgraded = version_info
logger.info(
"%r: Existing schema is %i (+%i deltas)",
databases,
user_version,
len(delta_files),
)
# config should only be None when we are preparing an in-memory SQLite db,
# which should be empty.
@ -111,6 +119,8 @@ def prepare_database(db_conn, database_engine, config, databases=["main", "state
databases=databases,
)
else:
logger.info("%r: Initialising new database", databases)
# if it's a worker app, refuse to upgrade the database, to avoid multiple
# workers doing it at once.
if config and config.worker_app is not None: