add a few more FOR UPDATE where appropriate

This commit is contained in:
Christian Grothoff 2018-08-10 19:12:57 +02:00
parent 9887077ea2
commit e0935af764
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 19 additions and 11 deletions

View File

@ -1,5 +1,5 @@
{
"url": "payto://x-taler-bank/localhost:8082/2",
"salt": "KY6F590HGDDJ2W8X1PFFKQDV5WNR6EFTBY2Q7MXCG4FQFZ53RKS2DA0DMQAK20V9B6P4JHB55E41XT905YEQHB0S9PA2YCDS2VSV6QR",
"master_sig": "W2GC7FF6NG8D6NGT1XKYF2GDDA2W2Q4GH1AZ47KD3MY4CNS29QF4VH1DWE11NW33ZPTCV4XMMGNSE1KKFF7DMK81R8A2VBBF8FMFY0R"
"salt": "1D8FXNTNHJZH0FQ60CT136GTHCMBM3WBDMGWNBFXMQ2R7XSCY69Y5MG1745WBJZAWWPNRCXD7KV8CCRWYZ10Y6D1694RVSGBFZFND2R",
"master_sig": "CRYKJBSH7QJ9Q32SPSR2PQNMFNSV76Q6JN4GHNQXYZ14CC4SFWYM9XWK678XZ05T6QYV0PD76Q4S1E5V7SJ7A49GQW6CZJS8YWH6W28"
}

View File

@ -22,6 +22,7 @@
* @brief HTTP serving layer intended to perform crypto-work and
* communication with the exchange
* @author Marcello Stanisci
* @author Christian Grothoff
*/
#include "platform.h"

View File

@ -30,7 +30,7 @@
* How often should we retry a transaction before giving up
* (for transactions resulting in serialization/dead locks only).
*/
#define MAX_TRANSACTION_COMMIT_RETRIES 3
#define MAX_TRANSACTION_COMMIT_RETRIES 2
/**
@ -108,7 +108,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
if (0 <= qs)
return GNUNET_OK;
}
TALER_LOG_WARNING ("Transaction commit failed %u times\n",
TALER_LOG_ERROR ("Transaction `%s' commit failed %u times\n",
name,
MAX_TRANSACTION_COMMIT_RETRIES);
if (NULL != mhd_ret)
*mhd_ret = TEH_RESPONSE_reply_commit_error (connection,

View File

@ -573,7 +573,8 @@ postgres_prepare (PGconn *db_conn)
",expiration_date"
" FROM reserves"
" WHERE reserve_pub=$1"
" LIMIT 1;",
" LIMIT 1"
" FOR UPDATE;",
1),
/* Used in #postgres_reserves_in_insert() when the reserve is new */
GNUNET_PQ_make_prepare ("reserve_create",
@ -782,7 +783,8 @@ postgres_prepare (PGconn *db_conn)
" FROM known_coins"
" JOIN denominations denom"
" USING (denom_pub_hash)"
" WHERE coin_pub=$1;",
" WHERE coin_pub=$1"
" FOR UPDATE;",
1),
/* Used in #postgres_insert_known_coin() to store
the denomination public key and signature for
@ -895,7 +897,8 @@ postgres_prepare (PGconn *db_conn)
" JOIN denominations denom "
" USING (denom_pub_hash)"
" WHERE rc=$1"
" ORDER BY newcoin_index ASC;",
" ORDER BY newcoin_index ASC"
" FOR UPDATE;",
1),
/* Used in #postgres_insert_refresh_reveal() to store the transfer
@ -1008,7 +1011,8 @@ postgres_prepare (PGconn *db_conn)
" (coin_pub=$1)"
" AND (h_contract_terms=$2)"
" AND (merchant_pub=$3)"
" );",
" )"
" FOR UPDATE;",
3),
/* Fetch deposits with rowid '\geq' the given parameter */
GNUNET_PQ_make_prepare ("audit_get_deposits_incr",
@ -1150,7 +1154,8 @@ postgres_prepare (PGconn *db_conn)
" USING (coin_pub)"
" JOIN denominations denom"
" USING (denom_pub_hash)"
" WHERE coin_pub=$1;",
" WHERE coin_pub=$1"
" FOR UPDATE;",
1),
/* Used in #postgres_get_link_data(). */
@ -1564,7 +1569,8 @@ postgres_prepare (PGconn *db_conn)
" reserve_pub"
" FROM reserves_out"
" WHERE h_blind_ev=$1"
" LIMIT 1;",
" LIMIT 1"
" FOR UPDATE;",
1),
/* used in #postgres_commit */
GNUNET_PQ_make_prepare ("do_commit",