summary refs log tree commit diff
path: root/synapse/storage/util
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-29 19:17:00 +0100
committerErik Johnston <erik@matrix.org>2015-04-29 19:17:00 +0100
commit50f96f256f01dcdb549017f68eccb2ae8a285134 (patch)
treeb0f1ab75686581fd3a4d8d8d072b7fd65fa3f0c6 /synapse/storage/util
parentFix deadlock in id_generators. No idea why this was an actual deadlock. (diff)
downloadsynapse-50f96f256f01dcdb549017f68eccb2ae8a285134.tar.xz
Also remove yield from within lock in the other generator
Diffstat (limited to 'synapse/storage/util')
-rw-r--r--synapse/storage/util/id_generators.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py
index 54aeff2b43..a51268511c 100644
--- a/synapse/storage/util/id_generators.py
+++ b/synapse/storage/util/id_generators.py
@@ -30,15 +30,13 @@ class IdGenerator(object):
 
     @defer.inlineCallbacks
     def get_next(self):
-        with self._lock:
-            if not self._next_id:
-                res = yield self.store._execute_and_decode(
-                    "IdGenerator_%s" % (self.table,),
-                    "SELECT MAX(%s) as mx FROM %s" % (self.column, self.table,)
-                )
-
-                self._next_id = (res and res[0] and res[0]["mx"]) or 1
+        if self._next_id is None:
+            yield self.store.runInteraction(
+                "IdGenerator_%s" % (self.table,),
+                self.get_next_txn,
+            )
 
+        with self._lock:
             i = self._next_id
             self._next_id += 1
             defer.returnValue(i)