gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: minimize idle in transaction fro


From: gnunet
Subject: [taler-exchange] branch master updated: minimize idle in transaction from wirewatcher
Date: Thu, 09 Dec 2021 14:05:25 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new a7b4cc97 minimize idle in transaction from wirewatcher
a7b4cc97 is described below

commit a7b4cc97ecfe2452064c8ac2f05b8d7890c8576b
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Dec 9 14:05:23 2021 +0100

    minimize idle in transaction from wirewatcher
---
 src/exchange/taler-exchange-wirewatch.c | 58 +++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 17 deletions(-)

diff --git a/src/exchange/taler-exchange-wirewatch.c 
b/src/exchange/taler-exchange-wirewatch.c
index 6e2cd1ee..8f69ba7b 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -125,6 +125,11 @@ struct WireAccount
    */
   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
  */
-static int
+static enum GNUNET_GenericReturnValue
 exchange_serve_process_config (void)
 {
   if (GNUNET_OK !=
@@ -473,7 +478,7 @@ do_commit (struct WireAccount *wa)
  * @param json raw JSON response
  * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
  */
-static int
+static enum GNUNET_GenericReturnValue
 history_cb (void *cls,
             unsigned int http_status,
             enum TALER_ErrorCode ec,
@@ -495,9 +500,13 @@ history_cb (void *cls,
                   (unsigned int) ec,
                   http_status);
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "End of list. Committing progress!\n");
-    do_commit (wa);
+    if (wa->started_transaction)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "End of list. Committing progress!\n");
+      wa->started_transaction = false;
+      do_commit (wa);
+    }
     return GNUNET_OK; /* will be ignored anyway */
   }
   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",
                 (unsigned long long) serial_id,
                 (unsigned long long) wa->latest_row_off);
-    db_plugin->rollback (db_plugin->cls);
+    if (wa->started_transaction)
+    {
+      wa->started_transaction = false;
+      db_plugin->rollback (db_plugin->cls);
+    }
     GNUNET_SCHEDULER_shutdown ();
     wa->hh = NULL;
     return GNUNET_SYSERR;
@@ -521,10 +534,31 @@ history_cb (void *cls,
                 (unsigned long long) wa->shard_end);
     wa->latest_row_off = serial_id - 1;
     wa->delay = false;
-    do_commit (wa);
+    if (wa->started_transaction)
+    {
+      wa->started_transaction = false;
+      do_commit (wa);
+    }
+    else
+      GNUNET_break (0); /* how did this happen */
     wa->hh = NULL;
     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,
               "Adding wire transfer over %s with (hashed) subject `%s'\n",
               TALER_amount2s (&details->amount),
@@ -645,16 +679,6 @@ find_transfers (void *cls)
       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,
                       wa_pos->shard_end - wa_pos->batch_start);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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