diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-01-10 13:36:02 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-01-10 13:36:02 +0100 |
commit | 1df72de087db8e2a0696fc5d8b8c3b1f8f3c8e80 (patch) | |
tree | a923182e74f864f2400d8ea64198cfba3e4883ca /src | |
parent | b41ffd1a1af24efc244f7ed95dcc13c4b77bc56e (diff) | |
parent | 0cf46d8e5995f84a642795ddf214776ed8d4077f (diff) | |
download | exchange-1df72de087db8e2a0696fc5d8b8c3b1f8f3c8e80.tar.xz |
Merge branch 'master' of git+ssh://git.taler.net/exchange
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange/taler-exchange-wirewatch.c | 30 | ||||
-rw-r--r-- | src/exchangedb/0002-work_shards.sql | 5 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_batch2_reserves_in_insert.sql | 1 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_batch4_reserves_in_insert.sql | 2 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_batch_reserves_in_insert.sql | 68 | ||||
-rw-r--r-- | src/exchangedb/pg_batch2_reserves_in_insert.c | 4 | ||||
-rw-r--r-- | src/mhd/mhd_legal.c | 1 |
7 files changed, 81 insertions, 30 deletions
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index 337b11ca3..957060329 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2016--2022 Taler Systems SA + Copyright (C) 2016--2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -52,6 +52,17 @@ static const struct TALER_EXCHANGEDB_AccountInfo *ai; static struct TALER_BANK_CreditHistoryHandle *hh; /** + * Set to true if the request for history did actually + * return transaction items. + */ +static bool hh_returned_data; + +/** + * When did we start the last @e hh request? + */ +static struct GNUNET_TIME_Absolute hh_start_time; + +/** * Until when is processing this wire plugin delayed? */ static struct GNUNET_TIME_Absolute delayed_until; @@ -455,6 +466,18 @@ transaction_completed (void) GNUNET_SCHEDULER_shutdown (); return; } + if (! hh_returned_data) + { + /* Enforce long polling delay even if the server ignored it + and returned earlier */ + struct GNUNET_TIME_Relative latency; + struct GNUNET_TIME_Relative left; + + latency = GNUNET_TIME_absolute_get_duration (hh_start_time); + left = GNUNET_TIME_relative_subtract (LONGPOLL_TIMEOUT, + latency); + delayed_until = GNUNET_TIME_relative_to_absolute (left); + } GNUNET_assert (NULL == task); schedule_transfers (); } @@ -482,6 +505,7 @@ process_reply (const struct TALER_BANK_CreditDetails *details, transaction_completed (); return; } + hh_returned_data = true; /* check serial IDs for range constraints */ for (unsigned int i = 0; i<details_length; i++) { @@ -720,6 +744,7 @@ process_reply_batched (const struct TALER_BANK_CreditDetails *details, enum GNUNET_DB_QueryStatus qss[details_length]; struct TALER_EXCHANGEDB_ReserveInInfo reserves[details_length]; + hh_returned_data = true; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Importing %u transactions\n", details_length); @@ -865,6 +890,7 @@ process_reply_batched2 (unsigned int batch_size, transaction_completed (); return; } + hh_returned_data = true; /* check serial IDs for range constraints */ for (unsigned int i = 0; i<details_length; i++) { @@ -1121,6 +1147,8 @@ continue_with_shard (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting credit history staring from %llu\n", (unsigned long long) latest_row_off); + hh_start_time = GNUNET_TIME_absolute_get (); + hh_returned_data = false; hh = TALER_BANK_credit_history (ctx, ai->auth, latest_row_off, diff --git a/src/exchangedb/0002-work_shards.sql b/src/exchangedb/0002-work_shards.sql index 016207d37..220745d43 100644 --- a/src/exchangedb/0002-work_shards.sql +++ b/src/exchangedb/0002-work_shards.sql @@ -49,3 +49,8 @@ CREATE INDEX work_shards_by_end_row_index ON work_shards (end_row DESC); +CREATE INDEX work_shards_by_rows + ON work_shards + (job_name + ,start_row + ,end_row); diff --git a/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql index bda644eca..932f7d813 100644 --- a/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql @@ -55,7 +55,6 @@ DECLARE DECLARE k INT8; BEGIN - --SIMPLE INSERT ON CONFLICT DO NOTHING transaction_duplicate=TRUE; transaction_duplicate2=TRUE; out_reserve_found = TRUE; diff --git a/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql index c2157f7d3..a70521bcd 100644 --- a/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql @@ -267,7 +267,7 @@ BEGIN END IF; k=k+1; END LOOP; - + /**ROLLBACK TRANSACTION IN SOTRED PROCEDURE IS IT PROSSIBLE ?**/ /*IF transaction_duplicate OR transaction_duplicate2 OR transaction_duplicate3 diff --git a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql index 4e0383f6c..c95f75c3c 100644 --- a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql @@ -32,7 +32,12 @@ CREATE OR REPLACE FUNCTION exchange_do_batch_reserves_in_insert( OUT ruuid INT8) LANGUAGE plpgsql AS $$ - +DECLARE + curs refcursor; +DECLARE + i RECORD; +DECLARE + curs_trans refcursor; BEGIN ruuid= 0; out_reserve_found = TRUE; @@ -46,29 +51,38 @@ transaction_duplicate= TRUE; ,in_payto_uri) ON CONFLICT DO NOTHING; - INSERT INTO reserves - (reserve_pub - ,current_balance_val - ,current_balance_frac - ,expiration_date - ,gc_date) - VALUES - (in_reserve_pub - ,in_credit_val - ,in_credit_frac - ,in_expiration_date - ,in_gc_date) - ON CONFLICT DO NOTHING - RETURNING reserves.reserve_uuid INTO ruuid; + OPEN curs FOR + WITH reserve_changes AS ( + INSERT INTO reserves + (reserve_pub + ,current_balance_val + ,current_balance_frac + ,expiration_date + ,gc_date) + VALUES + (in_reserve_pub + ,in_credit_val + ,in_credit_frac + ,in_expiration_date + ,in_gc_date) + ON CONFLICT DO NOTHING + RETURNING reserve_uuid, reserve_pub) + SELECT * FROM reserve_changes; + FETCH FROM curs INTO i; IF FOUND THEN -- We made a change, so the reserve did not previously exist. - out_reserve_found = FALSE; - ELSE - -- We made no change, which means the reserve existed. - out_reserve_found = TRUE; + IF in_reserve_pub = i.reserve_pub + THEN + out_reserve_found = FALSE; + ruuid = i.reserve_uuid; + END IF; END IF; + CLOSE curs; + PERFORM pg_notify(in_notify, NULL); + OPEN curs_trans FOR + WITH reserve_transaction AS( INSERT INTO reserves_in (reserve_pub ,wire_reference @@ -85,16 +99,18 @@ transaction_duplicate= TRUE; ,in_exchange_account_name ,in_wire_source_h_payto ,in_expiration_date) - ON CONFLICT DO NOTHING; + ON CONFLICT DO NOTHING + RETURNING reserve_pub) + SELECT * FROM reserve_transaction; + FETCH FROM curs_trans INTO i; IF FOUND THEN + IF i.reserve_pub = in_reserve_pub + THEN -- HAPPY PATH THERE IS NO DUPLICATE TRANS - transaction_duplicate = FALSE; - ELSE - -- Unhappy... --- RAISE EXCEPTION 'Reserve did not exist, but INSERT into reserves_in gave conflict'; - transaction_duplicate = TRUE; --- ROLLBACK; + transaction_duplicate = FALSE; + END IF; END IF; + CLOSE curs_trans; RETURN; END $$; diff --git a/src/exchangedb/pg_batch2_reserves_in_insert.c b/src/exchangedb/pg_batch2_reserves_in_insert.c index a55c518c3..1ef9045da 100644 --- a/src/exchangedb/pg_batch2_reserves_in_insert.c +++ b/src/exchangedb/pg_batch2_reserves_in_insert.c @@ -763,6 +763,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls, t_duplicate |= transaction_duplicate[i+1]; t_duplicate |= transaction_duplicate[i+2]; t_duplicate |= transaction_duplicate[i+3]; + // fprintf(stdout, "reserve_uuid : %ld %ld %ld %ld\n", reserve_uuid[i], reserve_uuid[i+1], reserve_uuid[i+2], reserve_uuid[i+3]); i += 4; break; case 3: @@ -792,6 +793,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls, results[i] = (t_duplicate) ? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS : GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; + // fprintf(stdout, "reserve_uuid : %ld %ld\n", reserve_uuid[i], reserve_uuid[i+1]); i += 2; break; case 1: @@ -815,7 +817,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls, } need_update |= conflicts[i]; t_duplicate |= transaction_duplicate[i]; - // fprintf(stdout, "reserve uuid : %ld c :%d t:%d\n", reserve_uuid[i], conflicts[i], transaction_duplicate[i]); + // fprintf(stdout, "reserve uuid : %ld c :%d t:%d\n", reserve_uuid[i], conflicts[i], transaction_duplicate[i]); i += 1; break; case 0: diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c index c801f84cd..25435210e 100644 --- a/src/mhd/mhd_legal.c +++ b/src/mhd/mhd_legal.c @@ -388,6 +388,7 @@ load_terms (struct TALER_MHD_Legal *legal, { .ext = ".html", .mime = "text/html", .priority = 100 }, { .ext = ".htm", .mime = "text/html", .priority = 99 }, { .ext = ".txt", .mime = "text/plain", .priority = 50 }, + { .ext = ".md", .mime = "text/markdown", .priority = 50 }, { .ext = ".pdf", .mime = "application/pdf", .priority = 25 }, { .ext = ".jpg", .mime = "image/jpeg" }, { .ext = ".jpeg", .mime = "image/jpeg" }, |