gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] 03/03: make do_retry not retry forever in tests/benchma


From: gnunet
Subject: [taler-exchange] 03/03: make do_retry not retry forever in tests/benchmark
Date: Thu, 19 Mar 2020 19:33:26 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

commit f76e7c46e6609d39d5b28cb489a946833ca58bfb
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Mar 19 19:33:20 2020 +0100

    make do_retry not retry forever in tests/benchmark
---
 .../testing_api_cmd_auditor_deposit_confirmation.c | 14 ++++++++----
 src/testing/testing_api_cmd_auditor_exchanges.c    | 15 +++++++++----
 .../testing_api_cmd_bank_admin_add_incoming.c      | 15 +++++++++----
 src/testing/testing_api_cmd_bank_transfer.c        | 17 +++++++++-----
 src/testing/testing_api_cmd_deposit.c              | 15 +++++++++----
 src/testing/testing_api_cmd_withdraw.c             | 26 +++++++++++++++++-----
 6 files changed, 76 insertions(+), 26 deletions(-)

diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c 
b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
index 96d0740e..bcef59c5 100644
--- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
+++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
@@ -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;
 }
 
diff --git a/src/testing/testing_api_cmd_auditor_exchanges.c 
b/src/testing/testing_api_cmd_auditor_exchanges.c
index c7acaab9..b5a1cab0 100644
--- a/src/testing/testing_api_cmd_auditor_exchanges.c
+++ b/src/testing/testing_api_cmd_auditor_exchanges.c
@@ -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;
 }
 
diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c 
b/src/testing/testing_api_cmd_bank_admin_add_incoming.c
index 2398c5be..6e707a2e 100644
--- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c
+++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c
@@ -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;
 }
 
diff --git a/src/testing/testing_api_cmd_bank_transfer.c 
b/src/testing/testing_api_cmd_bank_transfer.c
index f8dfc0b8..03bf5973 100644
--- a/src/testing/testing_api_cmd_bank_transfer.c
+++ b/src/testing/testing_api_cmd_bank_transfer.c
@@ -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 */
diff --git a/src/testing/testing_api_cmd_deposit.c 
b/src/testing/testing_api_cmd_deposit.c
index 573c68b9..6781568a 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -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;
 }
 
diff --git a/src/testing/testing_api_cmd_withdraw.c 
b/src/testing/testing_api_cmd_withdraw.c
index 96412156..b2fc272e 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -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;
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]