include shard when marking deposits tiny/done to make better use of partitions/shards

This commit is contained in:
Christian Grothoff 2022-03-03 19:39:19 +01:00
parent 4c53d42e44
commit f951cdef8c
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 26 additions and 5 deletions

View File

@ -488,6 +488,7 @@ deposit_cb (void *cls,
"Aggregator marks deposit %llu as done\n", "Aggregator marks deposit %llu as done\n",
(unsigned long long) row_id); (unsigned long long) row_id);
qs = db_plugin->mark_deposit_done (db_plugin->cls, qs = db_plugin->mark_deposit_done (db_plugin->cls,
merchant_pub,
row_id); row_id);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{ {
@ -610,6 +611,7 @@ aggregate_cb (void *cls,
return qs; return qs;
} }
qs = db_plugin->mark_deposit_done (db_plugin->cls, qs = db_plugin->mark_deposit_done (db_plugin->cls,
&au->merchant_pub,
row_id); row_id);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{ {
@ -842,12 +844,14 @@ run_aggregation (void *cls)
} }
/* Mark transactions by row_id as minor */ /* Mark transactions by row_id as minor */
qs = db_plugin->mark_deposit_tiny (db_plugin->cls, qs = db_plugin->mark_deposit_tiny (db_plugin->cls,
&au_active.merchant_pub,
au_active.row_id); au_active.row_id);
if (0 <= qs) if (0 <= qs)
{ {
for (unsigned int i = 0; i<au_active.rows_offset; i++) for (unsigned int i = 0; i<au_active.rows_offset; i++)
{ {
qs = db_plugin->mark_deposit_tiny (db_plugin->cls, qs = db_plugin->mark_deposit_tiny (db_plugin->cls,
&au_active.merchant_pub,
au_active.additional_rows[i]); au_active.additional_rows[i]);
if (0 > qs) if (0 > qs)
break; break;

View File

@ -1217,15 +1217,17 @@ prepare_statements (struct PostgresClosure *pg)
"mark_deposit_tiny", "mark_deposit_tiny",
"UPDATE deposits" "UPDATE deposits"
" SET tiny=TRUE" " SET tiny=TRUE"
" WHERE deposit_serial_id=$1", " WHERE shard=$2"
1), " AND deposit_serial_id=$1",
2),
/* Used in #postgres_mark_deposit_done() */ /* Used in #postgres_mark_deposit_done() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"mark_deposit_done", "mark_deposit_done",
"UPDATE deposits" "UPDATE deposits"
" SET done=TRUE" " SET done=TRUE"
" WHERE deposit_serial_id=$1;", " WHERE shard=$2"
1), " AND deposit_serial_id=$1;",
2),
/* Used in #postgres_get_coin_transactions() to obtain information /* Used in #postgres_get_coin_transactions() to obtain information
about how a coin has been spend with /deposit requests. */ about how a coin has been spend with /deposit requests. */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
@ -5429,16 +5431,20 @@ postgres_have_deposit2 (
* @e iterate_ready_deposits() * @e iterate_ready_deposits()
* *
* @param cls the @e cls of this struct with the plugin-specific state * @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 * @param rowid identifies the deposit row to modify
* @return query result status * @return query result status
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
postgres_mark_deposit_tiny (void *cls, postgres_mark_deposit_tiny (void *cls,
const struct TALER_MerchantPublicKeyP *merchant_pub,
uint64_t rowid) uint64_t rowid)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
uint64_t deposit_shard = compute_shard (merchant_pub);
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&rowid), GNUNET_PQ_query_param_uint64 (&rowid),
GNUNET_PQ_query_param_uint64 (&deposit_shard),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -5454,16 +5460,20 @@ postgres_mark_deposit_tiny (void *cls,
* @e iterate_ready_deposits() or @e iterate_matching_deposits(). * @e iterate_ready_deposits() or @e iterate_matching_deposits().
* *
* @param cls the @e cls of this struct with the plugin-specific state * @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 * @param rowid identifies the deposit row to modify
* @return query result status * @return query result status
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
postgres_mark_deposit_done (void *cls, postgres_mark_deposit_done (void *cls,
const struct TALER_MerchantPublicKeyP *merchant_pub,
uint64_t rowid) uint64_t rowid)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
uint64_t deposit_shard = compute_shard (merchant_pub);
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&rowid), GNUNET_PQ_query_param_uint64 (&rowid),
GNUNET_PQ_query_param_uint64 (&deposit_shard),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -8054,7 +8064,8 @@ postgres_start_deferred_wire_out (void *cls)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_ExecuteStatement es[] = { 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_make_execute ("SET CONSTRAINTS ALL DEFERRED;"),
GNUNET_PQ_EXECUTE_STATEMENT_END GNUNET_PQ_EXECUTE_STATEMENT_END
}; };

View File

@ -2279,6 +2279,7 @@ run (void *cls)
"test-2")); "test-2"));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->mark_deposit_tiny (plugin->cls, plugin->mark_deposit_tiny (plugin->cls,
&deposit.merchant_pub,
deposit_rowid)); deposit_rowid));
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->get_ready_deposit (plugin->cls, plugin->get_ready_deposit (plugin->cls,
@ -2300,6 +2301,7 @@ run (void *cls)
"test-3")); "test-3"));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->mark_deposit_done (plugin->cls, plugin->mark_deposit_done (plugin->cls,
&deposit.merchant_pub,
deposit_rowid)); deposit_rowid));
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->commit (plugin->cls)); plugin->commit (plugin->cls));

View File

@ -2979,11 +2979,13 @@ struct TALER_EXCHANGEDB_Plugin
* returned by @e iterate_ready_deposits() * returned by @e iterate_ready_deposits()
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param merchant_pub identifies the beneficiary of the deposit
* @param deposit_rowid identifies the deposit row to modify * @param deposit_rowid identifies the deposit row to modify
* @return query result status * @return query result status
*/ */
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
(*mark_deposit_tiny)(void *cls, (*mark_deposit_tiny)(void *cls,
const struct TALER_MerchantPublicKeyP *merchant_pub,
uint64_t rowid); uint64_t rowid);
@ -2993,11 +2995,13 @@ struct TALER_EXCHANGEDB_Plugin
* @e iterate_ready_deposits() or @e iterate_matching_deposits(). * @e iterate_ready_deposits() or @e iterate_matching_deposits().
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param merchant_pub identifies the beneficiary of the deposit
* @param deposit_rowid identifies the deposit row to modify * @param deposit_rowid identifies the deposit row to modify
* @return query result status * @return query result status
*/ */
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
(*mark_deposit_done)(void *cls, (*mark_deposit_done)(void *cls,
const struct TALER_MerchantPublicKeyP *merchant_pub,
uint64_t rowid); uint64_t rowid);