summary refs log tree commit diff
path: root/synapse/storage/transactions.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-27 13:22:30 +0100
committerErik Johnston <erik@matrix.org>2015-04-27 13:22:30 +0100
commit2732be83d9e883184f4a783fb7ba15487f30c20d (patch)
tree55ca53c5d3f1c0641d65cbe040ebe32d5ee4992c /synapse/storage/transactions.py
parentHandle the fact that postgres databases can be restarted from under us (diff)
downloadsynapse-2732be83d9e883184f4a783fb7ba15487f30c20d.tar.xz
Shuffle operations so that locking upsert happens last in the txn. This ensures the lock is held for the least amount of time possible.
Diffstat (limited to 'synapse/storage/transactions.py')
-rw-r--r--synapse/storage/transactions.py21
1 files changed, 6 insertions, 15 deletions
diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py

index 7e3add5280..89dd7d8947 100644 --- a/synapse/storage/transactions.py +++ b/synapse/storage/transactions.py
@@ -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,