Shuffle operations so that locking upsert happens last in the txn. This ensures the lock is held for the least amount of time possible.

This commit is contained in:
Erik Johnston 2015-04-27 13:22:30 +01:00
parent e4c4664d73
commit 2732be83d9
5 changed files with 59 additions and 59 deletions

View file

@ -76,25 +76,16 @@ class TransactionStore(SQLBaseStore):
response_json (str)
"""
return self.runInteraction(
"set_received_txn_response",
self._set_received_txn_response,
transaction_id, origin, code, response_dict
)
def _set_received_txn_response(self, txn, transaction_id, origin, code,
response_json):
self._simple_upsert_txn(
txn,
return self._simple_insert(
table=ReceivedTransactionsTable.table_name,
keyvalues={
values={
"transaction_id": transaction_id,
"origin": origin,
},
values={
"response_code": code,
"response_json": response_json,
}
"response_json": response_dict,
},
or_ignore=True,
desc="set_received_txn_response",
)
def prep_send_transaction(self, transaction_id, destination,