From 23f05c8b466a4bc8e58ca732bc7b71b0c3c83ab1 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 6 Nov 2020 12:35:10 +0000 Subject: [PATCH 1/2] Enable reconnection in DB pool --- synapse/storage/database.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/synapse/storage/database.py b/synapse/storage/database.py index a0572b295239..d1b5760c2c09 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -88,13 +88,18 @@ def make_pool( """Get the connection pool for the database. """ + # By default enable `cp_reconnect`. We need to fiddle with db_args in case + # someone has explicitly set `cp_reconnect`. + db_args = dict(db_config.config.get("args", {})) + db_args.setdefault("cp_reconnect", True) + return adbapi.ConnectionPool( db_config.config["name"], cp_reactor=reactor, cp_openfun=lambda conn: engine.on_new_connection( LoggingDatabaseConnection(conn, engine, "on_new_connection") ), - **db_config.config.get("args", {}), + **db_args, ) From 45ebae8e5df45ff453c10145ea0276419c509454 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 6 Nov 2020 12:40:02 +0000 Subject: [PATCH 2/2] Newsfile --- changelog.d/8726.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8726.bugfix diff --git a/changelog.d/8726.bugfix b/changelog.d/8726.bugfix new file mode 100644 index 000000000000..831f773a25e4 --- /dev/null +++ b/changelog.d/8726.bugfix @@ -0,0 +1 @@ +Fix bug where Synapse would not recover after losing connection to the database.