fix batch size adjustment of wirewatcher

This commit is contained in:
Christian Grothoff 2021-06-19 17:11:11 +02:00
parent bbe86aee78
commit 2a9ec82dce
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 26 additions and 27 deletions

View File

@ -25,7 +25,6 @@
// TODO:
// - use more than one 'client' bank account
// - also add taler-exchange-transfer to simulate outgoing payments
// - improve reporting logic (currently not working)
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
@ -516,7 +515,7 @@ parallel_benchmark (void)
return GNUNET_SYSERR;
}
/* wait for fakebank to be ready */
sleep (1);
sleep (1 + history_size / 65536);
}
else
{

View File

@ -377,31 +377,39 @@ history_cb (void *cls,
qs = db_plugin->commit (db_plugin->cls,
session);
}
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
GNUNET_SCHEDULER_shutdown ();
return GNUNET_OK;
}
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got DB soft error for commit\n");
/* reduce transaction size to reduce rollback probability */
if (2 > wa->current_batch_size)
wa->current_batch_size /= 2;
if (2 > wa->batch_size)
{
wa->batch_size /= 2;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Reduced batch size to %llu due to serialization issue\n",
(unsigned long long) wa->batch_size);
}
/* try again */
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&find_transfers,
NULL);
return GNUNET_OK; /* will be ignored anyway */
}
if (0 < qs)
{
/* transaction success, update #last_row_off */
wa->last_row_off = wa->latest_row_off;
wa->latest_row_off = 0; /* should not be needed */
wa->session = NULL; /* should not be needed */
/* if successful at limit, try increasing transaction batch size (AIMD) */
if ( (wa->current_batch_size == wa->batch_size) &&
(UINT_MAX > wa->batch_size) )
wa->batch_size++;
}
GNUNET_break (0 <= qs);
/* transaction success, update #last_row_off */
wa->last_row_off = wa->latest_row_off;
wa->latest_row_off = 0; /* should not be needed */
wa->session = NULL; /* should not be needed */
if (wa->batch_size < INITIAL_BATCH_SIZE)
{
wa->batch_size += 1;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Increasing batch size to %llu\n",
(unsigned long long) wa->batch_size);
}
if ( (GNUNET_YES == wa->delay) &&
(test_mode) &&
(NULL == wa->next) )
@ -425,7 +433,7 @@ history_cb (void *cls,
NULL);
return GNUNET_OK; /* will be ignored anyway */
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding wire transfer over %s with (hashed) subject `%s'\n",
TALER_amount2s (&details->amount),
TALER_B2S (&details->reserve_pub));
@ -450,8 +458,6 @@ history_cb (void *cls,
}
#endif
if (wa->current_batch_size < UINT_MAX)
wa->current_batch_size++;
qs = db_plugin->reserves_in_insert (db_plugin->cls,
session,
&details->reserve_pub,
@ -496,8 +502,6 @@ find_transfers (void *cls)
(void) cls;
task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking for incoming wire transfers\n");
if (NULL == (session = db_plugin->get_session (db_plugin->cls)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@ -548,10 +552,6 @@ find_transfers (void *cls)
}
wa_pos->delay = GNUNET_YES;
wa_pos->current_batch_size = 0; /* reset counter */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"wirewatch: requesting incoming history from %s\n",
wa_pos->auth.wire_gateway_url);
wa_pos->session = session;
wa_pos->hh = TALER_BANK_credit_history (ctx,
&wa_pos->auth,

View File

@ -3411,7 +3411,7 @@ postgres_reserves_in_insert (void *cls,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == reserve_exists);
return reserve_exists;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating reserve %s with expiration in %s\n",
TALER_B2S (reserve_pub),
GNUNET_STRINGS_relative_time_to_string (