change order of statements when making coin known to possibly reduce serialization failures
This commit is contained in:
parent
67de20d26e
commit
19de0f604f
@ -781,7 +781,8 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",denom_sig"
|
",denom_sig"
|
||||||
") SELECT $1, denominations_serial, $3 "
|
") SELECT $1, denominations_serial, $3 "
|
||||||
" FROM denominations"
|
" FROM denominations"
|
||||||
" WHERE denom_pub_hash=$2;",
|
" WHERE denom_pub_hash=$2"
|
||||||
|
" ON CONFLICT DO NOTHING;",
|
||||||
3),
|
3),
|
||||||
|
|
||||||
/* Used in #postgres_insert_melt() to store
|
/* Used in #postgres_insert_melt() to store
|
||||||
@ -5767,16 +5768,24 @@ postgres_ensure_coin_known (void *cls,
|
|||||||
&denom_pub_hash),
|
&denom_pub_hash),
|
||||||
GNUNET_PQ_result_spec_end
|
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,
|
/* First, try to simply insert it */
|
||||||
"lock_known_coins",
|
qs = insert_known_coin (pg,
|
||||||
no_params)))
|
coin);
|
||||||
return qs;
|
switch (qs)
|
||||||
#endif
|
{
|
||||||
|
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 */
|
/* check if the coin is already known */
|
||||||
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
"get_known_coin_dh",
|
"get_known_coin_dh",
|
||||||
@ -5795,26 +5804,13 @@ postgres_ensure_coin_known (void *cls,
|
|||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return TALER_EXCHANGEDB_CKS_CONFLICT;
|
return TALER_EXCHANGEDB_CKS_CONFLICT;
|
||||||
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
|
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
|
||||||
break;
|
/* should be impossible */
|
||||||
}
|
|
||||||
|
|
||||||
/* if not known, insert it */
|
|
||||||
qs = insert_known_coin (pg,
|
|
||||||
coin);
|
|
||||||
switch (qs)
|
|
||||||
{
|
|
||||||
case GNUNET_DB_STATUS_HARD_ERROR:
|
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
|
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
|
||||||
case GNUNET_DB_STATUS_SOFT_ERROR:
|
}
|
||||||
return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
|
/* we should never get here */
|
||||||
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
|
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
|
return TALER_EXCHANGEDB_CKS_HARD_FAIL;
|
||||||
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TALER_EXCHANGEDB_CKS_ADDED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1796,9 +1796,14 @@ run (void *cls)
|
|||||||
value.currency));
|
value.currency));
|
||||||
|
|
||||||
result = 7;
|
result = 7;
|
||||||
|
{
|
||||||
|
struct TALER_Amount balance;
|
||||||
|
|
||||||
qs = plugin->get_reserve_history (plugin->cls,
|
qs = plugin->get_reserve_history (plugin->cls,
|
||||||
&reserve_pub,
|
&reserve_pub,
|
||||||
|
&balance,
|
||||||
&rh);
|
&rh);
|
||||||
|
}
|
||||||
FAILIF (0 > qs);
|
FAILIF (0 > qs);
|
||||||
FAILIF (NULL == rh);
|
FAILIF (NULL == rh);
|
||||||
rh_head = rh;
|
rh_head = rh;
|
||||||
|
Loading…
Reference in New Issue
Block a user