summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-05-21 13:38:51 +0100
committerBrendan Abolivier <babolivier@matrix.org>2019-05-21 13:38:51 +0100
commit5ceee46c6bd55376ff2188b6e674035d7da95f24 (patch)
treeafe26bf00507705d11eb3fa38e5d7d8de8360c0a
parentChangelog (diff)
downloadsynapse-5ceee46c6bd55376ff2188b6e674035d7da95f24.tar.xz
Do the select and insert in a single transaction
-rw-r--r--synapse/storage/_base.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 06d516c9e2..fa6839ceca 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -304,21 +304,17 @@ class SQLBaseStore(object):
                 " WHERE account_validity.user_id is NULL;"
             )
             txn.execute(sql, [])
-            return self.cursor_to_dict(txn)
 
-        res = yield self.runInteraction(
+            res = self.cursor_to_dict(txn)
+            if res:
+                for user in res:
+                    self.set_expiration_date_for_user_txn(txn, user["name"])
+
+        yield self.runInteraction(
             "get_users_with_no_expiration_date",
             select_users_with_no_expiration_date_txn,
         )
 
-        if res:
-            for user in res:
-                self.runInteraction(
-                    "set_expiration_date_for_user_background",
-                    self.set_expiration_date_for_user_txn,
-                    user["name"],
-                )
-
     def set_expiration_date_for_user_txn(self, txn, user_id):
         """Sets an expiration date to the account with the given user ID.