fix sharding

This commit is contained in:
Christian Grothoff 2021-11-01 18:05:01 +01:00
parent 5b3a468d38
commit 22ce5bff77
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 46 additions and 35 deletions

@ -1 +1 @@
Subproject commit 8c7d9be40ba627348da3e01b91b4f1d3cc78631f Subproject commit 17555514bd2866e0d45b23e4a1c198415205c8f2

View File

@ -319,7 +319,7 @@ parse_wirewatch_config (void)
* @param amount_with_fee what was the refunded amount with the fee * @param amount_with_fee what was the refunded amount with the fee
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
*/ */
static int static enum GNUNET_GenericReturnValue
refund_by_coin_cb (void *cls, refund_by_coin_cb (void *cls,
const struct TALER_Amount *amount_with_fee) const struct TALER_Amount *amount_with_fee)
{ {
@ -768,8 +768,9 @@ run_aggregation (void *cls)
/* Now try to find other deposits to aggregate */ /* Now try to find other deposits to aggregate */
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Found ready deposit for %s, aggregating\n", "Found ready deposit for %s, aggregating by target %llu\n",
TALER_B2S (&au_active.merchant_pub)); TALER_B2S (&au_active.merchant_pub),
(unsigned long long) au_active.wire_target);
qs = db_plugin->iterate_matching_deposits (db_plugin->cls, qs = db_plugin->iterate_matching_deposits (db_plugin->cls,
au_active.wire_target, au_active.wire_target,
&au_active.merchant_pub, &au_active.merchant_pub,

View File

@ -386,7 +386,7 @@ CREATE TABLE IF NOT EXISTS deposits
COMMENT ON TABLE deposits COMMENT ON TABLE deposits
IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).'; IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).';
COMMENT ON COLUMN deposits.shard COMMENT ON COLUMN deposits.shard
IS 'Used for load sharding. Should be set based on h_wire, merchant_pub and a service salt. Default of 0 onlyapplies for columns migrated from a previous version without sharding support. 64-bit value because we need an *unsigned* 32-bit value.'; IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. Default of 0 onlyapplies for columns migrated from a previous version without sharding support. 64-bit value because we need an *unsigned* 32-bit value.';
COMMENT ON COLUMN deposits.wire_target_serial_id COMMENT ON COLUMN deposits.wire_target_serial_id
IS 'Identifies the target bank account and KYC status';COMMENT ON COLUMN deposits.wire_salt IS 'Identifies the target bank account and KYC status';COMMENT ON COLUMN deposits.wire_salt
IS 'Salt used when hashing the payto://-URI to get the h_wire'; IS 'Salt used when hashing the payto://-URI to get the h_wire';

View File

@ -5301,7 +5301,7 @@ postgres_get_ready_deposit (void *cls,
(void) GNUNET_TIME_round_abs (&now); (void) GNUNET_TIME_round_abs (&now);
GNUNET_assert (start_shard_row < end_shard_row); GNUNET_assert (start_shard_row < end_shard_row);
GNUNET_assert (end_shard_row <= INT64_MAX); GNUNET_assert (end_shard_row <= INT32_MAX);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Finding ready deposits by deadline %s (%llu)\n", "Finding ready deposits by deadline %s (%llu)\n",
GNUNET_STRINGS_absolute_time_to_string (now), GNUNET_STRINGS_absolute_time_to_string (now),
@ -5709,7 +5709,7 @@ postgres_ensure_coin_known (void *cls,
static uint64_t static uint64_t
compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit) compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit)
{ {
uint64_t res; uint32_t res;
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
GNUNET_CRYPTO_kdf (&res, GNUNET_CRYPTO_kdf (&res,
@ -5720,12 +5720,12 @@ compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit)
strlen (deposit->receiver_wire_account), strlen (deposit->receiver_wire_account),
NULL, 0)); NULL, 0));
/* interpret hash result as NBO for platform independence, /* interpret hash result as NBO for platform independence,
convert to HBO and map to [0..2^63-1] range */ convert to HBO and map to [0..2^31-1] range */
res = ntohl (res); res = ntohl (res);
if (res > INT64_MAX) if (res > INT32_MAX)
res += INT64_MIN; res += INT32_MIN;
GNUNET_assert (res <= INT64_MAX); GNUNET_assert (res <= INT32_MAX);
return res; return (uint64_t) res;
} }
@ -5773,7 +5773,7 @@ postgres_insert_deposit (void *cls,
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
GNUNET_assert (shard <= INT64_MAX); GNUNET_assert (shard <= INT32_MAX);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Inserting deposit to be executed at %s (%llu/%llu)\n", "Inserting deposit to be executed at %s (%llu/%llu)\n",
GNUNET_STRINGS_absolute_time_to_string (deposit->wire_deadline), GNUNET_STRINGS_absolute_time_to_string (deposit->wire_deadline),

View File

@ -1864,7 +1864,7 @@ run (void *cls)
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_ready_deposit (plugin->cls, plugin->get_ready_deposit (plugin->cls,
0, 0,
INT64_MAX, INT32_MAX,
&deposit_cb, &deposit_cb,
&deposit)); &deposit));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
@ -1885,14 +1885,14 @@ run (void *cls)
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,
0, 0,
INT64_MAX, INT32_MAX,
&deposit_cb, &deposit_cb,
&deposit)); &deposit));
plugin->rollback (plugin->cls); plugin->rollback (plugin->cls);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_ready_deposit (plugin->cls, plugin->get_ready_deposit (plugin->cls,
0, 0,
INT64_MAX, INT32_MAX,
&deposit_cb, &deposit_cb,
&deposit)); &deposit));
FAILIF (GNUNET_OK != FAILIF (GNUNET_OK !=

View File

@ -213,26 +213,35 @@ run (void *cls,
* happen here, as each deposit operation is run with a * happen here, as each deposit operation is run with a
* fresh merchant public key! NOTE: this comment comes * fresh merchant public key! NOTE: this comment comes
* "verbatim" from the old test-suite, and IMO does not explain * "verbatim" from the old test-suite, and IMO does not explain
* a lot!*/// * a lot! */
CMD_EXEC_AGGREGATOR ("run-aggregator"), CMD_EXEC_AGGREGATOR ("run-aggregator"),
/** /**
* Check all the transfers took place. * Check all the transfers took place.
*/ */
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer (
("check_bank_transfer-499c", ec.exchange_url, "check_bank_transfer-499c",
"EUR:4.98", bc.exchange_payto, bc.user42_payto), ec.exchange_url,
TALER_TESTING_cmd_check_bank_transfer "EUR:4.98",
("check_bank_transfer-99c1", ec.exchange_url, bc.exchange_payto,
"EUR:0.98", bc.exchange_payto, bc.user42_payto), bc.user42_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer (
("check_bank_transfer-99c", ec.exchange_url, "check_bank_transfer-99c1",
"EUR:0.08", bc.exchange_payto, bc.user43_payto), ec.exchange_url,
"EUR:0.98",
bc.exchange_payto,
bc.user42_payto),
TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-99c",
ec.exchange_url,
"EUR:0.08",
bc.exchange_payto,
bc.user43_payto),
/* The following transactions got originated within /* The following transactions got originated within
* the "massive deposit confirms" batch. */ * the "massive deposit confirms" batch. */
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer (
("check-massive-transfer-1", "check-massive-transfer-1",
ec.exchange_url, ec.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), bc.exchange_payto, bc.user43_payto),
@ -412,7 +421,8 @@ run (void *cls,
* These commands should close the reserve because the aggregator * These commands should close the reserve because the aggregator
* is given a config file that overrides the reserve expiration * is given a config file that overrides the reserve expiration
* time (making it now-ish) * time (making it now-ish)
*/CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", */
CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve",
"EUR:5.01"), "EUR:5.01"),
TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation", TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation",
CONFIG_FILE_EXPIRE_RESERVE_NOW), CONFIG_FILE_EXPIRE_RESERVE_NOW),
@ -472,8 +482,8 @@ run (void *cls,
*/ */
CMD_TRANSFER_TO_EXCHANGE ("massive-reserve", CMD_TRANSFER_TO_EXCHANGE ("massive-reserve",
"EUR:10.10"), "EUR:10.10"),
TALER_TESTING_cmd_check_bank_admin_transfer TALER_TESTING_cmd_check_bank_admin_transfer (
("check-massive-transfer", "check-massive-transfer",
"EUR:10.10", "EUR:10.10",
bc.user42_payto, bc.exchange_payto, bc.user42_payto, bc.exchange_payto,
"massive-reserve"), "massive-reserve"),
@ -518,8 +528,8 @@ run (void *cls,
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_deposit TALER_TESTING_cmd_deposit (
("massive-deposit-1", "massive-deposit-1",
"massive-withdraw-1", "massive-withdraw-1",
0, 0,
bc.user43_payto, bc.user43_payto,
@ -599,8 +609,8 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_deposit TALER_TESTING_cmd_deposit (
("massive-deposit-10", "massive-deposit-10",
"massive-withdraw-10", "massive-withdraw-10",
0, 0,
bc.user43_payto, bc.user43_payto,