From 346d539960592098626cac00f9a506aef1e1e2c4 Mon Sep 17 00:00:00 2001 From: csrapr <26280794+csrapr@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:04:07 +0100 Subject: [PATCH] Fix: fix rare concurrency bug on cashOut --- lib/cash-out/cash-out-atomic.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cash-out/cash-out-atomic.js b/lib/cash-out/cash-out-atomic.js index b03d51f5..3066dca4 100644 --- a/lib/cash-out/cash-out-atomic.js +++ b/lib/cash-out/cash-out-atomic.js @@ -19,7 +19,8 @@ function atomic (tx, pi, fromClient) { const isolationLevel = pgp.txMode.isolationLevel const mode = new TransactionMode({ tiLevel: isolationLevel.serializable }) function transaction (t) { - const sql = 'select * from cash_out_txs where id=$1' + const sql = 'SELECT * FROM cash_out_txs WHERE id=$1 FOR UPDATE' + return t.oneOrNone(sql, [tx.id]) .then(toObj) .then(oldTx => {