gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -fix aggregator with deferred co


From: gnunet
Subject: [taler-exchange] branch master updated: -fix aggregator with deferred constraint
Date: Thu, 24 Feb 2022 10:06:45 +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 5e500402 -fix aggregator with deferred constraint
5e500402 is described below

commit 5e5004020eb85a82394ac4d8bd83765304ffd8da
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Feb 24 10:06:43 2022 +0100

    -fix aggregator with deferred constraint
---
 src/exchangedb/exchange-0001.sql            | 19 ++++++++++++++++++-
 src/exchangedb/plugin_exchangedb_postgres.c | 17 ++++++++++++++++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/exchangedb/exchange-0001.sql b/src/exchangedb/exchange-0001.sql
index 477a9b0d..125f1020 100644
--- a/src/exchangedb/exchange-0001.sql
+++ b/src/exchangedb/exchange-0001.sql
@@ -581,7 +581,7 @@ CREATE INDEX IF NOT EXISTS 
wire_out_by_wire_target_serial_id_index
 CREATE TABLE IF NOT EXISTS aggregation_tracking
   (aggregation_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY -- UNIQUE
   ,deposit_serial_id INT8 PRIMARY KEY -- REFERENCES deposits 
(deposit_serial_id) ON DELETE CASCADE
-  ,wtid_raw BYTEA CONSTRAINT wire_out_ref REFERENCES wire_out(wtid_raw) ON 
DELETE CASCADE DEFERRABLE
+  ,wtid_raw BYTEA NOT NULL CONSTRAINT wire_out_ref REFERENCES 
wire_out(wtid_raw) ON DELETE CASCADE DEFERRABLE
   )
   PARTITION BY HASH (deposit_serial_id);
 COMMENT ON TABLE aggregation_tracking
@@ -1078,6 +1078,23 @@ COMMENT ON FUNCTION 
exchange_do_withdraw_limit_check(INT8, INT8, INT8, INT4)
   IS 'Check whether the withdrawals from the given reserve since the given 
time are below the given threshold';
 
 
+-- NOTE: experiment, currently dead, see postgres_Start_deferred_wire_out;
+-- now done inline. FIXME: Remove code here once inline version is confirmed 
working nicely!
+CREATE OR REPLACE PROCEDURE defer_wire_out()
+LANGUAGE plpgsql
+AS $$
+BEGIN
+
+IF EXISTS (
+  SELECT 1
+    FROM information_Schema.constraint_column_usage
+   WHERE table_name='wire_out'
+     AND constraint_name='wire_out_ref') 
+THEN 
+  SET CONSTRAINTS wire_out_ref DEFERRED;
+END IF;
+
+END $$;
 
 
 CREATE OR REPLACE FUNCTION exchange_do_deposit(
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index c80f3370..507a2c66 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -7949,7 +7949,22 @@ postgres_start_deferred_wire_out (void *cls)
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_ExecuteStatement es[] = {
     GNUNET_PQ_make_execute ("START TRANSACTION ISOLATION LEVEL READ 
COMMITTED"),
-    GNUNET_PQ_make_try_execute ("SET CONSTRAINTS wire_out_ref DEFERRED"),
+    GNUNET_PQ_make_execute ("DO $$"
+                            "BEGIN"
+                            " IF EXISTS ("
+                            "   SELECT 1"
+                            "     FROM 
information_Schema.constraint_column_usage"
+                            "    WHERE table_name='wire_out'"
+                            "      AND constraint_name='wire_out_ref')"
+                            "  THEN "
+                            "  SET CONSTRAINTS wire_out_ref DEFERRED;"
+                            "  END IF;"
+                            "END $$"),
+    // FIXME: above logic is better as it tests that the constraint
+    // is actually applicable; but maybe we want to drop the constraint
+    // entirely once do_gc() is fixed to do without it?
+    //    GNUNET_PQ_make_execute ("CALL defer_wire_out()"),
+    //    GNUNET_PQ_make_execute ("SET CONSTRAINTS wire_out_ref DEFERRED;"),
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
 

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