Move dist_internal functions to _timescaledb_functions schema

To increase schema security we do not want to mix our own internal
objects with user objects. Since chunks are created in the
_timescaledb_internal schema our internal functions should live in
a different dedicated schema. This patch make the necessary
adjustments for the following functions:

- set_dist_id(uuid)
- set_peer_dist_id(uuid)
- validate_as_data_node()
- show_connection_cache()
- ping_data_node(name, interval)
- remote_txn_heal_data_node(oid)
This commit is contained in:
Sven Klemm 2023-08-21 18:55:35 +02:00 committed by Sven Klemm
parent e99832727a
commit 4256009e4c
21 changed files with 189 additions and 175 deletions

View File

@ -3,10 +3,10 @@
-- LICENSE-APACHE for a copy of the license.
-- Check if a data node is up
CREATE OR REPLACE FUNCTION _timescaledb_internal.ping_data_node(node_name NAME, timeout INTERVAL = NULL) RETURNS BOOLEAN
CREATE OR REPLACE FUNCTION _timescaledb_functions.ping_data_node(node_name NAME, timeout INTERVAL = NULL) RETURNS BOOLEAN
AS '@MODULE_PATHNAME@', 'ts_data_node_ping' LANGUAGE C VOLATILE;
CREATE OR REPLACE FUNCTION _timescaledb_internal.remote_txn_heal_data_node(foreign_server_oid oid)
CREATE OR REPLACE FUNCTION _timescaledb_functions.remote_txn_heal_data_node(foreign_server_oid oid)
RETURNS INT
AS '@MODULE_PATHNAME@', 'ts_remote_txn_heal_data_node'
LANGUAGE C STRICT;

View File

