Skip to content
Snippets Groups Projects
Commit 8558e1ec authored by Erik Johnston's avatar Erik Johnston
Browse files

Make get_max_token into inlineCallbacks so that the lock works.

parent 56f518d2
No related branches found
No related tags found
No related merge requests found
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment