DB test passes again

This commit is contained in:
Christian Grothoff 2021-10-31 15:32:20 +01:00
parent 1d5edc6882
commit de8e0907aa
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 30 additions and 32 deletions

View File

@ -380,7 +380,7 @@ CREATE TABLE IF NOT EXISTS deposits
,tiny BOOLEAN NOT NULL DEFAULT FALSE ,tiny BOOLEAN NOT NULL DEFAULT FALSE
,done BOOLEAN NOT NULL DEFAULT FALSE ,done BOOLEAN NOT NULL DEFAULT FALSE
,extension_blocked BOOLEAN NOT NULL DEFAULT FALSE ,extension_blocked BOOLEAN NOT NULL DEFAULT FALSE
,extension_options VARCHAR NOT NULL ,extension_options VARCHAR
,UNIQUE (known_coin_id, merchant_pub, h_contract_terms) ,UNIQUE (known_coin_id, merchant_pub, h_contract_terms)
); );
COMMENT ON TABLE deposits COMMENT ON TABLE deposits

View File

@ -3904,7 +3904,7 @@ inselect_account_kyc_status (
}; };
uint8_t ok8 = 0; uint8_t ok8 = 0;
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("payment_target_uuid", GNUNET_PQ_result_spec_uint64 ("wire_target_serial_id",
&kyc->payment_target_uuid), &kyc->payment_target_uuid),
GNUNET_PQ_result_spec_auto_from_type ("kyc_ok", GNUNET_PQ_result_spec_auto_from_type ("kyc_ok",
&ok8), &ok8),
@ -5257,8 +5257,8 @@ postgres_mark_deposit_done (void *cls,
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
postgres_get_ready_deposit (void *cls, postgres_get_ready_deposit (void *cls,
uint32_t start_shard_row, uint64_t start_shard_row,
uint32_t end_shard_row, uint64_t end_shard_row,
TALER_EXCHANGEDB_DepositIterator deposit_cb, TALER_EXCHANGEDB_DepositIterator deposit_cb,
void *deposit_cb_cls) void *deposit_cb_cls)
{ {
@ -5266,8 +5266,8 @@ postgres_get_ready_deposit (void *cls,
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
TALER_PQ_query_param_absolute_time (&now), TALER_PQ_query_param_absolute_time (&now),
GNUNET_PQ_query_param_uint32 (&start_shard_row), GNUNET_PQ_query_param_uint64 (&start_shard_row),
GNUNET_PQ_query_param_uint32 (&end_shard_row), GNUNET_PQ_query_param_uint64 (&end_shard_row),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct TALER_Amount amount_with_fee; struct TALER_Amount amount_with_fee;
@ -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 <= INT32_MAX); GNUNET_assert (end_shard_row <= INT64_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),
@ -5706,27 +5706,25 @@ postgres_ensure_coin_known (void *cls,
* @param deposit deposit to compute shard for * @param deposit deposit to compute shard for
* @return shard number * @return shard number
*/ */
static uint32_t static uint64_t
compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit) compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit)
{ {
uint32_t res; uint64_t res;
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
GNUNET_CRYPTO_kdf (&res, GNUNET_CRYPTO_kdf (&res,
sizeof (res), sizeof (res),
&deposit->wire_salt,
sizeof (deposit->wire_salt),
&deposit->merchant_pub, &deposit->merchant_pub,
sizeof (deposit->merchant_pub), sizeof (deposit->merchant_pub),
deposit->receiver_wire_account, deposit->receiver_wire_account,
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^31-1] range */ convert to HBO and map to [0..2^63-1] range */
res = ntohl (res); res = ntohl (res);
if (res > INT32_MAX) if (res > INT64_MAX)
res += INT32_MIN; res += INT64_MIN;
GNUNET_assert (res <= INT32_MAX); GNUNET_assert (res <= INT64_MAX);
return res; return res;
} }
@ -5758,7 +5756,7 @@ postgres_insert_deposit (void *cls,
return qs; return qs;
} }
{ {
uint32_t shard = compute_shard (deposit); uint64_t shard = compute_shard (deposit);
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (&deposit->coin.coin_pub), GNUNET_PQ_query_param_auto_from_type (&deposit->coin.coin_pub),
TALER_PQ_query_param_amount (&deposit->amount_with_fee), TALER_PQ_query_param_amount (&deposit->amount_with_fee),
@ -5771,11 +5769,11 @@ postgres_insert_deposit (void *cls,
GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid), GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid),
GNUNET_PQ_query_param_auto_from_type (&deposit->csig), GNUNET_PQ_query_param_auto_from_type (&deposit->csig),
TALER_PQ_query_param_absolute_time (&exchange_timestamp), TALER_PQ_query_param_absolute_time (&exchange_timestamp),
GNUNET_PQ_query_param_uint32 (&shard), GNUNET_PQ_query_param_uint64 (&shard),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
GNUNET_assert (shard <= INT32_MAX); GNUNET_assert (shard <= INT64_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),
@ -7274,6 +7272,7 @@ postgres_lookup_transfer_by_deposit (
kyc->ok = true; kyc->ok = true;
return qs; return qs;
} }
qs = GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
} }
if (0 > qs) if (0 > qs)
return qs; return qs;
@ -11361,7 +11360,7 @@ postgres_begin_revolving_shard (void *cls,
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
GNUNET_assert (shard_limit <= 1U + (uint32_t) INT32_MAX); GNUNET_assert (shard_limit <= 1U + (uint32_t) INT_MAX);
GNUNET_assert (shard_limit > 0); GNUNET_assert (shard_limit > 0);
GNUNET_assert (shard_size > 0); GNUNET_assert (shard_size > 0);
for (unsigned int retries = 0; retries<3; retries++) for (unsigned int retries = 0; retries<3; retries++)

View File

@ -1472,7 +1472,6 @@ run (void *cls)
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute now;
struct TALER_WireSalt salt; struct TALER_WireSalt salt;
struct TALER_MerchantWireHash h_wire;
dkp = NULL; dkp = NULL;
rh = NULL; rh = NULL;
@ -1803,7 +1802,7 @@ run (void *cls)
TALER_merchant_wire_signature_hash ( TALER_merchant_wire_signature_hash (
"payto://iban/DE67830654080004822650?receiver-name=Test", "payto://iban/DE67830654080004822650?receiver-name=Test",
&deposit.wire_salt, &deposit.wire_salt,
&h_wire); &h_wire_wt);
deposit.amount_with_fee = value; deposit.amount_with_fee = value;
deposit.deposit_fee = fee_deposit; deposit.deposit_fee = fee_deposit;
@ -1855,6 +1854,13 @@ run (void *cls)
NULL)); NULL));
FAILIF (1 != auditor_row_cnt); FAILIF (1 != auditor_row_cnt);
result = 9; result = 9;
sleep (2); /* give deposit time to be ready */
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_ready_deposit (plugin->cls,
0,
INT64_MAX,
&deposit_cb,
&deposit));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->iterate_matching_deposits (plugin->cls, plugin->iterate_matching_deposits (plugin->cls,
wire_target_row, wire_target_row,
@ -1862,13 +1868,6 @@ run (void *cls)
&matching_deposit_cb, &matching_deposit_cb,
&deposit, &deposit,
2)); 2));
sleep (2); /* give deposit time to be ready */
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_ready_deposit (plugin->cls,
0,
INT32_MAX,
&deposit_cb,
&deposit));
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->commit (plugin->cls)); plugin->commit (plugin->cls));
FAILIF (GNUNET_OK != FAILIF (GNUNET_OK !=
@ -1880,14 +1879,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,
INT32_MAX, INT64_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,
INT32_MAX, INT64_MAX,
&deposit_cb, &deposit_cb,
&deposit)); &deposit));
FAILIF (GNUNET_OK != FAILIF (GNUNET_OK !=

View File

@ -2742,8 +2742,8 @@ struct TALER_EXCHANGEDB_Plugin
*/ */
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
(*get_ready_deposit)(void *cls, (*get_ready_deposit)(void *cls,
uint32_t start_shard_row, uint64_t start_shard_row,
uint32_t end_shard_row, uint64_t end_shard_row,
TALER_EXCHANGEDB_DepositIterator deposit_cb, TALER_EXCHANGEDB_DepositIterator deposit_cb,
void *deposit_cb_cls); void *deposit_cb_cls);