make do_retry not retry forever in tests/benchmark

This commit is contained in:
Christian Grothoff 2020-03-19 19:33:20 +01:00
parent 5e98c0652a
commit f76e7c46e6
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 76 additions and 26 deletions

View File

@ -29,6 +29,11 @@
#include "taler_signatures.h"
#include "backoff.h"
/**
* How often do we retry before giving up?
*/
#define NUM_RETRIES 5
/**
* State for a "deposit confirmation" CMD.
@ -83,9 +88,9 @@ struct DepositConfirmationState
unsigned int expected_response_code;
/**
* Should we retry on (transient) failures?
* How often should we retry on (transient) failures?
*/
int do_retry;
unsigned int do_retry;
};
@ -140,8 +145,9 @@ deposit_confirmation_cb (void *cls,
dcs->dc = NULL;
if (dcs->expected_response_code != http_status)
{
if (GNUNET_YES == dcs->do_retry)
if (0 != dcs->do_retry)
{
dcs->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@ -436,7 +442,7 @@ TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command
GNUNET_assert (&deposit_confirmation_run == cmd.run);
dcs = cmd.cls;
dcs->do_retry = GNUNET_YES;
dcs->do_retry = NUM_RETRIES;
return cmd;
}

View File

@ -30,6 +30,12 @@
#include "backoff.h"
/**
* How often do we retry before giving up?
*/
#define NUM_RETRIES 5
/**
* State for a "deposit confirmation" CMD.
*/
@ -72,9 +78,9 @@ struct ExchangesState
const char *exchange_url;
/**
* Should we retry on (transient) failures?
* How often should we retry on (transient) failures?
*/
int do_retry;
unsigned int do_retry;
};
@ -132,8 +138,9 @@ exchanges_cb (void *cls,
es->leh = NULL;
if (es->expected_response_code != http_status)
{
if (GNUNET_YES == es->do_retry)
if (0 != es->do_retry)
{
es->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@ -353,7 +360,7 @@ TALER_TESTING_cmd_exchanges_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&exchanges_run == cmd.run);
es = cmd.cls;
es->do_retry = GNUNET_YES;
es->do_retry = NUM_RETRIES;
return cmd;
}

View File

@ -32,6 +32,12 @@
#include "taler_testing_lib.h"
/**
* How often do we retry before giving up?
*/
#define NUM_RETRIES 5
/**
* State for a "fakebank transfer" CMD.
*/
@ -120,9 +126,9 @@ struct AdminAddIncomingState
/**
* Was this command modified via
* #TALER_TESTING_cmd_admin_add_incoming_with_retry to
* enable retries?
* enable retries? If so, how often should we still retry?
*/
int do_retry;
unsigned int do_retry;
};
@ -184,8 +190,9 @@ confirmation_cb (void *cls,
fts->aih = NULL;
if (MHD_HTTP_OK != http_status)
{
if (GNUNET_YES == fts->do_retry)
if (0 != fts->do_retry)
{
fts->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@ -588,7 +595,7 @@ TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&admin_add_incoming_run == cmd.run);
fts = cmd.cls;
fts->do_retry = GNUNET_YES;
fts->do_retry = NUM_RETRIES;
return cmd;
}

View File

@ -32,6 +32,12 @@
#include "taler_testing_lib.h"
/**
* How often do we retry before giving up?
*/
#define NUM_RETRIES 5
/**
* State for a "transfer" CMD.
*/
@ -113,9 +119,9 @@ struct TransferState
/**
* Was this command modified via
* #TALER_TESTING_cmd_admin_add_incoming_with_retry to
* enable retries?
* enable retries? If so, how often should we still retry?
*/
int do_retry;
unsigned int do_retry;
};
@ -175,8 +181,9 @@ confirmation_cb (void *cls,
fts->weh = NULL;
if (MHD_HTTP_OK != http_status)
{
if (GNUNET_YES == fts->do_retry)
if (0 != fts->do_retry)
{
fts->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@ -397,9 +404,9 @@ TALER_TESTING_cmd_transfer_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&transfer_run == cmd.run);
fts = cmd.cls;
fts->do_retry = GNUNET_YES;
fts->do_retry = NUM_RETRIES;
return cmd;
}
/* end of testing_api_cmd_transfer.c */
/* end of testing_api_cmd_bank_transfer.c */

View File

@ -29,6 +29,12 @@
#include "backoff.h"
/**
* How often do we retry before giving up?
*/
#define NUM_RETRIES 5
/**
* State for a "deposit" CMD.
*/
@ -104,9 +110,9 @@ struct DepositState
unsigned int expected_response_code;
/**
* Should we retry on (transient) failures?
* How often should we retry on (transient) failures?
*/
int do_retry;
unsigned int do_retry;
/**
* Set to #GNUNET_YES if the /deposit succeeded
@ -184,8 +190,9 @@ deposit_cb (void *cls,
ds->dh = NULL;
if (ds->expected_response_code != http_status)
{
if (GNUNET_YES == ds->do_retry)
if (0 != ds->do_retry)
{
ds->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@ -559,7 +566,7 @@ TALER_TESTING_cmd_deposit_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&deposit_run == cmd.run);
ds = cmd.cls;
ds->do_retry = GNUNET_YES;
ds->do_retry = NUM_RETRIES;
return cmd;
}

View File

@ -31,6 +31,17 @@
#include "backoff.h"
/**
* How often do we retry before giving up?
*/
#define NUM_RETRIES 15
/**
* How long do we wait AT LEAST if the exchange says the reserve is unknown?
*/
#define UNKNOWN_MIN_BACKOFF GNUNET_TIME_relative_multiply ( \
GNUNET_TIME_UNIT_MILLISECONDS, 100)
/**
* State for a "withdraw" CMD.
*/
@ -100,9 +111,9 @@ struct WithdrawState
/**
* Was this command modified via
* #TALER_TESTING_cmd_withdraw_with_retry to
* enable retries?
* enable retries? How often should we still retry?
*/
int do_retry;
unsigned int do_retry;
};
@ -160,8 +171,10 @@ reserve_withdraw_cb (void *cls,
ws->wsh = NULL;
if (ws->expected_response_code != http_status)
{
if (GNUNET_YES == ws->do_retry)
if (0 != ws->do_retry)
{
if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != ec)
ws->do_retry--; /* we don't count reserve unknown as failures here */
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS == ec) ||
@ -175,8 +188,11 @@ reserve_withdraw_cb (void *cls,
/* on DB conflicts, do not use backoff */
if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
ws->backoff = GNUNET_TIME_UNIT_ZERO;
else
else if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != ec)
ws->backoff = EXCHANGE_LIB_BACKOFF (ws->backoff);
else
ws->backoff = GNUNET_TIME_relative_max (UNKNOWN_MIN_BACKOFF,
ws->backoff);
ws->retry_task = GNUNET_SCHEDULER_add_delayed (ws->backoff,
&do_retry,
ws);
@ -526,7 +542,7 @@ TALER_TESTING_cmd_withdraw_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&withdraw_run == cmd.run);
ws = cmd.cls;
ws->do_retry = GNUNET_YES;
ws->do_retry = NUM_RETRIES;
return cmd;
}