summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 7b8215bf08..044e988e92 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -283,10 +283,14 @@ class DataStore(RoomMemberStore, RoomStore,
                 GROUP BY user_id
             ) u
         """
-        txn = self.db_conn.cursor()
-        txn.execute(sql, (thirty_days_ago,))
-        count, = txn.fetchone()
-        return count
+        try:
+            txn = self.db_conn.cursor()
+            txn.execute(sql, (thirty_days_ago,))
+            count, = txn.fetchone()
+            return count
+        finally:
+            txn.close()
+
 
 
     def count_r30_users(self):