diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-08-26 14:31:48 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-08-26 14:36:03 +0100 |
commit | 4b2ad549d5a1dcf5c05f890c0383626d6c042fd0 (patch) | |
tree | 8aec582555ff9c4551cfd50c3808ab6f313ac4bf /synapse/storage/stream.py | |
parent | Take a snapshot of the state of the room before performing updates (diff) | |
download | synapse-4b2ad549d5a1dcf5c05f890c0383626d6c042fd0.tar.xz |
Move the event storage into a single transaction
Diffstat (limited to 'synapse/storage/stream.py')
-rw-r--r-- | synapse/storage/stream.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index e994017bf2..7460bf28d7 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -283,17 +283,20 @@ class StreamStore(SQLBaseStore): ) ) - @defer.inlineCallbacks def get_room_events_max_id(self): - res = yield self._execute_and_decode( + return self._db_pool.runInteraction(self._get_room_events_max_id_txn) + + def _get_room_events_max_id_txn(self, txn): + txn.execute( "SELECT MAX(stream_ordering) as m FROM events" ) + res = self.cursor_to_dict(txn) + logger.debug("get_room_events_max_id: %s", res) if not res or not res[0] or not res[0]["m"]: - defer.returnValue("s1") - return + return "s1" key = res[0]["m"] + 1 - defer.returnValue("s%d" % (key,)) + return "s%d" % (key,) |