From e0935af764099a203a44b03a98ef0ec8ee17aeeb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 10 Aug 2018 19:12:57 +0200 Subject: add a few more FOR UPDATE where appropriate --- .../.config/taler/account-2.json | 4 ++-- src/benchmark/taler-exchange-benchmark.c | 1 + src/exchange/taler-exchange-httpd_db.c | 7 ++++--- src/exchangedb/plugin_exchangedb_postgres.c | 18 ++++++++++++------ 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json index 5e8dc44e9..35a5ec319 100644 --- a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json +++ b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json @@ -1,5 +1,5 @@ { "url": "payto://x-taler-bank/localhost:8082/2", - "salt": "KY6F590HGDDJ2W8X1PFFKQDV5WNR6EFTBY2Q7MXCG4FQFZ53RKS2DA0DMQAK20V9B6P4JHB55E41XT905YEQHB0S9PA2YCDS2VSV6QR", - "master_sig": "W2GC7FF6NG8D6NGT1XKYF2GDDA2W2Q4GH1AZ47KD3MY4CNS29QF4VH1DWE11NW33ZPTCV4XMMGNSE1KKFF7DMK81R8A2VBBF8FMFY0R" + "salt": "1D8FXNTNHJZH0FQ60CT136GTHCMBM3WBDMGWNBFXMQ2R7XSCY69Y5MG1745WBJZAWWPNRCXD7KV8CCRWYZ10Y6D1694RVSGBFZFND2R", + "master_sig": "CRYKJBSH7QJ9Q32SPSR2PQNMFNSV76Q6JN4GHNQXYZ14CC4SFWYM9XWK678XZ05T6QYV0PD76Q4S1E5V7SJ7A49GQW6CZJS8YWH6W28" } \ No newline at end of file diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 3440b3b4e..3a59bc6c9 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -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" diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 7817de990..1f7e0f257 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -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,8 +108,9 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, if (0 <= qs) return GNUNET_OK; } - TALER_LOG_WARNING ("Transaction commit failed %u times\n", - MAX_TRANSACTION_COMMIT_RETRIES); + 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, TALER_EC_DB_COMMIT_FAILED_ON_RETRY); diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index b9c577bcc..ac8d395c6 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -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", -- cgit v1.2.3