summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-11-12 14:26:24 +0000
committerGitHub <noreply@github.com>2020-11-12 14:26:24 +0000
commitc2d4467cd435851484b29685959124c541d47842 (patch)
treee1f83d57879f903bad9c4432aba522d3528628f2 /synapse/storage
parentFix port script fails when DB has no backfilled events. (#8729) (diff)
downloadsynapse-c2d4467cd435851484b29685959124c541d47842.tar.xz
Enable reconnection in DB pool (#8726)
`adbapi.ConnectionPool` let's you turn on auto reconnect of DB connections. This is off by default.
As far as I can tell if its not enabled dead connections never get removed from the pool.

Maybe helps #8574
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/database.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py
index a0572b2952..d1b5760c2c 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,
     )