@ -2,18 +2,18 @@
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
CREATE OR REPLACE FUNCTION _timescaledb_internal.set_dist_id(dist_id UUID) RETURNS BOOL
CREATE OR REPLACE FUNCTION _timescaledb_functions.set_dist_id(dist_id UUID) RETURNS BOOL
AS '@MODULE_PATHNAME@', 'ts_dist_set_id' LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION _timescaledb_internal.set_peer_dist_id(dist_id UUID) RETURNS BOOL
CREATE OR REPLACE FUNCTION _timescaledb_functions.set_peer_dist_id(dist_id UUID) RETURNS BOOL
AS '@MODULE_PATHNAME@', 'ts_dist_set_peer_id' LANGUAGE C VOLATILE STRICT;
-- Function to validate that a node has local settings to function as
-- a data node. Throws error if validation fails.
CREATE OR REPLACE FUNCTION _timescaledb_internal.validate_as_data_node() RETURNS void
CREATE OR REPLACE FUNCTION _timescaledb_functions.validate_as_data_node() RETURNS void
AS '@MODULE_PATHNAME@', 'ts_dist_validate_as_data_node' LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION _timescaledb_internal.show_connection_cache()
CREATE OR REPLACE FUNCTION _timescaledb_functions.show_connection_cache()
RETURNS TABLE (
node_name name,
user_name name,

View File

@ -57,3 +57,11 @@ ALTER FUNCTION _timescaledb_internal.to_date(bigint) SET SCHEMA _timescaledb_fun
ALTER FUNCTION _timescaledb_internal.to_interval(bigint) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.interval_to_usec(interval) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.time_to_internal(anyelement) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.set_dist_id(uuid) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.set_peer_dist_id(uuid) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.validate_as_data_node() SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.show_connection_cache() SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.ping_data_node(name, interval) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.remote_txn_heal_data_node(oid) SET SCHEMA _timescaledb_functions;

View File

@ -45,3 +45,9 @@ ALTER FUNCTION _timescaledb_functions.interval_to_usec(interval) SET SCHEMA _tim
ALTER FUNCTION _timescaledb_functions.time_to_internal(anyelement) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.subtract_integer_from_now(regclass, bigint) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.set_dist_id(uuid) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.set_peer_dist_id(uuid) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.validate_as_data_node() SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.show_connection_cache() SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.ping_data_node(name, interval) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.remote_txn_heal_data_node(oid) SET SCHEMA _timescaledb_internal;

View File

@ -491,7 +491,7 @@ static void
data_node_validate_as_data_node(TSConnection *conn)
{
PGresult *res =
remote_connection_exec(conn, "SELECT _timescaledb_internal.validate_as_data_node()");
remote_connection_exec(conn, "SELECT _timescaledb_functions.validate_as_data_node()");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
ereport(ERROR,
@ -588,7 +588,7 @@ add_distributed_id_to_data_node(TSConnection *conn)
{
Datum id_string = DirectFunctionCall1(uuid_out, dist_util_get_id());
PGresult *res = remote_connection_queryf_ok(conn,
"SELECT _timescaledb_internal.set_dist_id('%s')",
"SELECT _timescaledb_functions.set_dist_id('%s')",
DatumGetCString(id_string));
remote_result_close(res);
}

View File

@ -1356,7 +1356,7 @@ remote_connection_set_peer_dist_id(TSConnection *conn)
bool success = true;
res = remote_connection_execf(conn,
"SELECT * FROM _timescaledb_internal.set_peer_dist_id('%s')",
"SELECT * FROM _timescaledb_functions.set_peer_dist_id('%s')",
DatumGetCString(id_string));
success = PQresultStatus(res) == PGRES_TUPLES_OK;
PQclear(res);

View File

@ -668,26 +668,26 @@ SELECT * FROM _timescaledb_catalog.chunk_data_node;
----------+---------------+-----------
(0 rows)
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1');
ping_data_node
----------------
t
(1 row)
-- Ensure timeout returned by argument
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1', interval '0s');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1', interval '0s');
ping_data_node
----------------
f
(1 row)
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1', interval '3s');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1', interval '3s');
ping_data_node
----------------
t
(1 row)
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1', interval '1 day');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1', interval '1 day');
ping_data_node
----------------
t
@ -708,13 +708,13 @@ NOTICE: adding not-null constraint to column "time"
\set ON_ERROR_STOP 0
-- Throw ERROR for non-existing data node
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_123456789');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_123456789');
ERROR: server "data_node_123456789" does not exist
-- ERROR on NULL
SELECT * FROM _timescaledb_internal.ping_data_node(NULL);
SELECT * FROM _timescaledb_functions.ping_data_node(NULL);
ERROR: data node name cannot be NULL
-- ERROR when not passing TimescaleDB data node
SELECT * FROM _timescaledb_internal.ping_data_node('pg_data_node_1');
SELECT * FROM _timescaledb_functions.ping_data_node('pg_data_node_1');
ERROR: server "pg_data_node_1" does not exist
-- ERROR on attaching to non-distributed hypertable
SELECT * FROM attach_data_node('data_node_1', 'standalone');
@ -1524,23 +1524,23 @@ RESET ROLE;
DROP DATABASE :DN_DBNAME_1;
CREATE DATABASE :DN_DBNAME_1 OWNER :ROLE_1;
\c :DN_DBNAME_1
CREATE SCHEMA _timescaledb_internal;
GRANT ALL ON SCHEMA _timescaledb_internal TO :ROLE_1;
CREATE FUNCTION _timescaledb_internal.set_dist_id(uuid UUID)
CREATE SCHEMA _timescaledb_functions;
GRANT ALL ON SCHEMA _timescaledb_functions TO :ROLE_1;
CREATE FUNCTION _timescaledb_functions.set_dist_id(uuid UUID)
RETURNS BOOL LANGUAGE PLPGSQL AS
$BODY$
BEGIN
RETURN true;
END
$BODY$;
CREATE FUNCTION _timescaledb_internal.set_peer_dist_id(uuid UUID)
CREATE FUNCTION _timescaledb_functions.set_peer_dist_id(uuid UUID)
RETURNS BOOL LANGUAGE PLPGSQL AS
$BODY$
BEGIN
RETURN true;
END
$BODY$;
CREATE FUNCTION _timescaledb_internal.validate_as_data_node()
CREATE FUNCTION _timescaledb_functions.validate_as_data_node()
RETURNS BOOL LANGUAGE PLPGSQL AS
$BODY$
BEGIN

View File

@ -169,8 +169,8 @@ SELECT is_access_node_session_on_data_node();
-- Ensure peer dist id is already set and can be set only once
\set ON_ERROR_STOP 0
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_1'], $$ SELECT * FROM _timescaledb_internal.set_peer_dist_id('77348176-09da-4a80-bc78-e31bdf5e63ec'); $$);
NOTICE: [db_dist_commands_1]: SELECT * FROM _timescaledb_internal.set_peer_dist_id('77348176-09da-4a80-bc78-e31bdf5e63ec')
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_1'], $$ SELECT * FROM _timescaledb_functions.set_peer_dist_id('77348176-09da-4a80-bc78-e31bdf5e63ec'); $$);
NOTICE: [db_dist_commands_1]: SELECT * FROM _timescaledb_functions.set_peer_dist_id('77348176-09da-4a80-bc78-e31bdf5e63ec')
ERROR: [db_dist_commands_1]: distributed peer ID already set
\set ON_ERROR_STOP 1
-- Repeat is_access_node_session_on_data_node() test again, but this time using connections openned from

View File

