minimize idle in transaction from wirewatcher
This commit is contained in:
parent
ce28d3b8e4
commit
a7b4cc97ec
@ -125,6 +125,11 @@ struct WireAccount
|
|||||||
*/
|
*/
|
||||||
bool delay;
|
bool delay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Did we start a transaction yet?
|
||||||
|
*/
|
||||||
|
bool started_transaction;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -293,7 +298,7 @@ add_account_cb (void *cls,
|
|||||||
*
|
*
|
||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
static int
|
static enum GNUNET_GenericReturnValue
|
||||||
exchange_serve_process_config (void)
|
exchange_serve_process_config (void)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -473,7 +478,7 @@ do_commit (struct WireAccount *wa)
|
|||||||
* @param json raw JSON response
|
* @param json raw JSON response
|
||||||
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
|
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
|
||||||
*/
|
*/
|
||||||
static int
|
static enum GNUNET_GenericReturnValue
|
||||||
history_cb (void *cls,
|
history_cb (void *cls,
|
||||||
unsigned int http_status,
|
unsigned int http_status,
|
||||||
enum TALER_ErrorCode ec,
|
enum TALER_ErrorCode ec,
|
||||||
@ -495,9 +500,13 @@ history_cb (void *cls,
|
|||||||
(unsigned int) ec,
|
(unsigned int) ec,
|
||||||
http_status);
|
http_status);
|
||||||
}
|
}
|
||||||
|
if (wa->started_transaction)
|
||||||
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"End of list. Committing progress!\n");
|
"End of list. Committing progress!\n");
|
||||||
|
wa->started_transaction = false;
|
||||||
do_commit (wa);
|
do_commit (wa);
|
||||||
|
}
|
||||||
return GNUNET_OK; /* will be ignored anyway */
|
return GNUNET_OK; /* will be ignored anyway */
|
||||||
}
|
}
|
||||||
if (serial_id < wa->latest_row_off)
|
if (serial_id < wa->latest_row_off)
|
||||||
@ -507,7 +516,11 @@ history_cb (void *cls,
|
|||||||
"Serial ID %llu not monotonic (got %llu before). Failing!\n",
|
"Serial ID %llu not monotonic (got %llu before). Failing!\n",
|
||||||
(unsigned long long) serial_id,
|
(unsigned long long) serial_id,
|
||||||
(unsigned long long) wa->latest_row_off);
|
(unsigned long long) wa->latest_row_off);
|
||||||
|
if (wa->started_transaction)
|
||||||
|
{
|
||||||
|
wa->started_transaction = false;
|
||||||
db_plugin->rollback (db_plugin->cls);
|
db_plugin->rollback (db_plugin->cls);
|
||||||
|
}
|
||||||
GNUNET_SCHEDULER_shutdown ();
|
GNUNET_SCHEDULER_shutdown ();
|
||||||
wa->hh = NULL;
|
wa->hh = NULL;
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -521,10 +534,31 @@ history_cb (void *cls,
|
|||||||
(unsigned long long) wa->shard_end);
|
(unsigned long long) wa->shard_end);
|
||||||
wa->latest_row_off = serial_id - 1;
|
wa->latest_row_off = serial_id - 1;
|
||||||
wa->delay = false;
|
wa->delay = false;
|
||||||
|
if (wa->started_transaction)
|
||||||
|
{
|
||||||
|
wa->started_transaction = false;
|
||||||
do_commit (wa);
|
do_commit (wa);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
GNUNET_break (0); /* how did this happen */
|
||||||
wa->hh = NULL;
|
wa->hh = NULL;
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
if (! wa->started_transaction)
|
||||||
|
{
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
db_plugin->start_read_committed (db_plugin->cls,
|
||||||
|
"wirewatch check for incoming wire transfers"))
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Failed to start database transaction!\n");
|
||||||
|
global_ret = EXIT_FAILURE;
|
||||||
|
GNUNET_SCHEDULER_shutdown ();
|
||||||
|
wa->hh = NULL;
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
wa->started_transaction = true;
|
||||||
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Adding wire transfer over %s with (hashed) subject `%s'\n",
|
"Adding wire transfer over %s with (hashed) subject `%s'\n",
|
||||||
TALER_amount2s (&details->amount),
|
TALER_amount2s (&details->amount),
|
||||||
@ -645,16 +679,6 @@ find_transfers (void *cls)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
|
||||||
db_plugin->start_read_committed (db_plugin->cls,
|
|
||||||
"wirewatch check for incoming wire transfers"))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to start database transaction!\n");
|
|
||||||
global_ret = EXIT_FAILURE;
|
|
||||||
GNUNET_SCHEDULER_shutdown ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
limit = GNUNET_MIN (wa_pos->batch_size,
|
limit = GNUNET_MIN (wa_pos->batch_size,
|
||||||
wa_pos->shard_end - wa_pos->batch_start);
|
wa_pos->shard_end - wa_pos->batch_start);
|
||||||
|
Loading…
Reference in New Issue
Block a user