gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: change order of statements when


From: gnunet
Subject: [taler-exchange] branch master updated: change order of statements when making coin known to possibly reduce serialization failures
Date: Sun, 05 Dec 2021 17:59:06 +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 19de0f60 change order of statements when making coin known to possibly 
reduce serialization failures
19de0f60 is described below

commit 19de0f604f9b48eb18308353dee6de12ca4dd120
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Dec 5 17:59:02 2021 +0100

    change order of statements when making coin known to possibly reduce 
serialization failures
---
 src/exchangedb/plugin_exchangedb_postgres.c | 50 +++++++++++++----------------
 src/exchangedb/test_exchangedb.c            | 11 +++++--
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 9bdac759..79013179 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -781,7 +781,8 @@ prepare_statements (struct PostgresClosure *pg)
       ",denom_sig"
       ") SELECT $1, denominations_serial, $3 "
       "    FROM denominations"
-      "   WHERE denom_pub_hash=$2;",
+      "   WHERE denom_pub_hash=$2"
+      " ON CONFLICT DO NOTHING;",
       3),
 
     /* Used in #postgres_insert_melt() to store
@@ -5767,16 +5768,24 @@ postgres_ensure_coin_known (void *cls,
                                           &denom_pub_hash),
     GNUNET_PQ_result_spec_end
   };
-#if EXPLICIT_LOCKS
-  struct GNUNET_PQ_QueryParam no_params[] = {
-    GNUNET_PQ_query_param_end
-  };
 
-  if (0 > (qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
-                                                    "lock_known_coins",
-                                                    no_params)))
-    return qs;
-#endif
+  /* First, try to simply insert it */
+  qs = insert_known_coin (pg,
+                          coin);
+  switch (qs)
+  {
+  case GNUNET_DB_STATUS_HARD_ERROR:
+    GNUNET_break (0);
+    return TALER_EXCHANGEDB_CKS_HARD_FAIL;
+  case GNUNET_DB_STATUS_SOFT_ERROR:
+    return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
+  case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+    /* continued below */
+    break;
+  case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+    return TALER_EXCHANGEDB_CKS_ADDED;
+  }
+
   /* check if the coin is already known */
   qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
                                                  "get_known_coin_dh",
@@ -5795,26 +5804,13 @@ postgres_ensure_coin_known (void *cls,
     GNUNET_break_op (0);
     return TALER_EXCHANGEDB_CKS_CONFLICT;
   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
-    break;
-  }
-
-  /* if not known, insert it */
-  qs = insert_known_coin (pg,
-                          coin);
-  switch (qs)
-  {
-  case GNUNET_DB_STATUS_HARD_ERROR:
+    /* should be impossible */
     GNUNET_break (0);
     return TALER_EXCHANGEDB_CKS_HARD_FAIL;
-  case GNUNET_DB_STATUS_SOFT_ERROR:
-    return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
-  case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
-    GNUNET_break (0);
-    return TALER_EXCHANGEDB_CKS_HARD_FAIL;
-  case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
-    break;
   }
-  return TALER_EXCHANGEDB_CKS_ADDED;
+  /* we should never get here */
+  GNUNET_break (0);
+  return TALER_EXCHANGEDB_CKS_HARD_FAIL;
 }
 
 
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 12cff490..ce943226 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1796,9 +1796,14 @@ run (void *cls)
                          value.currency));
 
   result = 7;
-  qs = plugin->get_reserve_history (plugin->cls,
-                                    &reserve_pub,
-                                    &rh);
+  {
+    struct TALER_Amount balance;
+
+    qs = plugin->get_reserve_history (plugin->cls,
+                                      &reserve_pub,
+                                      &balance,
+                                      &rh);
+  }
   FAILIF (0 > qs);
   FAILIF (NULL == rh);
   rh_head = rh;

-- 
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]