From 1c05eebebe2bc0bf9851a37d5da454edaab24e16 Mon Sep 17 00:00:00 2001 From: gindibay Date: Sat, 29 Jul 2023 19:21:13 +0300 Subject: [PATCH] Updates udf name --- .../distributed/metadata/node_metadata.c | 4 +-- .../distributed/sql/citus--12.0-1--12.1-1.sql | 2 +- .../sql/downgrades/citus--12.1-1--12.0-1.sql | 2 +- .../sql/udfs/citus_pause_node/12.1-1.sql | 9 ------ .../sql/udfs/citus_pause_node/latest.sql | 9 ------ .../citus_pause_node_within_txn/12.1-1.sql | 9 ++++++ .../citus_pause_node_within_txn/latest.sql | 9 ++++++ .../expected/isolation_citus_pause_node.out | 32 +++++++++---------- .../spec/isolation_citus_pause_node.spec | 16 +++++----- 9 files changed, 46 insertions(+), 46 deletions(-) delete mode 100644 src/backend/distributed/sql/udfs/citus_pause_node/12.1-1.sql delete mode 100644 src/backend/distributed/sql/udfs/citus_pause_node/latest.sql create mode 100644 src/backend/distributed/sql/udfs/citus_pause_node_within_txn/12.1-1.sql create mode 100644 src/backend/distributed/sql/udfs/citus_pause_node_within_txn/latest.sql diff --git a/src/backend/distributed/metadata/node_metadata.c b/src/backend/distributed/metadata/node_metadata.c index 36f5c2a47..44e80404c 100644 --- a/src/backend/distributed/metadata/node_metadata.c +++ b/src/backend/distributed/metadata/node_metadata.c @@ -152,7 +152,7 @@ PG_FUNCTION_INFO_V1(master_disable_node); PG_FUNCTION_INFO_V1(citus_activate_node); PG_FUNCTION_INFO_V1(master_activate_node); PG_FUNCTION_INFO_V1(citus_update_node); -PG_FUNCTION_INFO_V1(citus_pause_node); +PG_FUNCTION_INFO_V1(citus_pause_node_within_txn); PG_FUNCTION_INFO_V1(master_update_node); PG_FUNCTION_INFO_V1(get_shard_id_for_distribution_column); PG_FUNCTION_INFO_V1(citus_nodename_for_nodeid); @@ -1332,7 +1332,7 @@ citus_update_node(PG_FUNCTION_ARGS) Datum -citus_pause_node(PG_FUNCTION_ARGS) +citus_pause_node_within_txn(PG_FUNCTION_ARGS) { CheckCitusVersion(ERROR); diff --git a/src/backend/distributed/sql/citus--12.0-1--12.1-1.sql b/src/backend/distributed/sql/citus--12.0-1--12.1-1.sql index d314d0b90..c66860832 100644 --- a/src/backend/distributed/sql/citus--12.0-1--12.1-1.sql +++ b/src/backend/distributed/sql/citus--12.0-1--12.1-1.sql @@ -1,6 +1,6 @@ -- citus--12.0-1--12.1-1 -#include "udfs/citus_pause_node/12.1-1.sql" +#include "udfs/citus_pause_node_within_txn/12.1-1.sql" diff --git a/src/backend/distributed/sql/downgrades/citus--12.1-1--12.0-1.sql b/src/backend/distributed/sql/downgrades/citus--12.1-1--12.0-1.sql index 6088c9677..652b53cb1 100644 --- a/src/backend/distributed/sql/downgrades/citus--12.1-1--12.0-1.sql +++ b/src/backend/distributed/sql/downgrades/citus--12.1-1--12.0-1.sql @@ -1,4 +1,4 @@ -- citus--12.1-1--12.0-1 -- this is an empty downgrade path since citus--12.0-1--12.1-1.sql is empty for now -DROP FUNCTION pg_catalog.citus_pause_node(int); +DROP FUNCTION pg_catalog.citus_pause_node_within_txn(int); diff --git a/src/backend/distributed/sql/udfs/citus_pause_node/12.1-1.sql b/src/backend/distributed/sql/udfs/citus_pause_node/12.1-1.sql deleted file mode 100644 index b34961492..000000000 --- a/src/backend/distributed/sql/udfs/citus_pause_node/12.1-1.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE FUNCTION pg_catalog.citus_pause_node(node_id int) - RETURNS void - LANGUAGE C STRICT - AS 'MODULE_PATHNAME', $$citus_pause_node$$; - -COMMENT ON FUNCTION pg_catalog.citus_pause_node(node_id int) - IS 'pauses node with given id which leads to add lock in tables and prevent any queries to be executed on that node'; - -REVOKE ALL ON FUNCTION pg_catalog.citus_pause_node(int) FROM PUBLIC; diff --git a/src/backend/distributed/sql/udfs/citus_pause_node/latest.sql b/src/backend/distributed/sql/udfs/citus_pause_node/latest.sql deleted file mode 100644 index b34961492..000000000 --- a/src/backend/distributed/sql/udfs/citus_pause_node/latest.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE FUNCTION pg_catalog.citus_pause_node(node_id int) - RETURNS void - LANGUAGE C STRICT - AS 'MODULE_PATHNAME', $$citus_pause_node$$; - -COMMENT ON FUNCTION pg_catalog.citus_pause_node(node_id int) - IS 'pauses node with given id which leads to add lock in tables and prevent any queries to be executed on that node'; - -REVOKE ALL ON FUNCTION pg_catalog.citus_pause_node(int) FROM PUBLIC; diff --git a/src/backend/distributed/sql/udfs/citus_pause_node_within_txn/12.1-1.sql b/src/backend/distributed/sql/udfs/citus_pause_node_within_txn/12.1-1.sql new file mode 100644 index 000000000..298263b52 --- /dev/null +++ b/src/backend/distributed/sql/udfs/citus_pause_node_within_txn/12.1-1.sql @@ -0,0 +1,9 @@ +CREATE FUNCTION pg_catalog.citus_pause_node_within_txn(node_id int) + RETURNS void + LANGUAGE C STRICT + AS 'MODULE_PATHNAME', $$citus_pause_node_within_txn$$; + +COMMENT ON FUNCTION pg_catalog.citus_pause_node_within_txn(node_id int) + IS 'pauses node with given id which leads to add lock in tables and prevent any queries to be executed on that node'; + +REVOKE ALL ON FUNCTION pg_catalog.citus_pause_node_within_txn(int) FROM PUBLIC; diff --git a/src/backend/distributed/sql/udfs/citus_pause_node_within_txn/latest.sql b/src/backend/distributed/sql/udfs/citus_pause_node_within_txn/latest.sql new file mode 100644 index 000000000..298263b52 --- /dev/null +++ b/src/backend/distributed/sql/udfs/citus_pause_node_within_txn/latest.sql @@ -0,0 +1,9 @@ +CREATE FUNCTION pg_catalog.citus_pause_node_within_txn(node_id int) + RETURNS void + LANGUAGE C STRICT + AS 'MODULE_PATHNAME', $$citus_pause_node_within_txn$$; + +COMMENT ON FUNCTION pg_catalog.citus_pause_node_within_txn(node_id int) + IS 'pauses node with given id which leads to add lock in tables and prevent any queries to be executed on that node'; + +REVOKE ALL ON FUNCTION pg_catalog.citus_pause_node_within_txn(int) FROM PUBLIC; diff --git a/src/test/regress/expected/isolation_citus_pause_node.out b/src/test/regress/expected/isolation_citus_pause_node.out index 18371b724..231b777cf 100644 --- a/src/test/regress/expected/isolation_citus_pause_node.out +++ b/src/test/regress/expected/isolation_citus_pause_node.out @@ -26,7 +26,7 @@ BEGIN -- Get the node id for the shard id SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1; -- Pause the node - perform pg_catalog.citus_pause_node(v_node_id) ; + perform pg_catalog.citus_pause_node_within_txn(v_node_id) ; END; $$ LANGUAGE plpgsql; @@ -50,13 +50,13 @@ step s2-insert-distributed: -- If we reach this point, the INSERT statement was successful v_insert_successful := TRUE; IF v_insert_successful THEN - RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node could not get the lock.'; + RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node_within_txn could not get the lock.'; END IF; -- You can add additional processing here if needed EXCEPTION WHEN query_canceled THEN -- The INSERT statement was canceled due to timeout - RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node was able to get the lock.'; + RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock.'; WHEN OTHERS THEN -- Any other exception raised during the INSERT statement RAISE; @@ -65,7 +65,7 @@ step s2-insert-distributed: LANGUAGE plpgsql; step s2-insert-distributed: <... completed> -s2: NOTICE: query_canceled exception raised. This means that citus_pause_node was able to get the lock. +s2: NOTICE: query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock. step s2-end: COMMIT; @@ -99,7 +99,7 @@ BEGIN -- Get the node id for the shard id SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1; -- Pause the node - perform pg_catalog.citus_pause_node(v_node_id) ; + perform pg_catalog.citus_pause_node_within_txn(v_node_id) ; END; $$ LANGUAGE plpgsql; @@ -123,13 +123,13 @@ BEGIN -- If we reach this point, the DELETE statement was successful v_delete_successful := TRUE; IF v_delete_successful THEN - RAISE NOTICE 'DELETE statement completed successfully. This means that citus_pause_node could not get the lock.'; + RAISE NOTICE 'DELETE statement completed successfully. This means that citus_pause_node_within_txn could not get the lock.'; END IF; -- You can add additional processing here if needed EXCEPTION WHEN query_canceled THEN -- The INSERT statement was canceled due to timeout - RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node was able to get the lock.'; + RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock.'; WHEN OTHERS THEN -- Any other exception raised during the INSERT statement RAISE; @@ -138,7 +138,7 @@ $$ LANGUAGE plpgsql; step s2-delete-distributed: <... completed> -s2: NOTICE: query_canceled exception raised. This means that citus_pause_node was able to get the lock. +s2: NOTICE: query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock. step s2-end: COMMIT; @@ -172,7 +172,7 @@ BEGIN -- Get the node id for the shard id SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1; -- Pause the node - perform pg_catalog.citus_pause_node(v_node_id) ; + perform pg_catalog.citus_pause_node_within_txn(v_node_id) ; END; $$ LANGUAGE plpgsql; @@ -223,7 +223,7 @@ BEGIN -- Get the node id for the shard id SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1; -- Pause the node - perform pg_catalog.citus_pause_node(v_node_id) ; + perform pg_catalog.citus_pause_node_within_txn(v_node_id) ; END; $$ LANGUAGE plpgsql; @@ -247,11 +247,11 @@ BEGIN -- If we reach this point, the INSERT statement was successful v_insert_successful := TRUE; IF v_insert_successful THEN - RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node could not get the lock.'; + RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node_within_txn could not get the lock.'; END IF; EXCEPTION WHEN query_canceled THEN -- The INSERT statement was canceled due to timeout - RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node was able to get the lock.'; + RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock.'; WHEN OTHERS THEN -- Any other exception raised during the INSERT statement RAISE; @@ -260,7 +260,7 @@ $$ LANGUAGE plpgsql; step s2-insert-reference: <... completed> -s2: NOTICE: query_canceled exception raised. This means that citus_pause_node was able to get the lock. +s2: NOTICE: query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock. step s2-end: COMMIT; @@ -294,7 +294,7 @@ BEGIN -- Get the node id for the shard id SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1; -- Pause the node - perform pg_catalog.citus_pause_node(v_node_id) ; + perform pg_catalog.citus_pause_node_within_txn(v_node_id) ; END; $$ LANGUAGE plpgsql; @@ -323,7 +323,7 @@ BEGIN -- Get the node id for the shard id SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1; -- Pause the node - perform pg_catalog.citus_pause_node(v_node_id) ; + perform pg_catalog.citus_pause_node_within_txn(v_node_id) ; END; $$ LANGUAGE plpgsql; @@ -348,7 +348,7 @@ DECLARE v_expected_exception_message text := ''; BEGIN select nextval('pg_dist_node_nodeid_seq')::int into v_node_id; - select citus_pause_node(v_node_id); + select citus_pause_node_within_txn(v_node_id); EXCEPTION WHEN SQLSTATE 'P0002' THEN GET STACKED DIAGNOSTICS v_exception_message = MESSAGE_TEXT; diff --git a/src/test/regress/spec/isolation_citus_pause_node.spec b/src/test/regress/spec/isolation_citus_pause_node.spec index 8b8dcded9..152d62bd0 100644 --- a/src/test/regress/spec/isolation_citus_pause_node.spec +++ b/src/test/regress/spec/isolation_citus_pause_node.spec @@ -59,7 +59,7 @@ step "s1-node-not-found" v_expected_exception_message text := ''; BEGIN select nextval('pg_dist_node_nodeid_seq')::int into v_node_id; - select citus_pause_node(v_node_id) ; + select citus_pause_node_within_txn(v_node_id) ; EXCEPTION WHEN SQLSTATE 'P0002' THEN GET STACKED DIAGNOSTICS v_exception_message = MESSAGE_TEXT; @@ -98,7 +98,7 @@ step "s1-pause-node" -- Pause the node - perform pg_catalog.citus_pause_node(v_node_id) ; + perform pg_catalog.citus_pause_node_within_txn(v_node_id) ; END; $$ LANGUAGE plpgsql; @@ -136,7 +136,7 @@ step "s2-insert-distributed" v_insert_successful := TRUE; IF v_insert_successful THEN - RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node could not get the lock.'; + RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node_within_txn could not get the lock.'; END IF; @@ -144,7 +144,7 @@ step "s2-insert-distributed" EXCEPTION WHEN query_canceled THEN -- The INSERT statement was canceled due to timeout - RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node was able to get the lock.'; + RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock.'; WHEN OTHERS THEN -- Any other exception raised during the INSERT statement RAISE; @@ -172,12 +172,12 @@ step "s2-insert-reference"{ v_insert_successful := TRUE; IF v_insert_successful THEN - RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node could not get the lock.'; + RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node_within_txn could not get the lock.'; END IF; EXCEPTION WHEN query_canceled THEN -- The INSERT statement was canceled due to timeout - RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node was able to get the lock.'; + RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock.'; WHEN OTHERS THEN -- Any other exception raised during the INSERT statement RAISE; @@ -209,13 +209,13 @@ step "s2-delete-distributed"{ v_delete_successful := TRUE; IF v_delete_successful THEN - RAISE NOTICE 'DELETE statement completed successfully. This means that citus_pause_node could not get the lock.'; + RAISE NOTICE 'DELETE statement completed successfully. This means that citus_pause_node_within_txn could not get the lock.'; END IF; -- You can add additional processing here if needed EXCEPTION WHEN query_canceled THEN -- The INSERT statement was canceled due to timeout - RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node was able to get the lock.'; + RAISE NOTICE 'query_canceled exception raised. This means that citus_pause_node_within_txn was able to get the lock.'; WHEN OTHERS THEN -- Any other exception raised during the INSERT statement RAISE;