@ -52,7 +52,7 @@ NOTICE: adding not-null constraint to column "time"
INSERT INTO testtable VALUES ('2021-09-19', 1, 13.2);
-- Should show valid connections for ROLE_1
SELECT node_name, user_name, invalidated
FROM _timescaledb_internal.show_connection_cache()
FROM _timescaledb_functions.show_connection_cache()
WHERE user_name=:'ROLE_1'
ORDER BY 1,2;
node_name | user_name | invalidated
@ -68,7 +68,7 @@ BEGIN;
-- fetch.
ALTER ROLE :ROLE_1 RENAME TO bob;
SELECT node_name, user_name, invalidated
FROM _timescaledb_internal.show_connection_cache()
FROM _timescaledb_functions.show_connection_cache()
WHERE user_name='bob'
ORDER BY 1,2;
node_name | user_name | invalidated

View File

@ -102,7 +102,7 @@ SELECT test_remote_txn_persistent_record('loopback');
SET timescaledb.enable_2pc = false;
--initially, there are no connections in the cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -117,7 +117,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (20001,1,'bleh', '2001-01-0
--expect to see one connection in transaction state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -126,7 +126,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (20001,1,'bleh', '2001-01-0
COMMIT;
--connection should remain, idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -149,7 +149,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (20002,1,'bleh', '2001-01-0
--existing connection, in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -158,7 +158,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (20002,1,'bleh', '2001-01-0
ROLLBACK;
--connection should remain, in idle state after rollback
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -178,7 +178,7 @@ ERROR: [loopback]: duplicate key value violates unique constraint "t1_pkey"
COMMIT;
-- Connection should remain after conflict, in idle state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -220,7 +220,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
-- Failed connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -262,7 +262,7 @@ BEGIN;
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -279,7 +279,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--connection failed during commit, so should be cleared from the cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -317,7 +317,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (20005,1,'bleh', '2001-01-0
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -350,7 +350,7 @@ SELECT count(*) FROM pg_prepared_xacts;
--the failed connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -373,7 +373,7 @@ ERROR: cannot prepare a transaction that modified remote tables
DELETE FROM "S 1"."T 1" where "C 1" >= 20000;
SET timescaledb.enable_2pc = true;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -390,7 +390,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-0
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -399,7 +399,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-0
COMMIT;
--connection should remain in idle state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -428,7 +428,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (11001,1,'bleh', '2001-01-0
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -437,7 +437,7 @@ NOTICE: [loopback]: INSERT INTO "S 1"."T 1" VALUES (11001,1,'bleh', '2001-01-0
ROLLBACK;
--rolled back transaction, but connection should remain in idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -463,7 +463,7 @@ ERROR: [loopback]: duplicate key value violates unique constraint "t1_pkey"
COMMIT;
--connection should remain in idle after constraint violation
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -504,7 +504,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--the connection was killed, so should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -554,7 +554,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--the connection should be cleared from the cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -567,7 +567,7 @@ SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10003;
--during waiting-prepare-transaction the data node process could die before or after
--executing the prepare transaction. To be safe to either case rollback using heal_server.
SELECT count(*) FROM _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
count
-------
1
@ -620,7 +620,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -640,11 +640,11 @@ SELECT count(*) FROM pg_prepared_xacts;
--this fails because heal cannot run inside txn block
BEGIN;
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
ERROR: remote_txn_heal_data_node cannot run inside a transaction block
COMMIT;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -656,7 +656,7 @@ select count(*) from _timescaledb_catalog.remote_txn;
(1 row)
--this resolves the previous txn
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
remote_txn_heal_data_node
---------------------------
1
@ -713,7 +713,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -732,7 +732,7 @@ SELECT count(*) FROM pg_prepared_xacts;
(1 row)
--this resolves the previous txn
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
remote_txn_heal_data_node
---------------------------
1
@ -757,7 +757,7 @@ select count(*) from _timescaledb_catalog.remote_txn;
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -796,7 +796,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--at this point the commit prepared might or might not have been executed before
--the data node process was killed.
--but in any case, healing the server will bring it into a known state
SELECT count(*) FROM _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
count
-------
1
@ -804,7 +804,7 @@ SELECT count(*) FROM _timescaledb_internal.remote_txn_heal_data_node((SELECT OID
--heal does not use the connection cache, so unaffected
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -844,7 +844,7 @@ ERROR: [loopback]: duplicate key value violates unique constraint "t1_pkey"
COMMIT;
--unique constraint violation, connection should remain
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -861,7 +861,7 @@ NOTICE: [loopback]: PREPARE prep_1 AS SELECT 1
--connection in transaction state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 2 | f
@ -875,7 +875,7 @@ ERROR: [loopback]: duplicate key value violates unique constraint "t1_pkey"
--for correctness, the connection must remain after rollback since
--the transaction is still ongoing
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -887,7 +887,7 @@ ERROR: [loopback]: duplicate key value violates unique constraint "t1_pkey"
COMMIT;
--connection should remain and be idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -918,7 +918,7 @@ BEGIN;
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -929,7 +929,7 @@ ERROR: [loopback]: duplicate key value violates unique constraint "t1_pkey"
RESET client_min_messages;
--connection should be removed since PREPARE TRANSACTION failed
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -963,7 +963,7 @@ BEGIN;
--Both connections in transaction state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -975,7 +975,7 @@ ERROR: [loopback2]: duplicate key value violates unique constraint "t1_pkey"
RESET client_min_messages;
--one connection should remain and be idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -1021,7 +1021,7 @@ BEGIN;
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -1033,7 +1033,7 @@ ERROR: [loopback2]: duplicate key value violates unique constraint "t1_pkey"
RESET client_min_messages;
--failed connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -1050,7 +1050,7 @@ SELECT count(*) FROM pg_prepared_xacts;
1
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
remote_txn_heal_data_node
---------------------------
1
@ -1070,7 +1070,7 @@ SELECT count(*) FROM pg_prepared_xacts;
--heal is not using the connection cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
(0 rows)
@ -1092,7 +1092,7 @@ NOTICE: [loopback2]: INSERT INTO "S 1"."T 1" VALUES (10013,1,'bleh', '2001-01-
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -1108,7 +1108,7 @@ NOTICE: [loopback2]: INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -1119,7 +1119,7 @@ NOTICE: [loopback2]: INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-
-- For correctness, both connections should remain in order to
-- continue the transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 1 | f
@ -1141,7 +1141,7 @@ NOTICE: [loopback2]: INSERT INTO "S 1"."T 1" VALUES (10015,1,'bleh', '2001-01-
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 2 | f
@ -1150,7 +1150,7 @@ NOTICE: [loopback2]: INSERT INTO "S 1"."T 1" VALUES (10015,1,'bleh', '2001-01-
COMMIT;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | IDLE | 0 | f
@ -1202,7 +1202,7 @@ BEGIN;
(1 row)
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | OK | INTRANS | 2 | f
@ -1211,7 +1211,7 @@ BEGIN;
ROLLBACK TO SAVEPOINT save_1;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback | BAD | UNKNOWN | 1 | t
@ -1225,7 +1225,7 @@ ERROR: current transaction is aborted, commands ignored until end of transactio
COMMIT;
RESET client_min_messages;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
node_name | connection_status | transaction_status | transaction_depth | processing
-----------+-------------------+--------------------+-------------------+------------
loopback2 | OK | IDLE | 0 | f

View File

@ -76,19 +76,19 @@ SELECT count(*) FROM _timescaledb_catalog.remote_txn;
3
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
remote_txn_heal_data_node
---------------------------
1
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
remote_txn_heal_data_node
---------------------------
0
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
remote_txn_heal_data_node
---------------------------
0
@ -160,7 +160,7 @@ SELECT create_prepared_record();
--inject errors in the GID and test "commit" resolution for it
SET timescaledb.debug_inject_gid_error TO 'commit';
--heal should error out and the prepared transaction should still be visible
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
WARNING: could not commit prepared transaction on data node "loopback2"
remote_txn_heal_data_node
---------------------------
@ -199,7 +199,7 @@ SELECT create_prepared_record();
--inject errors in the GID and test "abort" resolution for it
SET timescaledb.debug_inject_gid_error TO 'abort';
--heal should error out and the prepared transaction should still be visible
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
WARNING: could not roll back prepared transaction on data node "loopback2"
remote_txn_heal_data_node
---------------------------
@ -239,7 +239,7 @@ SELECT create_prepared_record();
--test "inprogress" resolution for the prepared 2PC
SET timescaledb.debug_inject_gid_error TO 'inprogress';
--heal will not error out but the prepared transaction should still be visible
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
remote_txn_heal_data_node
---------------------------
1
@ -278,19 +278,19 @@ SELECT create_prepared_record();
--set to any random value so that it does not have any effect and allows healing
SET timescaledb.debug_inject_gid_error TO 'ignored';
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
remote_txn_heal_data_node
---------------------------
2
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
remote_txn_heal_data_node
---------------------------
0
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
remote_txn_heal_data_node
---------------------------
0
@ -326,21 +326,21 @@ SELECT count(*) FROM _timescaledb_catalog.remote_txn;
BEGIN;
INSERT INTO public.table_modified_by_txns VALUES ('non-ts-txn');
PREPARE TRANSACTION 'non-ts-txn';
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
NOTICE: skipping 1 non-TimescaleDB prepared transaction
remote_txn_heal_data_node
---------------------------
0
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
NOTICE: skipping 1 non-TimescaleDB prepared transaction
remote_txn_heal_data_node
---------------------------
0
(1 row)
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
NOTICE: skipping 1 non-TimescaleDB prepared transaction
remote_txn_heal_data_node
---------------------------
@ -386,7 +386,7 @@ CREATE TABLE unused(id int);
PREPARE TRANSACTION 'ts-1-10-20-30';
\c :TEST_DBNAME :ROLE_SUPERUSER
-- should not fail
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
remote_txn_heal_data_node
---------------------------
0

View File

@ -103,7 +103,7 @@ RESET statement_timeout;
\set ON_ERROR_STOP 1
-- Data node connections should be IDLE
SELECT node_name, database, connection_status, transaction_status, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1;
node_name | database | connection_status | transaction_status | processing
-------------+-------------+-------------------+--------------------+------------
data_node_1 | data_node_1 | OK | IDLE | f

View File

@ -40,8 +40,13 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_functions.interval_to_usec(interval)
_timescaledb_functions.last_combinefunc(internal,internal)
_timescaledb_functions.last_sfunc(internal,anyelement,"any")
_timescaledb_functions.ping_data_node(name,interval)
_timescaledb_functions.remote_txn_heal_data_node(oid)
_timescaledb_functions.rxid_in(cstring)
_timescaledb_functions.rxid_out(rxid)
_timescaledb_functions.set_dist_id(uuid)
_timescaledb_functions.set_peer_dist_id(uuid)
_timescaledb_functions.show_connection_cache()
_timescaledb_functions.subtract_integer_from_now(regclass,bigint)
_timescaledb_functions.time_to_internal(anyelement)
_timescaledb_functions.to_date(bigint)
@ -49,6 +54,7 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_functions.to_timestamp(bigint)
_timescaledb_functions.to_timestamp_without_timezone(bigint)
_timescaledb_functions.to_unix_microseconds(timestamp with time zone)
_timescaledb_functions.validate_as_data_node()
_timescaledb_internal.alter_job_set_hypertable_id(integer,regclass)
_timescaledb_internal.attach_osm_table_chunk(regclass,regclass)
_timescaledb_internal.cagg_migrate_create_plan(_timescaledb_catalog.continuous_agg,text,boolean,boolean)
@ -116,7 +122,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_internal.invalidation_process_hypertable_log(integer,integer,regtype,integer[],bigint[],bigint[],text[])
_timescaledb_internal.materialization_invalidation_log_delete(integer)
_timescaledb_internal.partialize_agg(anyelement)
_timescaledb_internal.ping_data_node(name,interval)
_timescaledb_internal.policy_compression(integer,jsonb)
_timescaledb_internal.policy_compression_check(jsonb)
_timescaledb_internal.policy_compression_execute(integer,integer,anyelement,integer,boolean,boolean)
@ -133,18 +138,13 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_internal.range_value_to_pretty(bigint,regtype)
_timescaledb_internal.recompress_chunk_segmentwise(regclass,boolean)
_timescaledb_internal.relation_size(regclass)
_timescaledb_internal.remote_txn_heal_data_node(oid)
_timescaledb_internal.restart_background_workers()
_timescaledb_internal.set_chunk_default_data_node(regclass,name)
_timescaledb_internal.set_dist_id(uuid)
_timescaledb_internal.set_peer_dist_id(uuid)
_timescaledb_internal.show_chunk(regclass)
_timescaledb_internal.show_connection_cache()
_timescaledb_internal.start_background_workers()
_timescaledb_internal.stop_background_workers()
_timescaledb_internal.tsl_loaded()
_timescaledb_internal.unfreeze_chunk(regclass)
_timescaledb_internal.validate_as_data_node()
_timescaledb_internal.wait_subscription_sync(name,name,integer,numeric)
debug_waitpoint_enable(text)
debug_waitpoint_id(text)

View File

@ -79,4 +79,4 @@ RESET statement_timeout;
\set ON_ERROR_STOP 1
-- Data node connections should be IDLE
SELECT node_name, database, connection_status, transaction_status, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1;

View File

@ -338,12 +338,12 @@ SELECT * FROM attach_data_node('data_node_1', 'disttable');
SELECT * FROM _timescaledb_catalog.hypertable_data_node;
SELECT * FROM _timescaledb_catalog.chunk_data_node;
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1');
-- Ensure timeout returned by argument
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1', interval '0s');
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1', interval '3s');
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_1', interval '1 day');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1', interval '0s');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1', interval '3s');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_1', interval '1 day');
-- Create data node referencing postgres_fdw
RESET ROLE;
@ -355,11 +355,11 @@ CREATE TABLE standalone(time TIMESTAMPTZ, device INT, value FLOAT);
SELECT * FROM create_hypertable('standalone','time');
\set ON_ERROR_STOP 0
-- Throw ERROR for non-existing data node
SELECT * FROM _timescaledb_internal.ping_data_node('data_node_123456789');
SELECT * FROM _timescaledb_functions.ping_data_node('data_node_123456789');
-- ERROR on NULL
SELECT * FROM _timescaledb_internal.ping_data_node(NULL);
SELECT * FROM _timescaledb_functions.ping_data_node(NULL);
-- ERROR when not passing TimescaleDB data node
SELECT * FROM _timescaledb_internal.ping_data_node('pg_data_node_1');
SELECT * FROM _timescaledb_functions.ping_data_node('pg_data_node_1');
-- ERROR on attaching to non-distributed hypertable
SELECT * FROM attach_data_node('data_node_1', 'standalone');
\set ON_ERROR_STOP 1
@ -698,10 +698,10 @@ DROP DATABASE :DN_DBNAME_1;
CREATE DATABASE :DN_DBNAME_1 OWNER :ROLE_1;
\c :DN_DBNAME_1
CREATE SCHEMA _timescaledb_internal;
GRANT ALL ON SCHEMA _timescaledb_internal TO :ROLE_1;
CREATE SCHEMA _timescaledb_functions;
GRANT ALL ON SCHEMA _timescaledb_functions TO :ROLE_1;
CREATE FUNCTION _timescaledb_internal.set_dist_id(uuid UUID)
CREATE FUNCTION _timescaledb_functions.set_dist_id(uuid UUID)
RETURNS BOOL LANGUAGE PLPGSQL AS
$BODY$
BEGIN
@ -709,7 +709,7 @@ BEGIN
END
$BODY$;
CREATE FUNCTION _timescaledb_internal.set_peer_dist_id(uuid UUID)
CREATE FUNCTION _timescaledb_functions.set_peer_dist_id(uuid UUID)
RETURNS BOOL LANGUAGE PLPGSQL AS
$BODY$
BEGIN
@ -717,7 +717,7 @@ BEGIN
END
$BODY$;
CREATE FUNCTION _timescaledb_internal.validate_as_data_node()
CREATE FUNCTION _timescaledb_functions.validate_as_data_node()
RETURNS BOOL LANGUAGE PLPGSQL AS
$BODY$
BEGIN

View File

@ -103,7 +103,7 @@ SELECT is_access_node_session_on_data_node();
-- Ensure peer dist id is already set and can be set only once
\set ON_ERROR_STOP 0
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_1'], $$ SELECT * FROM _timescaledb_internal.set_peer_dist_id('77348176-09da-4a80-bc78-e31bdf5e63ec'); $$);
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_1'], $$ SELECT * FROM _timescaledb_functions.set_peer_dist_id('77348176-09da-4a80-bc78-e31bdf5e63ec'); $$);
\set ON_ERROR_STOP 1
-- Repeat is_access_node_session_on_data_node() test again, but this time using connections openned from

View File

@ -40,7 +40,7 @@ INSERT INTO testtable VALUES ('2021-09-19', 1, 13.2);
-- Should show valid connections for ROLE_1
SELECT node_name, user_name, invalidated
FROM _timescaledb_internal.show_connection_cache()
FROM _timescaledb_functions.show_connection_cache()
WHERE user_name=:'ROLE_1'
ORDER BY 1,2;
RESET ROLE;
@ -51,7 +51,7 @@ BEGIN;
-- fetch.
ALTER ROLE :ROLE_1 RENAME TO bob;
SELECT node_name, user_name, invalidated
FROM _timescaledb_internal.show_connection_cache()
FROM _timescaledb_functions.show_connection_cache()
WHERE user_name='bob'
ORDER BY 1,2;
ROLLBACK;

View File

@ -88,17 +88,17 @@ SET timescaledb.enable_2pc = false;
--initially, there are no connections in the cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (20001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
--expect to see one connection in transaction state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
COMMIT;
--connection should remain, idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 20001;
@ -107,12 +107,12 @@ BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (20002,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
--existing connection, in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
ROLLBACK;
--connection should remain, in idle state after rollback
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 20002;
--constraint violation
@ -122,7 +122,7 @@ COMMIT;
-- Connection should remain after conflict, in idle state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--the next few statements inject faults before the commit. They should all fail
--and be rolled back with no unresolved state
@ -140,7 +140,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
-- Failed connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 20003;
SELECT count(*) FROM pg_prepared_xacts;
@ -155,14 +155,14 @@ BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (20004,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
COMMIT;
RESET client_min_messages;
SELECT debug_waitpoint_release('remote_conn_xact_end');
--connection failed during commit, so should be cleared from the cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--during waiting-commit the data node process could die before or after
--executing the commit on the remote node. So the behaviour here is non-deterministic
@ -177,7 +177,7 @@ BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (20005,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
-- since the error messages/warnings from this ROLLBACK varies between
-- platforms/environments we remove it from test output and show
@ -195,7 +195,7 @@ SELECT count(*) FROM pg_prepared_xacts;
--the failed connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--block preparing transactions on the access node
BEGIN;
@ -211,19 +211,19 @@ DELETE FROM "S 1"."T 1" where "C 1" >= 20000;
SET timescaledb.enable_2pc = true;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--simple commit
BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
COMMIT;
--connection should remain in idle state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10001;
SELECT count(*) FROM pg_prepared_xacts;
@ -232,12 +232,12 @@ BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (11001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
--connection in transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
ROLLBACK;
--rolled back transaction, but connection should remain in idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 11001;
SELECT count(*) FROM pg_prepared_xacts;
@ -248,7 +248,7 @@ COMMIT;
--connection should remain in idle after constraint violation
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--the next few statements inject faults before the commit. They should all fail
--and be rolled back with no unresolved state
@ -267,7 +267,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--the connection was killed, so should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10002;
SELECT count(*) FROM pg_prepared_xacts;
@ -287,13 +287,13 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--the connection should be cleared from the cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10003;
--during waiting-prepare-transaction the data node process could die before or after
--executing the prepare transaction. To be safe to either case rollback using heal_server.
SELECT count(*) FROM _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM pg_prepared_xacts;
SELECT count(*) from _timescaledb_catalog.remote_txn;
@ -315,7 +315,7 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--unresolved state shown here
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10004;
@ -323,16 +323,16 @@ SELECT count(*) FROM pg_prepared_xacts;
--this fails because heal cannot run inside txn block
BEGIN;
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
COMMIT;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
select count(*) from _timescaledb_catalog.remote_txn;
--this resolves the previous txn
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10004;
SELECT count(*) FROM pg_prepared_xacts;
--cleanup also happened
@ -352,19 +352,19 @@ COMMIT;
SELECT debug_waitpoint_release('remote_conn_xact_end');
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--unresolved state shown here
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10006;
SELECT count(*) FROM pg_prepared_xacts;
--this resolves the previous txn
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10006;
SELECT count(*) FROM pg_prepared_xacts;
select count(*) from _timescaledb_catalog.remote_txn;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
BEGIN;
SELECT remote_node_killer_set_event('waiting-commit-prepared','loopback');
@ -382,11 +382,11 @@ SELECT debug_waitpoint_release('remote_conn_xact_end');
--at this point the commit prepared might or might not have been executed before
--the data node process was killed.
--but in any case, healing the server will bring it into a known state
SELECT count(*) FROM _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
--heal does not use the connection cache, so unaffected
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10005;
SELECT count(*) FROM pg_prepared_xacts;
select count(*) from _timescaledb_catalog.remote_txn;
@ -400,7 +400,7 @@ BEGIN;
COMMIT;
--unique constraint violation, connection should remain
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
BEGIN;
SAVEPOINT save_1;
@ -408,7 +408,7 @@ BEGIN;
--connection in transaction state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--generate a unique violation
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
@ -417,14 +417,14 @@ BEGIN;
--for correctness, the connection must remain after rollback since
--the transaction is still ongoing
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (81,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
COMMIT;
--connection should remain and be idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 81;
@ -443,13 +443,13 @@ SET client_min_messages TO error;
BEGIN;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
COMMIT;
RESET client_min_messages;
--connection should be removed since PREPARE TRANSACTION failed
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM pg_prepared_xacts;
--test ROLLBACK TRANSACTION
@ -466,13 +466,13 @@ BEGIN;
--Both connections in transaction state
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
COMMIT;
RESET client_min_messages;
--one connection should remain and be idle
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10010;
SELECT count(*) FROM pg_prepared_xacts;
@ -490,23 +490,23 @@ BEGIN;
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
COMMIT;
RESET client_min_messages;
--failed connection should be cleared
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10011;
SELECT count(*) FROM pg_prepared_xacts;
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" = 10011;
SELECT count(*) FROM pg_prepared_xacts;
--heal is not using the connection cache
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
--test simple subtrans abort.
BEGIN;
@ -514,26 +514,26 @@ BEGIN;
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10013,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SAVEPOINT save_1;
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
ROLLBACK TO SAVEPOINT save_1;
-- For correctness, both connections should remain in order to
-- continue the transaction
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10014,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10015,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
COMMIT;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" > 10011;
SELECT count(*) FROM pg_prepared_xacts;
@ -550,17 +550,17 @@ BEGIN;
SAVEPOINT save_1;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10001,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
ROLLBACK TO SAVEPOINT save_1;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT test.remote_exec('{loopback}', $$ INSERT INTO "S 1"."T 1" VALUES (10019,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
SELECT test.remote_exec('{loopback2}', $$ INSERT INTO "S 1"."T 1" VALUES (10020,1,'bleh', '2001-01-01', '2001-01-01', 'bleh') $$);
COMMIT;
RESET client_min_messages;
SELECT node_name, connection_status, transaction_status, transaction_depth, processing
FROM _timescaledb_internal.show_connection_cache() ORDER BY 1,4;
FROM _timescaledb_functions.show_connection_cache() ORDER BY 1,4;
SELECT count(*) FROM "S 1"."T 1" WHERE "C 1" > 10016;
SELECT count(*) FROM pg_prepared_xacts;

View File

@ -51,9 +51,9 @@ SELECT * FROM table_modified_by_txns;
SELECT count(*) FROM pg_prepared_xacts;
SELECT count(*) FROM _timescaledb_catalog.remote_txn;
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT * FROM table_modified_by_txns;
SELECT count(*) FROM pg_prepared_xacts;
@ -75,7 +75,7 @@ SELECT create_prepared_record();
--inject errors in the GID and test "commit" resolution for it
SET timescaledb.debug_inject_gid_error TO 'commit';
--heal should error out and the prepared transaction should still be visible
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT * FROM table_modified_by_txns;
SELECT count(*) FROM pg_prepared_xacts;
SELECT count(*) FROM _timescaledb_catalog.remote_txn;
@ -85,7 +85,7 @@ SELECT create_prepared_record();
--inject errors in the GID and test "abort" resolution for it
SET timescaledb.debug_inject_gid_error TO 'abort';
--heal should error out and the prepared transaction should still be visible
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT * FROM table_modified_by_txns;
SELECT count(*) FROM pg_prepared_xacts;
SELECT count(*) FROM _timescaledb_catalog.remote_txn;
@ -95,7 +95,7 @@ SELECT create_prepared_record();
--test "inprogress" resolution for the prepared 2PC
SET timescaledb.debug_inject_gid_error TO 'inprogress';
--heal will not error out but the prepared transaction should still be visible
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT * FROM table_modified_by_txns;
SELECT count(*) FROM pg_prepared_xacts;
SELECT count(*) FROM _timescaledb_catalog.remote_txn;
@ -104,9 +104,9 @@ SELECT count(*) FROM _timescaledb_catalog.remote_txn;
SELECT create_prepared_record();
--set to any random value so that it does not have any effect and allows healing
SET timescaledb.debug_inject_gid_error TO 'ignored';
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT * FROM table_modified_by_txns;
SELECT count(*) FROM pg_prepared_xacts;
SELECT count(*) FROM _timescaledb_catalog.remote_txn;
@ -116,9 +116,9 @@ BEGIN;
INSERT INTO public.table_modified_by_txns VALUES ('non-ts-txn');
PREPARE TRANSACTION 'non-ts-txn';
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback2'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback3'));
COMMIT PREPARED 'non-ts-txn';
SELECT * FROM table_modified_by_txns;
@ -137,7 +137,7 @@ CREATE TABLE unused(id int);
PREPARE TRANSACTION 'ts-1-10-20-30';
\c :TEST_DBNAME :ROLE_SUPERUSER
-- should not fail
SELECT _timescaledb_internal.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
SELECT _timescaledb_functions.remote_txn_heal_data_node((SELECT OID FROM pg_foreign_server WHERE srvname = 'loopback'));
\c test_an2
ROLLBACK PREPARED 'ts-1-10-20-30';
\c :TEST_DBNAME :ROLE_SUPERUSER

View File

@ -87,7 +87,7 @@ send_heal()
{
remote_connection_query_ok(get_connection(),
"SELECT "
"_timescaledb_internal.remote_txn_heal_data_node((SELECT "
"_timescaledb_functions.remote_txn_heal_data_node((SELECT "
"OID FROM pg_foreign_server WHERE srvname = 'loopback'))");
}

View File

@ -39,7 +39,7 @@ my ($cmdret, $stdout, $stderr) = $an->psql(
SET ROLE alice;
SELECT time AT TIME ZONE 'America/New_York', location, temp FROM conditions;
SELECT node_name, user_name, invalidated
FROM _timescaledb_internal.show_connection_cache()
FROM _timescaledb_functions.show_connection_cache()
WHERE user_name='alice';
RESET ROLE;
DROP TABLE conditions;
@ -47,7 +47,7 @@ my ($cmdret, $stdout, $stderr) = $an->psql(
REVOKE CREATE ON SCHEMA public FROM alice;
DROP ROLE ALICE;
SELECT node_name, user_name, invalidated
FROM _timescaledb_internal.show_connection_cache()
FROM _timescaledb_functions.show_connection_cache()
WHERE user_name='alice';
]);