mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 11:03:36 +08:00
The timescale clustering code so far has been written referring to the remote databases as 'servers'. This terminology is a bit overloaded, and in particular we don't enforce any network topology limitations that the term 'server' would suggest. In light of this we've decided to change to use the term 'node' when referring to the different databases in a distributed database. Specifically we refer to the frontend as an 'access node' and to the backends as 'data nodes', though we may omit the access or data qualifier where it's unambiguous. As the vast bulk of the code so far has been written for the case where there was a single access node, almost all instances of 'server' were references to data nodes. This change has updated the code to rename those instances.
95 lines
2.8 KiB
SQL
95 lines
2.8 KiB
SQL
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
|
|
\c :TEST_DBNAME :ROLE_SUPERUSER
|
|
|
|
SELECT * FROM add_data_node('data_node1', 'localhost', 'data_node1', port=>current_setting('port')::integer);
|
|
SELECT * FROM add_data_node('data_node2', 'localhost', 'data_node2', port=>current_setting('port')::integer);
|
|
SELECT * FROM add_data_node('data_node3', 'localhost', 'data_node3', port=>current_setting('port')::integer);
|
|
|
|
\des+
|
|
|
|
CREATE FUNCTION _timescaledb_internal.invoke_distributed_commands()
|
|
RETURNS void
|
|
AS :TSL_MODULE_PATHNAME, 'tsl_invoke_distributed_commands'
|
|
LANGUAGE C STRICT;
|
|
|
|
CREATE FUNCTION _timescaledb_internal.invoke_faulty_distributed_command()
|
|
RETURNS void
|
|
AS :TSL_MODULE_PATHNAME, 'tsl_invoke_faulty_distributed_command'
|
|
LANGUAGE C STRICT;
|
|
|
|
SELECT _timescaledb_internal.invoke_distributed_commands();
|
|
|
|
\c data_node1
|
|
\dt
|
|
SELECT * FROM disttable1;
|
|
\c data_node2
|
|
\dt
|
|
SELECT * FROM disttable1;
|
|
\c data_node3
|
|
\dt
|
|
SELECT * FROM disttable1;
|
|
\c single
|
|
|
|
-- Verify failed insert command gets fully rolled back
|
|
\set ON_ERROR_STOP 0
|
|
SELECT _timescaledb_internal.invoke_faulty_distributed_command();
|
|
\set ON_ERROR_STOP 1
|
|
|
|
\c data_node1
|
|
SELECT * from disttable2;
|
|
\c data_node3
|
|
SELECT * from disttable2;
|
|
|
|
-- Test connection session identity
|
|
\c :TEST_DBNAME :ROLE_SUPERUSER
|
|
\unset ECHO
|
|
\o /dev/null
|
|
\ir include/remote_exec.sql
|
|
\o
|
|
\set ECHO all
|
|
|
|
-- Register is_frontend_session() function and test that it returns false for
|
|
-- connections openned by test suite. This simualates behaviour expected
|
|
-- with a client connections.
|
|
CREATE OR REPLACE FUNCTION is_frontend_session()
|
|
RETURNS BOOL
|
|
AS :TSL_MODULE_PATHNAME, 'test_is_frontend_session' LANGUAGE C;
|
|
|
|
\c data_node1
|
|
CREATE OR REPLACE FUNCTION is_frontend_session()
|
|
RETURNS BOOL
|
|
AS :TSL_MODULE_PATHNAME, 'test_is_frontend_session' LANGUAGE C;
|
|
SELECT is_frontend_session();
|
|
|
|
\c data_node2
|
|
CREATE OR REPLACE FUNCTION is_frontend_session()
|
|
RETURNS BOOL
|
|
AS :TSL_MODULE_PATHNAME, 'test_is_frontend_session' LANGUAGE C;
|
|
SELECT is_frontend_session();
|
|
|
|
\c data_node3
|
|
CREATE OR REPLACE FUNCTION is_frontend_session()
|
|
RETURNS BOOL
|
|
AS :TSL_MODULE_PATHNAME, 'test_is_frontend_session' LANGUAGE C;
|
|
SELECT is_frontend_session();
|
|
|
|
\c :TEST_DBNAME :ROLE_SUPERUSER
|
|
SELECT is_frontend_session();
|
|
|
|
-- Ensure peer dist id is already set and can be set only once
|
|
\set ON_ERROR_STOP 0
|
|
SELECT * FROM test.remote_exec('{data_node1}', $$ SELECT * FROM _timescaledb_internal.set_peer_dist_id('77348176-09da-4a80-bc78-e31bdf5e63ec'); $$);
|
|
\set ON_ERROR_STOP 1
|
|
|
|
-- Repeat is_frontend_session() test again, but this time using connections openned from frontend
|
|
-- to backend nodes. Must return true.
|
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT is_frontend_session(); $$);
|
|
|
|
\c single
|
|
DROP DATABASE data_node1;
|
|
DROP DATABASE data_node2;
|
|
DROP DATABASE data_node3;
|