Move the event storage into a single transaction

This commit is contained in:
Mark Haines 2014-08-26 14:31:48 +01:00
parent 1379dcae6f
commit 4b2ad549d5
6 changed files with 60 additions and 48 deletions

View file

@ -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,)