change order of statements when making coin known to possibly reduce serialization failures

This commit is contained in:
Christian Grothoff 2021-12-05 17:59:02 +01:00
parent 67de20d26e
commit 19de0f604f
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 31 additions and 30 deletions

View File

@ -781,7 +781,8 @@ prepare_statements (struct PostgresClosure *pg)
",denom_sig"
") SELECT $1, denominations_serial, $3 "
" FROM denominations"
" WHERE denom_pub_hash=$2;",
" WHERE denom_pub_hash=$2"
" ON CONFLICT DO NOTHING;",
3),
/* Used in #postgres_insert_melt() to store
@ -5767,16 +5768,24 @@ postgres_ensure_coin_known (void *cls,
&denom_pub_hash),
GNUNET_PQ_result_spec_end
};
#if EXPLICIT_LOCKS
struct GNUNET_PQ_QueryParam no_params[] = {
GNUNET_PQ_query_param_end
};
if (0 > (qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"lock_known_coins",
no_params)))
return qs;
#endif
/* First, try to simply insert it */
qs = insert_known_coin (pg,
coin);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
GNUNET_break (0);
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
case GNUNET_DB_STATUS_SOFT_ERROR:
return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
/* continued below */
break;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
return TALER_EXCHANGEDB_CKS_ADDED;
}
/* check if the coin is already known */
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"get_known_coin_dh",
@ -5795,26 +5804,13 @@ postgres_ensure_coin_known (void *cls,
GNUNET_break_op (0);
return TALER_EXCHANGEDB_CKS_CONFLICT;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
break;
}
/* if not known, insert it */
qs = insert_known_coin (pg,
coin);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
/* should be impossible */
GNUNET_break (0);
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
case GNUNET_DB_STATUS_SOFT_ERROR:
return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_break (0);
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break;
}
return TALER_EXCHANGEDB_CKS_ADDED;
/* we should never get here */
GNUNET_break (0);
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
}

View File

@ -1796,9 +1796,14 @@ run (void *cls)
value.currency));
result = 7;
qs = plugin->get_reserve_history (plugin->cls,
&reserve_pub,
&rh);
{
struct TALER_Amount balance;
qs = plugin->get_reserve_history (plugin->cls,
&reserve_pub,
&balance,
&rh);
}
FAILIF (0 > qs);
FAILIF (NULL == rh);
rh_head = rh;