summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-27 15:19:44 +0100
committerErik Johnston <erik@matrix.org>2015-04-27 15:19:44 +0100
commit8558e1ec7338a1f60342024736614dec71d104ce (patch)
tree9277675e34e4ae7fe680b4d662b244674862551b
parentAdd docs on how to use synapse with psycopg2 (diff)
downloadsynapse-8558e1ec7338a1f60342024736614dec71d104ce.tar.xz
Make get_max_token into inlineCallbacks so that the lock works.
-rw-r--r--synapse/storage/util/id_generators.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py
index e5dec1c948..9d461d5e96 100644
--- a/synapse/storage/util/id_generators.py
+++ b/synapse/storage/util/id_generators.py
@@ -105,21 +105,22 @@ class StreamIdGenerator(object):
 
         return manager()
 
+    @defer.inlineCallbacks
     def get_max_token(self, store):
         """Returns the maximum stream id such that all stream ids less than or
         equal to it have been successfully persisted.
         """
         with self._lock:
             if self._unfinished_ids:
-                return self._unfinished_ids[0] - 1
+                defer.returnValue(self._unfinished_ids[0] - 1)
 
             if not self._current_max:
-                return store.runInteraction(
+                yield store.runInteraction(
                     "_compute_current_max",
                     self._compute_current_max,
                 )
 
-            return self._current_max
+            defer.returnValue(self._current_max)
 
     def _compute_current_max(self, txn):
         txn.execute("SELECT MAX(stream_ordering) FROM events")