summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-01-07 11:40:40 +0000
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-01-07 11:40:40 +0000
commitf69d2fcac1acd813b7b46c8dd9df92bea598bb9a (patch)
treef2bfe28fb9d5cd25ce8232d29f1893c2e58a909f
parentUse `setattr` because direct assignment fails (diff)
downloadsynapse-f69d2fcac1acd813b7b46c8dd9df92bea598bb9a.tar.xz
Use a nasty wrapper class
-rw-r--r--synapse/storage/database.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py
index 1c1d76520f..f713efbf90 100644
--- a/synapse/storage/database.py
+++ b/synapse/storage/database.py
@@ -107,10 +107,18 @@ def make_pool(
         with LoggingContext("db.on_new_connection"):
             # HACK Patch the connection's commit function so that we can see
             #      how long it's taking from Jaeger.
-            setattr(conn, "commit", trace(conn.commit, "db.conn.commit"))
+            class NastyConnectionWrapper:
+                def __init__(self, connection):
+                    self._connection = connection
+                    self.commit = trace(conn.commit, "db.conn.commit")
+
+                def __getattr__(self, item):
+                    return self._connection.__getattr__(item)
 
             engine.on_new_connection(
-                LoggingDatabaseConnection(conn, engine, "on_new_connection")
+                LoggingDatabaseConnection(
+                    NastyConnectionWrapper(conn), engine, "on_new_connection"
+                )
             )
 
     connection_pool = adbapi.ConnectionPool(