diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-03-03 19:39:19 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-03-03 19:39:25 +0100 |
commit | f951cdef8ced141326887c1a996e8546774514f6 (patch) | |
tree | 6de32e119c3b074e81229cb9c7f4c7252a61bb31 /src/exchangedb/plugin_exchangedb_postgres.c | |
parent | 4c53d42e44cbab55194b2f0fb71ffc3cb082b56a (diff) | |
download | exchange-f951cdef8ced141326887c1a996e8546774514f6.tar.xz |
include shard when marking deposits tiny/done to make better use of partitions/shards
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index c9512e64f..86480f29b 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1217,15 +1217,17 @@ prepare_statements (struct PostgresClosure *pg) "mark_deposit_tiny", "UPDATE deposits" " SET tiny=TRUE" - " WHERE deposit_serial_id=$1", - 1), + " WHERE shard=$2" + " AND deposit_serial_id=$1", + 2), /* Used in #postgres_mark_deposit_done() */ GNUNET_PQ_make_prepare ( "mark_deposit_done", "UPDATE deposits" " SET done=TRUE" - " WHERE deposit_serial_id=$1;", - 1), + " WHERE shard=$2" + " AND deposit_serial_id=$1;", + 2), /* Used in #postgres_get_coin_transactions() to obtain information about how a coin has been spend with /deposit requests. */ GNUNET_PQ_make_prepare ( @@ -5429,16 +5431,20 @@ postgres_have_deposit2 ( * @e iterate_ready_deposits() * * @param cls the @e cls of this struct with the plugin-specific state + * @param merchant_pub identifies the beneficiary of the deposit * @param rowid identifies the deposit row to modify * @return query result status */ static enum GNUNET_DB_QueryStatus postgres_mark_deposit_tiny (void *cls, + const struct TALER_MerchantPublicKeyP *merchant_pub, uint64_t rowid) { struct PostgresClosure *pg = cls; + uint64_t deposit_shard = compute_shard (merchant_pub); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&rowid), + GNUNET_PQ_query_param_uint64 (&deposit_shard), GNUNET_PQ_query_param_end }; @@ -5454,16 +5460,20 @@ postgres_mark_deposit_tiny (void *cls, * @e iterate_ready_deposits() or @e iterate_matching_deposits(). * * @param cls the @e cls of this struct with the plugin-specific state + * @param merchant_pub identifies the beneficiary of the deposit * @param rowid identifies the deposit row to modify * @return query result status */ static enum GNUNET_DB_QueryStatus postgres_mark_deposit_done (void *cls, + const struct TALER_MerchantPublicKeyP *merchant_pub, uint64_t rowid) { struct PostgresClosure *pg = cls; + uint64_t deposit_shard = compute_shard (merchant_pub); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&rowid), + GNUNET_PQ_query_param_uint64 (&deposit_shard), GNUNET_PQ_query_param_end }; @@ -8054,7 +8064,8 @@ postgres_start_deferred_wire_out (void *cls) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_ExecuteStatement es[] = { - GNUNET_PQ_make_execute ("START TRANSACTION ISOLATION LEVEL READ COMMITTED"), + GNUNET_PQ_make_execute ( + "START TRANSACTION ISOLATION LEVEL READ COMMITTED;"), GNUNET_PQ_make_execute ("SET CONSTRAINTS ALL DEFERRED;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; |