match GNUnet API rename, work on #5010
This commit is contained in:
parent
780b716652
commit
cad64767d9
@ -732,6 +732,29 @@ static void
|
||||
run_aggregation (void *cls);
|
||||
|
||||
|
||||
/**
|
||||
* Perform a database commit. If it fails, print a warning.
|
||||
*
|
||||
* @param session session to perform the commit for.
|
||||
* @return status of commit
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
commit_or_warn (struct TALER_EXCHANGEDB_Session *session)
|
||||
{
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
|
||||
qs = db_plugin->commit (db_plugin->cls,
|
||||
session);
|
||||
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
|
||||
return qs;
|
||||
GNUNET_log ((GNUNET_DB_STATUS_SOFT_ERROR == qs)
|
||||
? GNUNET_ERROR_TYPE_INFO
|
||||
: GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to commit database transaction!\n");
|
||||
return qs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to be called with the prepared transfer data
|
||||
* when closing a reserve.
|
||||
@ -782,13 +805,7 @@ prepare_close_cb (void *cls,
|
||||
}
|
||||
|
||||
/* finally commit */
|
||||
if (GNUNET_OK !=
|
||||
db_plugin->commit (db_plugin->cls,
|
||||
ctc->session))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Failed to commit database transaction!\n");
|
||||
}
|
||||
(void) commit_or_warn (ctc->session);
|
||||
GNUNET_free (ctc->type);
|
||||
GNUNET_free (ctc);
|
||||
ctc = NULL;
|
||||
@ -948,13 +965,7 @@ expired_reserve_cb (void *cls,
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
/* Reserve balance was almost zero; just commit */
|
||||
if (GNUNET_OK !=
|
||||
db_plugin->commit (db_plugin->cls,
|
||||
session))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Failed to commit database transaction!\n");
|
||||
}
|
||||
(void) commit_or_warn (session);
|
||||
task = GNUNET_SCHEDULER_add_now (&run_reserve_closures,
|
||||
NULL);
|
||||
return GNUNET_SYSERR;
|
||||
@ -1191,13 +1202,7 @@ run_aggregation (void *cls)
|
||||
au->additional_rows[i]))
|
||||
ret = GNUNET_SYSERR;
|
||||
/* commit */
|
||||
if (GNUNET_OK !=
|
||||
db_plugin->commit (db_plugin->cls,
|
||||
session))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Failed to commit database transaction!\n");
|
||||
}
|
||||
(void) commit_or_warn (session);
|
||||
GNUNET_free_non_null (au->additional_rows);
|
||||
if (NULL != au->wire)
|
||||
json_decref (au->wire);
|
||||
@ -1336,6 +1341,8 @@ prepare_cb (void *cls,
|
||||
au = NULL;
|
||||
return;
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||
"Stored wire transfer out instructions\n");
|
||||
if (NULL != au->wire)
|
||||
{
|
||||
json_decref (au->wire);
|
||||
@ -1346,22 +1353,31 @@ prepare_cb (void *cls,
|
||||
|
||||
/* Now we can finally commit the overall transaction, as we are
|
||||
again consistent if all of this passes. */
|
||||
if (GNUNET_OK !=
|
||||
db_plugin->commit (db_plugin->cls,
|
||||
session))
|
||||
switch (commit_or_warn (session))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Failed to commit database transaction!\n");
|
||||
case GNUNET_DB_STATUS_SOFT_ERROR:
|
||||
/* try again */
|
||||
task = GNUNET_SCHEDULER_add_now (&run_aggregation,
|
||||
NULL);
|
||||
return;
|
||||
case GNUNET_DB_STATUS_HARD_ERROR:
|
||||
GNUNET_break (0);
|
||||
global_ret = GNUNET_SYSERR;
|
||||
GNUNET_SCHEDULER_shutdown ();
|
||||
return;
|
||||
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Preparation complete, switching to transfer mode\n");
|
||||
/* run alternative task: actually do wire transfer! */
|
||||
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
||||
NULL);
|
||||
return;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
global_ret = GNUNET_SYSERR;
|
||||
GNUNET_SCHEDULER_shutdown ();
|
||||
return;
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Preparation complete, switching to transfer mode\n");
|
||||
/* run alternative task: actually do wire transfer! */
|
||||
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -1411,24 +1427,32 @@ wire_confirm_cb (void *cls,
|
||||
}
|
||||
GNUNET_free (wpd);
|
||||
wpd = NULL;
|
||||
if (GNUNET_OK !=
|
||||
db_plugin->commit (db_plugin->cls,
|
||||
session))
|
||||
switch (commit_or_warn (session))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Failed to commit database transaction!\n");
|
||||
case GNUNET_DB_STATUS_SOFT_ERROR:
|
||||
/* try again */
|
||||
task = GNUNET_SCHEDULER_add_now (&run_aggregation,
|
||||
NULL);
|
||||
return;
|
||||
case GNUNET_DB_STATUS_HARD_ERROR:
|
||||
GNUNET_break (0);
|
||||
global_ret = GNUNET_SYSERR;
|
||||
GNUNET_SCHEDULER_shutdown ();
|
||||
return;
|
||||
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Wire transfer complete\n");
|
||||
/* continue with #run_transfers(), just to guard
|
||||
against the unlikely case that there are more. */
|
||||
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
||||
NULL);
|
||||
return;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
global_ret = GNUNET_SYSERR;
|
||||
GNUNET_SCHEDULER_shutdown ();
|
||||
return;
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Wire transfer complete\n");
|
||||
/* continue with #run_transfers(), just to guard
|
||||
against the unlikely case that there are more. */
|
||||
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
#define START_TRANSACTION(session,connection) \
|
||||
{ /* start new scope, will be ended by COMMIT_TRANSACTION() */\
|
||||
unsigned int transaction_retries = 0; \
|
||||
int transaction_commit_result; \
|
||||
enum GNUNET_DB_QueryStatus transaction_commit_result; \
|
||||
transaction_start_label: /* we will use goto for retries */ \
|
||||
if (GNUNET_OK != \
|
||||
TEH_plugin->start (TEH_plugin->cls, \
|
||||
@ -71,13 +71,13 @@ transaction_start_label: /* we will use goto for retries */ \
|
||||
transaction_commit_result = \
|
||||
TEH_plugin->commit (TEH_plugin->cls, \
|
||||
session); \
|
||||
if (GNUNET_SYSERR == transaction_commit_result) \
|
||||
if (GNUNET_DB_STATUS_HARD_ERROR == transaction_commit_result) \
|
||||
{ \
|
||||
TALER_LOG_WARNING ("Transaction commit failed in %s\n", __FUNCTION__); \
|
||||
return TEH_RESPONSE_reply_commit_error (connection, \
|
||||
TALER_EC_DB_COMMIT_FAILED_HARD); \
|
||||
} \
|
||||
if (GNUNET_NO == transaction_commit_result) \
|
||||
if (GNUNET_DB_STATUS_SOFT_ERROR == transaction_commit_result) \
|
||||
{ \
|
||||
TALER_LOG_WARNING ("Transaction commit failed in %s\n", __FUNCTION__); \
|
||||
if (transaction_retries++ <= MAX_TRANSACTION_COMMIT_RETRIES) \
|
||||
|
@ -331,7 +331,9 @@ reload_keys_denom_iter (void *cls,
|
||||
struct GNUNET_TIME_Absolute expire_deposit;
|
||||
struct GNUNET_HashCode denom_key_hash;
|
||||
struct TALER_EXCHANGEDB_Session *session;
|
||||
unsigned int thresh;
|
||||
int res;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||
"Loading denomination key `%s'\n",
|
||||
@ -361,8 +363,6 @@ reload_keys_denom_iter (void *cls,
|
||||
|
||||
if (NULL != revocation_master_sig)
|
||||
{
|
||||
unsigned int thresh = 0;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Adding denomination key `%s' to revokation set\n",
|
||||
alias);
|
||||
@ -373,11 +373,13 @@ reload_keys_denom_iter (void *cls,
|
||||
/* Try to insert DKI into DB until we succeed; note that if the DB
|
||||
failure is persistent, we need to die, as we cannot continue
|
||||
without the DKI being in the DB). */
|
||||
res = GNUNET_SYSERR;
|
||||
while (GNUNET_OK != res)
|
||||
thresh = 0;
|
||||
qs = GNUNET_DB_STATUS_SOFT_ERROR;
|
||||
while (0 > qs)
|
||||
{
|
||||
thresh++;
|
||||
if (thresh > 16)
|
||||
if ( (thresh > 16) ||
|
||||
(GNUNET_DB_STATUS_HARD_ERROR == qs) )
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Giving up, this is fatal. Committing suicide via SIGTERM.\n");
|
||||
@ -409,8 +411,8 @@ reload_keys_denom_iter (void *cls,
|
||||
session);
|
||||
break; /* already in is also OK! */
|
||||
}
|
||||
res = TEH_plugin->commit (TEH_plugin->cls,
|
||||
session);
|
||||
qs = TEH_plugin->commit (TEH_plugin->cls,
|
||||
session);
|
||||
}
|
||||
GNUNET_assert (0 ==
|
||||
json_array_append_new (ctx->payback_array,
|
||||
@ -440,12 +442,22 @@ reload_keys_denom_iter (void *cls,
|
||||
if (NULL == session)
|
||||
return GNUNET_SYSERR;
|
||||
/* Try to insert DKI into DB until we succeed; note that if the DB
|
||||
failure is persistent, this code may loop forever (as there is no
|
||||
sane alternative, we cannot continue without the DKI being in the
|
||||
DB). */
|
||||
res = GNUNET_SYSERR;
|
||||
while (GNUNET_OK != res)
|
||||
failure is persistent, we die, as we cannot continue without the
|
||||
DKI being in the DB). */
|
||||
qs = GNUNET_DB_STATUS_SOFT_ERROR;
|
||||
thresh = 0;
|
||||
while (0 > qs)
|
||||
{
|
||||
thresh++;
|
||||
if ( (thresh > 16) ||
|
||||
(GNUNET_DB_STATUS_HARD_ERROR == qs) )
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Giving up, this is fatal. Committing suicide via SIGTERM.\n");
|
||||
handle_signal (SIGTERM);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
res = TEH_plugin->start (TEH_plugin->cls,
|
||||
session);
|
||||
if (GNUNET_OK != res)
|
||||
@ -485,8 +497,8 @@ reload_keys_denom_iter (void *cls,
|
||||
session);
|
||||
continue;
|
||||
}
|
||||
res = TEH_plugin->commit (TEH_plugin->cls,
|
||||
session);
|
||||
qs = TEH_plugin->commit (TEH_plugin->cls,
|
||||
session);
|
||||
/* If commit succeeded, we're done, otherwise we retry; this
|
||||
time without logging, as theroetically commits can fail
|
||||
in a transactional DB due to concurrent activities that
|
||||
|
@ -450,7 +450,7 @@ do_deposit (struct Command *cmd)
|
||||
plugin->insert_deposit (plugin->cls,
|
||||
session,
|
||||
&deposit)) ||
|
||||
(GNUNET_OK !=
|
||||
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||
plugin->commit (plugin->cls,
|
||||
session)) )
|
||||
ret = GNUNET_SYSERR;
|
||||
@ -1148,7 +1148,7 @@ run (void *cls)
|
||||
session,
|
||||
&dpk,
|
||||
&issue)) ||
|
||||
(GNUNET_OK !=
|
||||
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||
plugin->commit (plugin->cls,
|
||||
session)) )
|
||||
{
|
||||
|
@ -1292,13 +1292,16 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
|
||||
break;
|
||||
|
||||
case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION:
|
||||
state->plugin->start (state->plugin->cls, state->session);
|
||||
GNUNET_break (GNUNET_OK ==
|
||||
state->plugin->start (state->plugin->cls,
|
||||
state->session));
|
||||
break;
|
||||
|
||||
case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION:
|
||||
state->plugin->commit (state->plugin->cls, state->session);
|
||||
GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
|
||||
state->plugin->commit (state->plugin->cls,
|
||||
state->session));
|
||||
break;
|
||||
|
||||
case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION:
|
||||
state->plugin->rollback (state->plugin->cls,
|
||||
state->session);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1337,7 +1337,7 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session,
|
||||
wire_out_account,
|
||||
&wire_out_amount));
|
||||
/* And now the commit should still succeed! */
|
||||
FAILIF (GNUNET_OK !=
|
||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||
plugin->commit (plugin->cls,
|
||||
session));
|
||||
|
||||
@ -1828,7 +1828,7 @@ run (void *cls)
|
||||
plugin->mark_deposit_done (plugin->cls,
|
||||
session,
|
||||
deposit_rowid));
|
||||
FAILIF (GNUNET_OK !=
|
||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||
plugin->commit (plugin->cls,
|
||||
session));
|
||||
FAILIF (GNUNET_YES !=
|
||||
@ -1873,7 +1873,7 @@ run (void *cls)
|
||||
session,
|
||||
&dkp_pub_hash,
|
||||
&master_sig));
|
||||
FAILIF (GNUNET_OK !=
|
||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||
plugin->commit (plugin->cls,
|
||||
session));
|
||||
FAILIF (GNUNET_OK !=
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <jansson.h>
|
||||
#include <gnunet/gnunet_util_lib.h>
|
||||
#include <gnunet/gnunet_db_lib.h>
|
||||
#include "taler_exchangedb_lib.h"
|
||||
|
||||
|
||||
@ -1109,7 +1110,7 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
* @return #GNUNET_OK on success, #GNUNET_NO if the transaction
|
||||
* can be retried, #GNUNET_SYSERR on hard failures
|
||||
*/
|
||||
int
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*commit) (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user