mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 18:43:52 +01:00
Pull prev txn from in memory
This commit is contained in:
parent
1d275dba69
commit
d13459636f
1 changed files with 13 additions and 5 deletions
|
@ -58,6 +58,8 @@ class TransactionStore(SQLBaseStore):
|
||||||
# Newly delivered transactions that *were* persisted while in flight
|
# Newly delivered transactions that *were* persisted while in flight
|
||||||
self.update_delivered_transactions = {}
|
self.update_delivered_transactions = {}
|
||||||
|
|
||||||
|
self.last_transaction = {}
|
||||||
|
|
||||||
reactor.addSystemEventTrigger("before", "shutdown", self._persist_in_mem_txns)
|
reactor.addSystemEventTrigger("before", "shutdown", self._persist_in_mem_txns)
|
||||||
hs.get_clock().looping_call(
|
hs.get_clock().looping_call(
|
||||||
self._persist_in_mem_txns,
|
self._persist_in_mem_txns,
|
||||||
|
@ -159,6 +161,10 @@ class TransactionStore(SQLBaseStore):
|
||||||
|
|
||||||
self.inflight_transactions.setdefault(destination, {})[transaction_id] = txn_row
|
self.inflight_transactions.setdefault(destination, {})[transaction_id] = txn_row
|
||||||
|
|
||||||
|
prev_txn = self.last_transaction.get(destination)
|
||||||
|
if prev_txn:
|
||||||
|
return defer.succeed(prev_txn)
|
||||||
|
else:
|
||||||
return self.runInteraction(
|
return self.runInteraction(
|
||||||
"_get_prevs_txn",
|
"_get_prevs_txn",
|
||||||
self._get_prevs_txn,
|
self._get_prevs_txn,
|
||||||
|
@ -196,6 +202,8 @@ class TransactionStore(SQLBaseStore):
|
||||||
destination, {}
|
destination, {}
|
||||||
).pop(transaction_id, None)
|
).pop(transaction_id, None)
|
||||||
|
|
||||||
|
self.last_transaction[destination] = transaction_id
|
||||||
|
|
||||||
if txn_row:
|
if txn_row:
|
||||||
d = self.new_delivered_transactions.setdefault(destination, {})
|
d = self.new_delivered_transactions.setdefault(destination, {})
|
||||||
d[transaction_id] = txn_row._replace(
|
d[transaction_id] = txn_row._replace(
|
||||||
|
|
Loading…
Reference in a new issue