summary refs log tree commit diff
path: root/synapse/storage/registration.py
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2018-10-23 15:24:58 +0100
committerNeil Johnson <neil@matrix.org>2018-10-23 15:24:58 +0100
commit6105c6101fa0f4560daf7d23dedcfd217530b02a (patch)
treec4b2318ccdbb3993391ceb580b84f9ed8635441d /synapse/storage/registration.py
parentMerge pull request #4076 from matrix-org/rav/fix_init_logcontexts (diff)
downloadsynapse-6105c6101fa0f4560daf7d23dedcfd217530b02a.tar.xz
fix race condiftion in calling initialise_reserved_users
Diffstat (limited to 'synapse/storage/registration.py')
-rw-r--r--synapse/storage/registration.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 26b429e307..01931f29cc 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -474,17 +474,25 @@ class RegistrationStore(RegistrationWorkerStore,
 
     @defer.inlineCallbacks
     def get_user_id_by_threepid(self, medium, address):
-        ret = yield self._simple_select_one(
+        user_id = yield self.runInteraction(
+            "get_user_id_by_threepid", self.get_user_id_by_threepid_txn,
+            medium, address
+        )
+        defer.returnValue(user_id)
+
+    def get_user_id_by_threepid_txn(self, txn, medium, address):
+        ret = self._simple_select_one_txn(
+            txn,
             "user_threepids",
             {
                 "medium": medium,
                 "address": address
             },
-            ['user_id'], True, 'get_user_id_by_threepid'
+            ['user_id'], True
         )
         if ret:
-            defer.returnValue(ret['user_id'])
-        defer.returnValue(None)
+            return ret['user_id']
+        return None
 
     def user_delete_threepid(self, user_id, medium, address):
         return self._simple_delete(