mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 19:59:48 +08:00
Adjust relation size in MN test results
Commit 8767de658b8279fd3352d0bf2acce4564784079e introduces the freezing of compressed tuples. Since a visibility map is created on PG14+, relations are larger by one page. However, the adjustment for the MN tests was missing so far, which is done by this PR.
This commit is contained in:
parent
50578e4e0a
commit
f8b8bef207
1784
tsl/test/expected/dist_compression-14.out
Normal file
1784
tsl/test/expected/dist_compression-14.out
Normal file
File diff suppressed because it is too large
Load Diff
1784
tsl/test/expected/dist_compression-15.out
Normal file
1784
tsl/test/expected/dist_compression-15.out
Normal file
File diff suppressed because it is too large
Load Diff
630
tsl/test/expected/dist_move_chunk-14.out
Normal file
630
tsl/test/expected/dist_move_chunk-14.out
Normal file
@ -0,0 +1,630 @@
|
|||||||
|
-- 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_CLUSTER_SUPERUSER;
|
||||||
|
\unset ECHO
|
||||||
|
psql:include/remote_exec.sql:5: NOTICE: schema "test" already exists, skipping
|
||||||
|
\set DATA_NODE_1 :TEST_DBNAME _1
|
||||||
|
\set DATA_NODE_2 :TEST_DBNAME _2
|
||||||
|
\set DATA_NODE_3 :TEST_DBNAME _3
|
||||||
|
SELECT node_name, database, node_created, database_created, extension_created
|
||||||
|
FROM (
|
||||||
|
SELECT (add_data_node(name, host => 'localhost', DATABASE => name)).*
|
||||||
|
FROM (VALUES (:'DATA_NODE_1'), (:'DATA_NODE_2'), (:'DATA_NODE_3')) v(name)
|
||||||
|
) a;
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
node_name | database | node_created | database_created | extension_created
|
||||||
|
----------------------+----------------------+--------------+------------------+-------------------
|
||||||
|
db_dist_move_chunk_1 | db_dist_move_chunk_1 | t | t | t
|
||||||
|
db_dist_move_chunk_2 | db_dist_move_chunk_2 | t | t | t
|
||||||
|
db_dist_move_chunk_3 | db_dist_move_chunk_3 | t | t | t
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
GRANT USAGE ON FOREIGN SERVER :DATA_NODE_1, :DATA_NODE_2, :DATA_NODE_3 TO PUBLIC;
|
||||||
|
-- though user on access node has required GRANTS, this will propagate GRANTS to the connected data nodes
|
||||||
|
GRANT CREATE ON SCHEMA public TO :ROLE_1;
|
||||||
|
SET ROLE :ROLE_1;
|
||||||
|
CREATE TABLE dist_test(time timestamp NOT NULL, device int, temp float);
|
||||||
|
SELECT create_distributed_hypertable('dist_test', 'time', 'device', 3);
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
WARNING: column type "timestamp without time zone" used for "time" does not follow best practices
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(1,public,dist_test,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO dist_test SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 0.10 FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-08 1:00', '1 hour') t;
|
||||||
|
SELECT * from show_chunks('dist_test');
|
||||||
|
show_chunks
|
||||||
|
---------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_1'], $$ SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk; $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
sum
|
||||||
|
---
|
||||||
|
406
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- ensure data node name is provided and has proper type
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> null, destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: invalid source or destination node
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => null);
|
||||||
|
ERROR: invalid source or destination node
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => 2);
|
||||||
|
ERROR: procedure timescaledb_experimental.copy_chunk(chunk => unknown, source_node => unknown, destination_node => integer) does not exist at character 6
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node => :'DATA_NODE_1');
|
||||||
|
ERROR: invalid source or destination node
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- ensure functions can't be run in read only mode
|
||||||
|
SET default_transaction_read_only TO on;
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: cannot execute move_chunk() in a read-only transaction
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: cannot execute copy_chunk() in a read-only transaction
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
SET default_transaction_read_only TO off;
|
||||||
|
-- ensure functions can't be run in an active multi-statement transaction
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
BEGIN;
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: move_chunk cannot run inside a transaction block
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: copy_chunk cannot run inside a transaction block
|
||||||
|
ROLLBACK;
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- must be superuser to copy/move chunks
|
||||||
|
SET ROLE :ROLE_DEFAULT_PERM_USER;
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: must be superuser, replication role, or hypertable owner to copy/move chunk to data node
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
SET ROLE :ROLE_1;
|
||||||
|
-- can't run copy/move chunk on a data node
|
||||||
|
\c :DATA_NODE_1 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: function must be run on the access node only
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: function must be run on the access node only
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- ensure that hypertable chunks are distributed
|
||||||
|
CREATE TABLE nondist_test(time timestamp NOT NULL, device int, temp float);
|
||||||
|
SELECT create_hypertable('nondist_test', 'time', 'device', 3);
|
||||||
|
WARNING: column type "timestamp without time zone" used for "time" does not follow best practices
|
||||||
|
create_hypertable
|
||||||
|
---------------------------
|
||||||
|
(2,public,nondist_test,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO nondist_test SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 0.10 FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-08 1:00', '1 hour') t;
|
||||||
|
SELECT * from show_chunks('nondist_test');
|
||||||
|
show_chunks
|
||||||
|
----------------------------------------
|
||||||
|
_timescaledb_internal._hyper_2_5_chunk
|
||||||
|
_timescaledb_internal._hyper_2_6_chunk
|
||||||
|
_timescaledb_internal._hyper_2_7_chunk
|
||||||
|
_timescaledb_internal._hyper_2_8_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._hyper_2_5_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: "_hyper_2_5_chunk" is not a valid remote chunk
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._hyper_2_5_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: "_hyper_2_5_chunk" is not a valid remote chunk
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- ensure that chunk exists on a source data node
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_2_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: chunk "_dist_hyper_1_2_chunk" does not exist on source data node "db_dist_move_chunk_1"
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- do actualy copy
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_2'], $$ SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk; $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
sum
|
||||||
|
---
|
||||||
|
406
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- ensure that chunk exists on a destination data node
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: chunk "_dist_hyper_1_1_chunk" already exists on destination data node "db_dist_move_chunk_2"
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- now try to move the same chunk from data node 2 to 3
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_3'], $$ SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk; $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
sum
|
||||||
|
---
|
||||||
|
406
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Check that they can be called from inside a procedure without
|
||||||
|
-- generating warnings or error messages (#3495).
|
||||||
|
CREATE OR REPLACE PROCEDURE copy_wrapper(regclass, text, text)
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
CALL timescaledb_experimental.copy_chunk($1, $2, $3);
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
LANGUAGE PLPGSQL;
|
||||||
|
CREATE OR REPLACE PROCEDURE move_wrapper(regclass, text, text)
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
CALL timescaledb_experimental.move_chunk($1, $2, $3);
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
LANGUAGE PLPGSQL;
|
||||||
|
SELECT chunk_name, replica_nodes, non_replica_nodes
|
||||||
|
FROM timescaledb_experimental.chunk_replication_status;
|
||||||
|
chunk_name | replica_nodes | non_replica_nodes
|
||||||
|
-----------------------+---------------------------------------------+---------------------------------------------
|
||||||
|
_dist_hyper_1_1_chunk | {db_dist_move_chunk_1,db_dist_move_chunk_3} | {db_dist_move_chunk_2}
|
||||||
|
_dist_hyper_1_2_chunk | {db_dist_move_chunk_2} | {db_dist_move_chunk_1,db_dist_move_chunk_3}
|
||||||
|
_dist_hyper_1_3_chunk | {db_dist_move_chunk_3} | {db_dist_move_chunk_1,db_dist_move_chunk_2}
|
||||||
|
_dist_hyper_1_4_chunk | {db_dist_move_chunk_1} | {db_dist_move_chunk_2,db_dist_move_chunk_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
CALL copy_wrapper('_timescaledb_internal._dist_hyper_1_3_chunk', :'DATA_NODE_3', :'DATA_NODE_2');
|
||||||
|
CALL move_wrapper('_timescaledb_internal._dist_hyper_1_2_chunk', :'DATA_NODE_2', :'DATA_NODE_1');
|
||||||
|
SELECT chunk_name, replica_nodes, non_replica_nodes
|
||||||
|
FROM timescaledb_experimental.chunk_replication_status;
|
||||||
|
chunk_name | replica_nodes | non_replica_nodes
|
||||||
|
-----------------------+---------------------------------------------+---------------------------------------------
|
||||||
|
_dist_hyper_1_1_chunk | {db_dist_move_chunk_1,db_dist_move_chunk_3} | {db_dist_move_chunk_2}
|
||||||
|
_dist_hyper_1_2_chunk | {db_dist_move_chunk_1} | {db_dist_move_chunk_2,db_dist_move_chunk_3}
|
||||||
|
_dist_hyper_1_3_chunk | {db_dist_move_chunk_3,db_dist_move_chunk_2} | {db_dist_move_chunk_1}
|
||||||
|
_dist_hyper_1_4_chunk | {db_dist_move_chunk_1} | {db_dist_move_chunk_2,db_dist_move_chunk_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
DROP PROCEDURE copy_wrapper;
|
||||||
|
DROP PROCEDURE move_wrapper;
|
||||||
|
DROP TABLE dist_test;
|
||||||
|
-- Test copy/move compressed chunk
|
||||||
|
--
|
||||||
|
-- Create a compressed hypertable
|
||||||
|
CREATE TABLE dist_test(time timestamp NOT NULL, device int, temp float);
|
||||||
|
SELECT create_distributed_hypertable('dist_test', 'time', 'device', 3);
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
WARNING: column type "timestamp without time zone" used for "time" does not follow best practices
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(3,public,dist_test,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO dist_test SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 0.10 FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-08 1:00', '1 hour') t;
|
||||||
|
ALTER TABLE dist_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby = 'time DESC');
|
||||||
|
-- Integrity check (see below)
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Get a list of chunks
|
||||||
|
SELECT * from show_chunks('dist_test');
|
||||||
|
show_chunks
|
||||||
|
----------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT chunk_schema || '.' || chunk_name, data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'dist_test';
|
||||||
|
?column? | data_nodes
|
||||||
|
----------------------------------------------+------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk | {db_dist_move_chunk_1}
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk | {db_dist_move_chunk_2}
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk | {db_dist_move_chunk_3}
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk | {db_dist_move_chunk_1}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
-- Compress a chunk
|
||||||
|
SELECT compress_chunk('_timescaledb_internal._dist_hyper_3_12_chunk');
|
||||||
|
compress_chunk
|
||||||
|
----------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
-- Get compressed chunk name on the source data node and show its content
|
||||||
|
\c :DATA_NODE_1 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
--------------------------
|
||||||
|
compress_hyper_3_6_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
time | device | temp | _ts_meta_count | _ts_meta_sequence_num | _ts_meta_min_1 | _ts_meta_max_1
|
||||||
|
----------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------------+--------------------------+--------------------------
|
||||||
|
BAAAAgna9rUEAAACCdr2tQQAAAAAAQAAAAEAAAAAAAAADgAEE7XtaggA | 1 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 01:00:00 2018 | Thu Mar 08 01:00:00 2018
|
||||||
|
BAAAAgnaICFgAAACCdogIWAAAAAAAQAAAAEAAAAAAAAADgAEE7RAQsAA | 10 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 00:00:00 2018 | Thu Mar 08 00:00:00 2018
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
-- Get compressed chunk stat
|
||||||
|
SELECT * FROM _timescaledb_internal.compressed_chunk_stats WHERE chunk_name = '_dist_hyper_3_12_chunk';
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | compression_status | uncompressed_heap_size | uncompressed_index_size | uncompressed_toast_size | uncompressed_total_size | compressed_heap_size | compressed_index_size | compressed_toast_size | compressed_total_size
|
||||||
|
-------------------+-----------------+-----------------------+------------------------+--------------------+------------------------+-------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-----------------------
|
||||||
|
public | dist_test | _timescaledb_internal | _dist_hyper_3_12_chunk | Compressed | 8192 | 32768 | 0 | 40960 | 16384 | 16384 | 8192 | 40960
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Move compressed chunk from data node 1 to data node 2
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
SELECT count(*) FROM _timescaledb_catalog.chunk_copy_operation;
|
||||||
|
count
|
||||||
|
-------
|
||||||
|
5
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Make sure same compressed chunk hash been created on the destination data node
|
||||||
|
\c :DATA_NODE_2 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- Chunk created on data node has different id but the same name, make sure
|
||||||
|
-- compressed_chunk_id is correctly set
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
--------------------------
|
||||||
|
compress_hyper_3_6_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Try to query hypertable member with compressed chunk
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
time | device | temp | _ts_meta_count | _ts_meta_sequence_num | _ts_meta_min_1 | _ts_meta_max_1
|
||||||
|
----------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------------+--------------------------+--------------------------
|
||||||
|
BAAAAgna9rUEAAACCdr2tQQAAAAAAQAAAAEAAAAAAAAADgAEE7XtaggA | 1 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 01:00:00 2018 | Thu Mar 08 01:00:00 2018
|
||||||
|
BAAAAgnaICFgAAACCdogIWAAAAAAAQAAAAEAAAAAAAAADgAEE7RAQsAA | 10 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 00:00:00 2018 | Thu Mar 08 00:00:00 2018
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
-- Ensure that compressed chunk stats match stats from the source data node
|
||||||
|
SELECT * FROM _timescaledb_internal.compressed_chunk_stats WHERE chunk_name = '_dist_hyper_3_12_chunk';
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | compression_status | uncompressed_heap_size | uncompressed_index_size | uncompressed_toast_size | uncompressed_total_size | compressed_heap_size | compressed_index_size | compressed_toast_size | compressed_total_size
|
||||||
|
-------------------+-----------------+-----------------------+------------------------+--------------------+------------------------+-------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-----------------------
|
||||||
|
public | dist_test | _timescaledb_internal | _dist_hyper_3_12_chunk | Compressed | 8192 | 32768 | 0 | 40960 | 16384 | 16384 | 8192 | 40960
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Ensure moved chunks are no longer present on the source data node
|
||||||
|
\c :DATA_NODE_1 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
ERROR: relation "_timescaledb_internal.compress_hyper_3_6_chunk" does not exist at character 15
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
ERROR: relation "_timescaledb_internal._dist_hyper_3_12_chunk" does not exist at character 15
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- Make sure chunk has been properly moved from AN
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
SELECT * FROM show_chunks('dist_test');
|
||||||
|
show_chunks
|
||||||
|
----------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT chunk_schema || '.' || chunk_name, data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'dist_test';
|
||||||
|
?column? | data_nodes
|
||||||
|
----------------------------------------------+------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk | {db_dist_move_chunk_1}
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk | {db_dist_move_chunk_2}
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk | {db_dist_move_chunk_3}
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk | {db_dist_move_chunk_2}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
-- Query distributed hypertable again to query newly moved chunk, make
|
||||||
|
-- sure result has not changed
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Test operation_id name validation
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => ' move chunk id ', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
ERROR: operation_id name " move chunk id " is not valid
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => 'ChUnK_MoVe_Op', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
ERROR: operation_id name "ChUnK_MoVe_Op" is not valid
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => '_ID123', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
ERROR: operation_id name "_ID123" is not valid
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- Now copy chunk from data node 2 to data node 3
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => 'id123', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
\c :DATA_NODE_3 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- Validate chunk on data node 3
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
--------------------------
|
||||||
|
compress_hyper_3_6_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
time | device | temp | _ts_meta_count | _ts_meta_sequence_num | _ts_meta_min_1 | _ts_meta_max_1
|
||||||
|
----------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------------+--------------------------+--------------------------
|
||||||
|
BAAAAgna9rUEAAACCdr2tQQAAAAAAQAAAAEAAAAAAAAADgAEE7XtaggA | 1 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 01:00:00 2018 | Thu Mar 08 01:00:00 2018
|
||||||
|
BAAAAgnaICFgAAACCdogIWAAAAAAAQAAAAEAAAAAAAAADgAEE7RAQsAA | 10 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 00:00:00 2018 | Thu Mar 08 00:00:00 2018
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal.compressed_chunk_stats WHERE chunk_name = '_dist_hyper_3_12_chunk';
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | compression_status | uncompressed_heap_size | uncompressed_index_size | uncompressed_toast_size | uncompressed_total_size | compressed_heap_size | compressed_index_size | compressed_toast_size | compressed_total_size
|
||||||
|
-------------------+-----------------+-----------------------+------------------------+--------------------+------------------------+-------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-----------------------
|
||||||
|
public | dist_test | _timescaledb_internal | _dist_hyper_3_12_chunk | Compressed | 8192 | 32768 | 0 | 40960 | 16384 | 16384 | 8192 | 40960
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- _dist_hyper_3_12_chunk should be moved in data node 3 now
|
||||||
|
SELECT chunk_schema || '.' || chunk_name, data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'dist_test';
|
||||||
|
?column? | data_nodes
|
||||||
|
----------------------------------------------+------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk | {db_dist_move_chunk_1}
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk | {db_dist_move_chunk_2}
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk | {db_dist_move_chunk_3}
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk | {db_dist_move_chunk_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
RESET ROLE;
|
||||||
|
DROP DATABASE :DATA_NODE_1 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_2 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_3 WITH (FORCE);
|
630
tsl/test/expected/dist_move_chunk-15.out
Normal file
630
tsl/test/expected/dist_move_chunk-15.out
Normal file
@ -0,0 +1,630 @@
|
|||||||
|
-- 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_CLUSTER_SUPERUSER;
|
||||||
|
\unset ECHO
|
||||||
|
psql:include/remote_exec.sql:5: NOTICE: schema "test" already exists, skipping
|
||||||
|
\set DATA_NODE_1 :TEST_DBNAME _1
|
||||||
|
\set DATA_NODE_2 :TEST_DBNAME _2
|
||||||
|
\set DATA_NODE_3 :TEST_DBNAME _3
|
||||||
|
SELECT node_name, database, node_created, database_created, extension_created
|
||||||
|
FROM (
|
||||||
|
SELECT (add_data_node(name, host => 'localhost', DATABASE => name)).*
|
||||||
|
FROM (VALUES (:'DATA_NODE_1'), (:'DATA_NODE_2'), (:'DATA_NODE_3')) v(name)
|
||||||
|
) a;
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
node_name | database | node_created | database_created | extension_created
|
||||||
|
----------------------+----------------------+--------------+------------------+-------------------
|
||||||
|
db_dist_move_chunk_1 | db_dist_move_chunk_1 | t | t | t
|
||||||
|
db_dist_move_chunk_2 | db_dist_move_chunk_2 | t | t | t
|
||||||
|
db_dist_move_chunk_3 | db_dist_move_chunk_3 | t | t | t
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
GRANT USAGE ON FOREIGN SERVER :DATA_NODE_1, :DATA_NODE_2, :DATA_NODE_3 TO PUBLIC;
|
||||||
|
-- though user on access node has required GRANTS, this will propagate GRANTS to the connected data nodes
|
||||||
|
GRANT CREATE ON SCHEMA public TO :ROLE_1;
|
||||||
|
SET ROLE :ROLE_1;
|
||||||
|
CREATE TABLE dist_test(time timestamp NOT NULL, device int, temp float);
|
||||||
|
SELECT create_distributed_hypertable('dist_test', 'time', 'device', 3);
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
WARNING: column type "timestamp without time zone" used for "time" does not follow best practices
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(1,public,dist_test,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO dist_test SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 0.10 FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-08 1:00', '1 hour') t;
|
||||||
|
SELECT * from show_chunks('dist_test');
|
||||||
|
show_chunks
|
||||||
|
---------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_1'], $$ SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk; $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
sum
|
||||||
|
---
|
||||||
|
406
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- ensure data node name is provided and has proper type
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> null, destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: invalid source or destination node
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => null);
|
||||||
|
ERROR: invalid source or destination node
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => 2);
|
||||||
|
ERROR: procedure timescaledb_experimental.copy_chunk(chunk => unknown, source_node => unknown, destination_node => integer) does not exist at character 6
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node => :'DATA_NODE_1');
|
||||||
|
ERROR: invalid source or destination node
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- ensure functions can't be run in read only mode
|
||||||
|
SET default_transaction_read_only TO on;
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: cannot execute move_chunk() in a read-only transaction
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: cannot execute copy_chunk() in a read-only transaction
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
SET default_transaction_read_only TO off;
|
||||||
|
-- ensure functions can't be run in an active multi-statement transaction
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
BEGIN;
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: move_chunk cannot run inside a transaction block
|
||||||
|
ROLLBACK;
|
||||||
|
BEGIN;
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: copy_chunk cannot run inside a transaction block
|
||||||
|
ROLLBACK;
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- must be superuser to copy/move chunks
|
||||||
|
SET ROLE :ROLE_DEFAULT_PERM_USER;
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: must be superuser, replication role, or hypertable owner to copy/move chunk to data node
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
SET ROLE :ROLE_1;
|
||||||
|
-- can't run copy/move chunk on a data node
|
||||||
|
\c :DATA_NODE_1 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: function must be run on the access node only
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: function must be run on the access node only
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- ensure that hypertable chunks are distributed
|
||||||
|
CREATE TABLE nondist_test(time timestamp NOT NULL, device int, temp float);
|
||||||
|
SELECT create_hypertable('nondist_test', 'time', 'device', 3);
|
||||||
|
WARNING: column type "timestamp without time zone" used for "time" does not follow best practices
|
||||||
|
create_hypertable
|
||||||
|
---------------------------
|
||||||
|
(2,public,nondist_test,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO nondist_test SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 0.10 FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-08 1:00', '1 hour') t;
|
||||||
|
SELECT * from show_chunks('nondist_test');
|
||||||
|
show_chunks
|
||||||
|
----------------------------------------
|
||||||
|
_timescaledb_internal._hyper_2_5_chunk
|
||||||
|
_timescaledb_internal._hyper_2_6_chunk
|
||||||
|
_timescaledb_internal._hyper_2_7_chunk
|
||||||
|
_timescaledb_internal._hyper_2_8_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._hyper_2_5_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: "_hyper_2_5_chunk" is not a valid remote chunk
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._hyper_2_5_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: "_hyper_2_5_chunk" is not a valid remote chunk
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- ensure that chunk exists on a source data node
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_2_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: chunk "_dist_hyper_1_2_chunk" does not exist on source data node "db_dist_move_chunk_1"
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- do actualy copy
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_2'], $$ SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk; $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
sum
|
||||||
|
---
|
||||||
|
406
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- ensure that chunk exists on a destination data node
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.copy_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
ERROR: chunk "_dist_hyper_1_1_chunk" already exists on destination data node "db_dist_move_chunk_2"
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- now try to move the same chunk from data node 2 to 3
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_1_1_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_4_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_3'], $$ SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk; $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT sum(device) FROM _timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
sum
|
||||||
|
---
|
||||||
|
406
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Check that they can be called from inside a procedure without
|
||||||
|
-- generating warnings or error messages (#3495).
|
||||||
|
CREATE OR REPLACE PROCEDURE copy_wrapper(regclass, text, text)
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
CALL timescaledb_experimental.copy_chunk($1, $2, $3);
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
LANGUAGE PLPGSQL;
|
||||||
|
CREATE OR REPLACE PROCEDURE move_wrapper(regclass, text, text)
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
CALL timescaledb_experimental.move_chunk($1, $2, $3);
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
LANGUAGE PLPGSQL;
|
||||||
|
SELECT chunk_name, replica_nodes, non_replica_nodes
|
||||||
|
FROM timescaledb_experimental.chunk_replication_status;
|
||||||
|
chunk_name | replica_nodes | non_replica_nodes
|
||||||
|
-----------------------+---------------------------------------------+---------------------------------------------
|
||||||
|
_dist_hyper_1_1_chunk | {db_dist_move_chunk_1,db_dist_move_chunk_3} | {db_dist_move_chunk_2}
|
||||||
|
_dist_hyper_1_2_chunk | {db_dist_move_chunk_2} | {db_dist_move_chunk_1,db_dist_move_chunk_3}
|
||||||
|
_dist_hyper_1_3_chunk | {db_dist_move_chunk_3} | {db_dist_move_chunk_1,db_dist_move_chunk_2}
|
||||||
|
_dist_hyper_1_4_chunk | {db_dist_move_chunk_1} | {db_dist_move_chunk_2,db_dist_move_chunk_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
CALL copy_wrapper('_timescaledb_internal._dist_hyper_1_3_chunk', :'DATA_NODE_3', :'DATA_NODE_2');
|
||||||
|
CALL move_wrapper('_timescaledb_internal._dist_hyper_1_2_chunk', :'DATA_NODE_2', :'DATA_NODE_1');
|
||||||
|
SELECT chunk_name, replica_nodes, non_replica_nodes
|
||||||
|
FROM timescaledb_experimental.chunk_replication_status;
|
||||||
|
chunk_name | replica_nodes | non_replica_nodes
|
||||||
|
-----------------------+---------------------------------------------+---------------------------------------------
|
||||||
|
_dist_hyper_1_1_chunk | {db_dist_move_chunk_1,db_dist_move_chunk_3} | {db_dist_move_chunk_2}
|
||||||
|
_dist_hyper_1_2_chunk | {db_dist_move_chunk_1} | {db_dist_move_chunk_2,db_dist_move_chunk_3}
|
||||||
|
_dist_hyper_1_3_chunk | {db_dist_move_chunk_3,db_dist_move_chunk_2} | {db_dist_move_chunk_1}
|
||||||
|
_dist_hyper_1_4_chunk | {db_dist_move_chunk_1} | {db_dist_move_chunk_2,db_dist_move_chunk_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
DROP PROCEDURE copy_wrapper;
|
||||||
|
DROP PROCEDURE move_wrapper;
|
||||||
|
DROP TABLE dist_test;
|
||||||
|
-- Test copy/move compressed chunk
|
||||||
|
--
|
||||||
|
-- Create a compressed hypertable
|
||||||
|
CREATE TABLE dist_test(time timestamp NOT NULL, device int, temp float);
|
||||||
|
SELECT create_distributed_hypertable('dist_test', 'time', 'device', 3);
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
WARNING: column type "timestamp without time zone" used for "time" does not follow best practices
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(3,public,dist_test,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO dist_test SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 0.10 FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-08 1:00', '1 hour') t;
|
||||||
|
ALTER TABLE dist_test SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby = 'time DESC');
|
||||||
|
-- Integrity check (see below)
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Get a list of chunks
|
||||||
|
SELECT * from show_chunks('dist_test');
|
||||||
|
show_chunks
|
||||||
|
----------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT chunk_schema || '.' || chunk_name, data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'dist_test';
|
||||||
|
?column? | data_nodes
|
||||||
|
----------------------------------------------+------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk | {db_dist_move_chunk_1}
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk | {db_dist_move_chunk_2}
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk | {db_dist_move_chunk_3}
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk | {db_dist_move_chunk_1}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
-- Compress a chunk
|
||||||
|
SELECT compress_chunk('_timescaledb_internal._dist_hyper_3_12_chunk');
|
||||||
|
compress_chunk
|
||||||
|
----------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
-- Get compressed chunk name on the source data node and show its content
|
||||||
|
\c :DATA_NODE_1 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
--------------------------
|
||||||
|
compress_hyper_3_6_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
time | device | temp | _ts_meta_count | _ts_meta_sequence_num | _ts_meta_min_1 | _ts_meta_max_1
|
||||||
|
----------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------------+--------------------------+--------------------------
|
||||||
|
BAAAAgna9rUEAAACCdr2tQQAAAAAAQAAAAEAAAAAAAAADgAEE7XtaggA | 1 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 01:00:00 2018 | Thu Mar 08 01:00:00 2018
|
||||||
|
BAAAAgnaICFgAAACCdogIWAAAAAAAQAAAAEAAAAAAAAADgAEE7RAQsAA | 10 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 00:00:00 2018 | Thu Mar 08 00:00:00 2018
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
-- Get compressed chunk stat
|
||||||
|
SELECT * FROM _timescaledb_internal.compressed_chunk_stats WHERE chunk_name = '_dist_hyper_3_12_chunk';
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | compression_status | uncompressed_heap_size | uncompressed_index_size | uncompressed_toast_size | uncompressed_total_size | compressed_heap_size | compressed_index_size | compressed_toast_size | compressed_total_size
|
||||||
|
-------------------+-----------------+-----------------------+------------------------+--------------------+------------------------+-------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-----------------------
|
||||||
|
public | dist_test | _timescaledb_internal | _dist_hyper_3_12_chunk | Compressed | 8192 | 32768 | 0 | 40960 | 16384 | 16384 | 8192 | 40960
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Move compressed chunk from data node 1 to data node 2
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
CALL timescaledb_experimental.move_chunk(chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_1', destination_node => :'DATA_NODE_2');
|
||||||
|
SELECT count(*) FROM _timescaledb_catalog.chunk_copy_operation;
|
||||||
|
count
|
||||||
|
-------
|
||||||
|
5
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Make sure same compressed chunk hash been created on the destination data node
|
||||||
|
\c :DATA_NODE_2 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- Chunk created on data node has different id but the same name, make sure
|
||||||
|
-- compressed_chunk_id is correctly set
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
--------------------------
|
||||||
|
compress_hyper_3_6_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Try to query hypertable member with compressed chunk
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
time | device | temp | _ts_meta_count | _ts_meta_sequence_num | _ts_meta_min_1 | _ts_meta_max_1
|
||||||
|
----------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------------+--------------------------+--------------------------
|
||||||
|
BAAAAgna9rUEAAACCdr2tQQAAAAAAQAAAAEAAAAAAAAADgAEE7XtaggA | 1 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 01:00:00 2018 | Thu Mar 08 01:00:00 2018
|
||||||
|
BAAAAgnaICFgAAACCdogIWAAAAAAAQAAAAEAAAAAAAAADgAEE7RAQsAA | 10 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 00:00:00 2018 | Thu Mar 08 00:00:00 2018
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
-- Ensure that compressed chunk stats match stats from the source data node
|
||||||
|
SELECT * FROM _timescaledb_internal.compressed_chunk_stats WHERE chunk_name = '_dist_hyper_3_12_chunk';
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | compression_status | uncompressed_heap_size | uncompressed_index_size | uncompressed_toast_size | uncompressed_total_size | compressed_heap_size | compressed_index_size | compressed_toast_size | compressed_total_size
|
||||||
|
-------------------+-----------------+-----------------------+------------------------+--------------------+------------------------+-------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-----------------------
|
||||||
|
public | dist_test | _timescaledb_internal | _dist_hyper_3_12_chunk | Compressed | 8192 | 32768 | 0 | 40960 | 16384 | 16384 | 8192 | 40960
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Ensure moved chunks are no longer present on the source data node
|
||||||
|
\c :DATA_NODE_1 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
ERROR: relation "_timescaledb_internal.compress_hyper_3_6_chunk" does not exist at character 15
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
ERROR: relation "_timescaledb_internal._dist_hyper_3_12_chunk" does not exist at character 15
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- Make sure chunk has been properly moved from AN
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
SELECT * FROM show_chunks('dist_test');
|
||||||
|
show_chunks
|
||||||
|
----------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
SELECT * FROM test.remote_exec(NULL, $$ SELECT * from show_chunks('dist_test'); $$);
|
||||||
|
WARNING: executing remote command is deprecated
|
||||||
|
NOTICE: [db_dist_move_chunk_1]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_1]:
|
||||||
|
show_chunks
|
||||||
|
-------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_2]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_2]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE: [db_dist_move_chunk_3]: SELECT * from show_chunks('dist_test')
|
||||||
|
NOTICE: [db_dist_move_chunk_3]:
|
||||||
|
show_chunks
|
||||||
|
--------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
remote_exec
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT chunk_schema || '.' || chunk_name, data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'dist_test';
|
||||||
|
?column? | data_nodes
|
||||||
|
----------------------------------------------+------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk | {db_dist_move_chunk_1}
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk | {db_dist_move_chunk_2}
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk | {db_dist_move_chunk_3}
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk | {db_dist_move_chunk_2}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
-- Query distributed hypertable again to query newly moved chunk, make
|
||||||
|
-- sure result has not changed
|
||||||
|
SELECT sum(device) FROM dist_test;
|
||||||
|
sum
|
||||||
|
-----
|
||||||
|
846
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Test operation_id name validation
|
||||||
|
\set ON_ERROR_STOP 0
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => ' move chunk id ', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
ERROR: operation_id name " move chunk id " is not valid
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => 'ChUnK_MoVe_Op', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
ERROR: operation_id name "ChUnK_MoVe_Op" is not valid
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => '_ID123', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
ERROR: operation_id name "_ID123" is not valid
|
||||||
|
\set ON_ERROR_STOP 1
|
||||||
|
-- Now copy chunk from data node 2 to data node 3
|
||||||
|
CALL timescaledb_experimental.move_chunk(operation_id => 'id123', chunk=>'_timescaledb_internal._dist_hyper_3_12_chunk', source_node=> :'DATA_NODE_2', destination_node => :'DATA_NODE_3');
|
||||||
|
\c :DATA_NODE_3 :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- Validate chunk on data node 3
|
||||||
|
SELECT c2.table_name
|
||||||
|
FROM _timescaledb_catalog.chunk c1
|
||||||
|
JOIN _timescaledb_catalog.chunk c2 ON (c1.compressed_chunk_id = c2.id)
|
||||||
|
WHERE c1.table_name = '_dist_hyper_3_12_chunk';
|
||||||
|
table_name
|
||||||
|
--------------------------
|
||||||
|
compress_hyper_3_6_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal.compress_hyper_3_6_chunk ORDER BY device, _ts_meta_min_1;
|
||||||
|
time | device | temp | _ts_meta_count | _ts_meta_sequence_num | _ts_meta_min_1 | _ts_meta_max_1
|
||||||
|
----------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------------+--------------------------+--------------------------
|
||||||
|
BAAAAgna9rUEAAACCdr2tQQAAAAAAQAAAAEAAAAAAAAADgAEE7XtaggA | 1 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 01:00:00 2018 | Thu Mar 08 01:00:00 2018
|
||||||
|
BAAAAgnaICFgAAACCdogIWAAAAAAAQAAAAEAAAAAAAAADgAEE7RAQsAA | 10 | AwA/uZmZmZmZmgAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEGAAAAAAAAAAIAAAABAAAAAQAAAAAAAAAGAAAAAAAAAD0AAAABPR/czMzMzMzN | 1 | 10 | Thu Mar 08 00:00:00 2018 | Thu Mar 08 00:00:00 2018
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal._dist_hyper_3_12_chunk ORDER BY time;
|
||||||
|
time | device | temp
|
||||||
|
--------------------------+--------+------
|
||||||
|
Thu Mar 08 00:00:00 2018 | 10 | 0.1
|
||||||
|
Thu Mar 08 01:00:00 2018 | 1 | 0.1
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SELECT * FROM _timescaledb_internal.compressed_chunk_stats WHERE chunk_name = '_dist_hyper_3_12_chunk';
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | compression_status | uncompressed_heap_size | uncompressed_index_size | uncompressed_toast_size | uncompressed_total_size | compressed_heap_size | compressed_index_size | compressed_toast_size | compressed_total_size
|
||||||
|
-------------------+-----------------+-----------------------+------------------------+--------------------+------------------------+-------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-----------------------
|
||||||
|
public | dist_test | _timescaledb_internal | _dist_hyper_3_12_chunk | Compressed | 8192 | 32768 | 0 | 40960 | 16384 | 16384 | 8192 | 40960
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
|
||||||
|
-- _dist_hyper_3_12_chunk should be moved in data node 3 now
|
||||||
|
SELECT chunk_schema || '.' || chunk_name, data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'dist_test';
|
||||||
|
?column? | data_nodes
|
||||||
|
----------------------------------------------+------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_3_9_chunk | {db_dist_move_chunk_1}
|
||||||
|
_timescaledb_internal._dist_hyper_3_10_chunk | {db_dist_move_chunk_2}
|
||||||
|
_timescaledb_internal._dist_hyper_3_11_chunk | {db_dist_move_chunk_3}
|
||||||
|
_timescaledb_internal._dist_hyper_3_12_chunk | {db_dist_move_chunk_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
RESET ROLE;
|
||||||
|
DROP DATABASE :DATA_NODE_1 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_2 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_3 WITH (FORCE);
|
227
tsl/test/expected/dist_views-14.out
Normal file
227
tsl/test/expected/dist_views-14.out
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
-- 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.
|
||||||
|
---------------------------------------------------
|
||||||
|
-- Test views and size_utils functions on distributed hypertable
|
||||||
|
---------------------------------------------------
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER
|
||||||
|
\set DATA_NODE_1 :TEST_DBNAME _1
|
||||||
|
\set DATA_NODE_2 :TEST_DBNAME _2
|
||||||
|
\set DATA_NODE_3 :TEST_DBNAME _3
|
||||||
|
SELECT node_name, database, node_created, database_created, extension_created
|
||||||
|
FROM (
|
||||||
|
SELECT (add_data_node(name, host => 'localhost', DATABASE => name)).*
|
||||||
|
FROM (VALUES (:'DATA_NODE_1'), (:'DATA_NODE_2'), (:'DATA_NODE_3')) v(name)
|
||||||
|
) a;
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
node_name | database | node_created | database_created | extension_created
|
||||||
|
-----------------+-----------------+--------------+------------------+-------------------
|
||||||
|
db_dist_views_1 | db_dist_views_1 | t | t | t
|
||||||
|
db_dist_views_2 | db_dist_views_2 | t | t | t
|
||||||
|
db_dist_views_3 | db_dist_views_3 | t | t | t
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
GRANT USAGE ON FOREIGN SERVER :DATA_NODE_1, :DATA_NODE_2, :DATA_NODE_3 TO :ROLE_1;
|
||||||
|
GRANT CREATE ON SCHEMA public TO :ROLE_1;
|
||||||
|
SET client_min_messages TO NOTICE;
|
||||||
|
SET ROLE :ROLE_1;
|
||||||
|
SELECT setseed(1);
|
||||||
|
setseed
|
||||||
|
---------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TABLE dist_table(time timestamptz NOT NULL, device int, temp float, timedim date NOT NULL);
|
||||||
|
SELECT create_distributed_hypertable('dist_table', 'time', 'device', replication_factor => 2);
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(1,public,dist_table,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT add_dimension('dist_table', 'timedim', chunk_time_interval=>'7 days'::interval);
|
||||||
|
add_dimension
|
||||||
|
---------------------------------
|
||||||
|
(3,public,dist_table,timedim,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO dist_table SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 80, '2020-01-01'
|
||||||
|
FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-04 1:00', '1 hour') t;
|
||||||
|
ALTER TABLE dist_table SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby = 'time DESC');
|
||||||
|
-- Test views with compression
|
||||||
|
BEGIN;
|
||||||
|
SELECT compress_chunk(chunk)
|
||||||
|
FROM show_chunks('dist_table') AS chunk
|
||||||
|
ORDER BY chunk
|
||||||
|
LIMIT 1;
|
||||||
|
compress_chunk
|
||||||
|
---------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM timescaledb_information.hypertables
|
||||||
|
WHERE hypertable_name = 'dist_table';
|
||||||
|
hypertable_schema | hypertable_name | owner | num_dimensions | num_chunks | compression_enabled | is_distributed | replication_factor | data_nodes | tablespaces
|
||||||
|
-------------------+-----------------+-------------+----------------+------------+---------------------+----------------+--------------------+---------------------------------------------------+-------------
|
||||||
|
public | dist_table | test_role_1 | 3 | 3 | t | t | 2 | {db_dist_views_1,db_dist_views_2,db_dist_views_3} |
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT hypertable_schema,
|
||||||
|
hypertable_name,
|
||||||
|
chunk_schema,
|
||||||
|
chunk_name,
|
||||||
|
primary_dimension,
|
||||||
|
primary_dimension_type,
|
||||||
|
range_start,
|
||||||
|
range_end,
|
||||||
|
range_start_integer,
|
||||||
|
range_end_integer,
|
||||||
|
is_compressed,
|
||||||
|
chunk_tablespace,
|
||||||
|
data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
ORDER BY hypertable_name, chunk_name;
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | primary_dimension | primary_dimension_type | range_start | range_end | range_start_integer | range_end_integer | is_compressed | chunk_tablespace | data_nodes
|
||||||
|
-------------------+-----------------+-----------------------+-----------------------+-------------------+--------------------------+------------------------------+------------------------------+---------------------+-------------------+---------------+------------------+-----------------------------------
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_1_chunk | time | timestamp with time zone | Wed Feb 28 16:00:00 2018 PST | Wed Mar 07 16:00:00 2018 PST | | | t | | {db_dist_views_1,db_dist_views_2}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_2_chunk | time | timestamp with time zone | Wed Feb 28 16:00:00 2018 PST | Wed Mar 07 16:00:00 2018 PST | | | f | | {db_dist_views_2,db_dist_views_3}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_3_chunk | time | timestamp with time zone | Wed Feb 28 16:00:00 2018 PST | Wed Mar 07 16:00:00 2018 PST | | | f | | {db_dist_views_1,db_dist_views_3}
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT * from timescaledb_information.dimensions
|
||||||
|
ORDER BY hypertable_name, dimension_number;
|
||||||
|
hypertable_schema | hypertable_name | dimension_number | column_name | column_type | dimension_type | time_interval | integer_interval | integer_now_func | num_partitions
|
||||||
|
-------------------+-----------------+------------------+-------------+--------------------------+----------------+---------------+------------------+------------------+----------------
|
||||||
|
public | dist_table | 1 | time | timestamp with time zone | Time | @ 7 days | | |
|
||||||
|
public | dist_table | 2 | device | integer | Space | | | | 3
|
||||||
|
public | dist_table | 3 | timedim | date | Time | @ 7 days | | |
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT * FROM chunks_detailed_size('dist_table'::regclass)
|
||||||
|
ORDER BY chunk_name, node_name;
|
||||||
|
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-----------------------+-----------------------+-------------+-------------+-------------+-------------+-----------------
|
||||||
|
_timescaledb_internal | _dist_hyper_1_1_chunk | 16384 | 32768 | 8192 | 57344 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_1_1_chunk | 16384 | 32768 | 8192 | 57344 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_1_2_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_1_2_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_3
|
||||||
|
_timescaledb_internal | _dist_hyper_1_3_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_1_3_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_3
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
|
SELECT * FROM hypertable_detailed_size('dist_table'::regclass)
|
||||||
|
ORDER BY node_name;;
|
||||||
|
table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-------------+-------------+-------------+-------------+-----------------
|
||||||
|
24576 | 81920 | 8192 | 114688 | db_dist_views_1
|
||||||
|
24576 | 81920 | 8192 | 114688 | db_dist_views_2
|
||||||
|
16384 | 81920 | 0 | 98304 | db_dist_views_3
|
||||||
|
0 | 16384 | 0 | 16384 |
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
---tables with special characters in the name ----
|
||||||
|
CREATE TABLE "quote'tab" ( a timestamp, b integer);
|
||||||
|
SELECT create_distributed_hypertable( '"quote''tab"', 'a', 'b', replication_factor=>2, chunk_time_interval=>INTERVAL '1 day');
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
WARNING: column type "timestamp without time zone" used for "a" does not follow best practices
|
||||||
|
NOTICE: adding not-null constraint to column "a"
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(2,public,quote'tab,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT into "quote'tab" select generate_series( '2020-02-02 10:00', '2020-02-05 10:00' , '1 day'::interval), 10;
|
||||||
|
SELECT * FROM chunks_detailed_size( '"quote''tab"') ORDER BY chunk_name, node_name;
|
||||||
|
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-----------------------+-----------------------+-------------+-------------+-------------+-------------+-----------------
|
||||||
|
_timescaledb_internal | _dist_hyper_2_4_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_4_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_2_5_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_5_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_2_6_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_6_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_2_7_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_7_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
(8 rows)
|
||||||
|
|
||||||
|
CREATE TABLE "special#tab" ( a timestamp, b integer);
|
||||||
|
SELECT create_hypertable( 'special#tab', 'a', 'b', replication_factor=>2, chunk_time_interval=>INTERVAL '1 day');
|
||||||
|
WARNING: column type "timestamp without time zone" used for "a" does not follow best practices
|
||||||
|
NOTICE: adding not-null constraint to column "a"
|
||||||
|
create_hypertable
|
||||||
|
--------------------------
|
||||||
|
(3,public,special#tab,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT into "special#tab" select generate_series( '2020-02-02 10:00', '2020-02-05 10:00' , '1 day'::interval), 10;
|
||||||
|
SELECT * FROM chunks_detailed_size( '"special#tab"') ORDER BY chunk_name, node_name;
|
||||||
|
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-----------------------+------------------------+-------------+-------------+-------------+-------------+-----------------
|
||||||
|
_timescaledb_internal | _dist_hyper_3_10_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_10_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_3_11_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_11_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_3_8_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_8_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_3_9_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_9_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
(8 rows)
|
||||||
|
|
||||||
|
SELECT * FROM hypertable_index_size( 'dist_table_time_idx') ;
|
||||||
|
hypertable_index_size
|
||||||
|
-----------------------
|
||||||
|
114688
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Test chunk_replication_status view
|
||||||
|
SELECT * FROM timescaledb_experimental.chunk_replication_status
|
||||||
|
ORDER BY chunk_schema, chunk_name
|
||||||
|
LIMIT 4;
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | desired_num_replicas | num_replicas | replica_nodes | non_replica_nodes
|
||||||
|
-------------------+-----------------+-----------------------+-----------------------+----------------------+--------------+-----------------------------------+-------------------
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_1_chunk | 2 | 2 | {db_dist_views_1,db_dist_views_2} | {db_dist_views_3}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_2_chunk | 2 | 2 | {db_dist_views_2,db_dist_views_3} | {db_dist_views_1}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_3_chunk | 2 | 2 | {db_dist_views_3,db_dist_views_1} | {db_dist_views_2}
|
||||||
|
public | quote'tab | _timescaledb_internal | _dist_hyper_2_4_chunk | 2 | 2 | {db_dist_views_1,db_dist_views_2} | {db_dist_views_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
-- drop one chunk replica
|
||||||
|
SELECT _timescaledb_functions.chunk_drop_replica(format('%I.%I', chunk_schema, chunk_name)::regclass, replica_nodes[1])
|
||||||
|
FROM timescaledb_experimental.chunk_replication_status
|
||||||
|
ORDER BY chunk_schema, chunk_name
|
||||||
|
LIMIT 1;
|
||||||
|
chunk_drop_replica
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM timescaledb_experimental.chunk_replication_status
|
||||||
|
WHERE num_replicas < desired_num_replicas
|
||||||
|
ORDER BY chunk_schema, chunk_name;
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | desired_num_replicas | num_replicas | replica_nodes | non_replica_nodes
|
||||||
|
-------------------+-----------------+-----------------------+-----------------------+----------------------+--------------+-------------------+-----------------------------------
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_1_chunk | 2 | 1 | {db_dist_views_2} | {db_dist_views_1,db_dist_views_3}
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Example usage of finding data nodes to copy/move chunks between
|
||||||
|
SELECT
|
||||||
|
format('%I.%I', chunk_schema, chunk_name)::regclass AS chunk,
|
||||||
|
replica_nodes[1] AS copy_from_node,
|
||||||
|
non_replica_nodes[1] AS copy_to_node
|
||||||
|
FROM
|
||||||
|
timescaledb_experimental.chunk_replication_status
|
||||||
|
WHERE
|
||||||
|
num_replicas < desired_num_replicas
|
||||||
|
ORDER BY
|
||||||
|
chunk_schema, chunk_name;
|
||||||
|
chunk | copy_from_node | copy_to_node
|
||||||
|
---------------------------------------------+-----------------+-----------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk | db_dist_views_2 | db_dist_views_1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER
|
||||||
|
DROP DATABASE :DATA_NODE_1 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_2 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_3 WITH (FORCE);
|
227
tsl/test/expected/dist_views-15.out
Normal file
227
tsl/test/expected/dist_views-15.out
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
-- 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.
|
||||||
|
---------------------------------------------------
|
||||||
|
-- Test views and size_utils functions on distributed hypertable
|
||||||
|
---------------------------------------------------
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER
|
||||||
|
\set DATA_NODE_1 :TEST_DBNAME _1
|
||||||
|
\set DATA_NODE_2 :TEST_DBNAME _2
|
||||||
|
\set DATA_NODE_3 :TEST_DBNAME _3
|
||||||
|
SELECT node_name, database, node_created, database_created, extension_created
|
||||||
|
FROM (
|
||||||
|
SELECT (add_data_node(name, host => 'localhost', DATABASE => name)).*
|
||||||
|
FROM (VALUES (:'DATA_NODE_1'), (:'DATA_NODE_2'), (:'DATA_NODE_3')) v(name)
|
||||||
|
) a;
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
WARNING: adding data node is deprecated
|
||||||
|
node_name | database | node_created | database_created | extension_created
|
||||||
|
-----------------+-----------------+--------------+------------------+-------------------
|
||||||
|
db_dist_views_1 | db_dist_views_1 | t | t | t
|
||||||
|
db_dist_views_2 | db_dist_views_2 | t | t | t
|
||||||
|
db_dist_views_3 | db_dist_views_3 | t | t | t
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
GRANT USAGE ON FOREIGN SERVER :DATA_NODE_1, :DATA_NODE_2, :DATA_NODE_3 TO :ROLE_1;
|
||||||
|
GRANT CREATE ON SCHEMA public TO :ROLE_1;
|
||||||
|
SET client_min_messages TO NOTICE;
|
||||||
|
SET ROLE :ROLE_1;
|
||||||
|
SELECT setseed(1);
|
||||||
|
setseed
|
||||||
|
---------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TABLE dist_table(time timestamptz NOT NULL, device int, temp float, timedim date NOT NULL);
|
||||||
|
SELECT create_distributed_hypertable('dist_table', 'time', 'device', replication_factor => 2);
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(1,public,dist_table,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT add_dimension('dist_table', 'timedim', chunk_time_interval=>'7 days'::interval);
|
||||||
|
add_dimension
|
||||||
|
---------------------------------
|
||||||
|
(3,public,dist_table,timedim,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO dist_table SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 80, '2020-01-01'
|
||||||
|
FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-04 1:00', '1 hour') t;
|
||||||
|
ALTER TABLE dist_table SET (timescaledb.compress, timescaledb.compress_segmentby='device', timescaledb.compress_orderby = 'time DESC');
|
||||||
|
-- Test views with compression
|
||||||
|
BEGIN;
|
||||||
|
SELECT compress_chunk(chunk)
|
||||||
|
FROM show_chunks('dist_table') AS chunk
|
||||||
|
ORDER BY chunk
|
||||||
|
LIMIT 1;
|
||||||
|
compress_chunk
|
||||||
|
---------------------------------------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM timescaledb_information.hypertables
|
||||||
|
WHERE hypertable_name = 'dist_table';
|
||||||
|
hypertable_schema | hypertable_name | owner | num_dimensions | num_chunks | compression_enabled | is_distributed | replication_factor | data_nodes | tablespaces
|
||||||
|
-------------------+-----------------+-------------+----------------+------------+---------------------+----------------+--------------------+---------------------------------------------------+-------------
|
||||||
|
public | dist_table | test_role_1 | 3 | 3 | t | t | 2 | {db_dist_views_1,db_dist_views_2,db_dist_views_3} |
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT hypertable_schema,
|
||||||
|
hypertable_name,
|
||||||
|
chunk_schema,
|
||||||
|
chunk_name,
|
||||||
|
primary_dimension,
|
||||||
|
primary_dimension_type,
|
||||||
|
range_start,
|
||||||
|
range_end,
|
||||||
|
range_start_integer,
|
||||||
|
range_end_integer,
|
||||||
|
is_compressed,
|
||||||
|
chunk_tablespace,
|
||||||
|
data_nodes
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
ORDER BY hypertable_name, chunk_name;
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | primary_dimension | primary_dimension_type | range_start | range_end | range_start_integer | range_end_integer | is_compressed | chunk_tablespace | data_nodes
|
||||||
|
-------------------+-----------------+-----------------------+-----------------------+-------------------+--------------------------+------------------------------+------------------------------+---------------------+-------------------+---------------+------------------+-----------------------------------
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_1_chunk | time | timestamp with time zone | Wed Feb 28 16:00:00 2018 PST | Wed Mar 07 16:00:00 2018 PST | | | t | | {db_dist_views_1,db_dist_views_2}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_2_chunk | time | timestamp with time zone | Wed Feb 28 16:00:00 2018 PST | Wed Mar 07 16:00:00 2018 PST | | | f | | {db_dist_views_2,db_dist_views_3}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_3_chunk | time | timestamp with time zone | Wed Feb 28 16:00:00 2018 PST | Wed Mar 07 16:00:00 2018 PST | | | f | | {db_dist_views_1,db_dist_views_3}
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT * from timescaledb_information.dimensions
|
||||||
|
ORDER BY hypertable_name, dimension_number;
|
||||||
|
hypertable_schema | hypertable_name | dimension_number | column_name | column_type | dimension_type | time_interval | integer_interval | integer_now_func | num_partitions
|
||||||
|
-------------------+-----------------+------------------+-------------+--------------------------+----------------+---------------+------------------+------------------+----------------
|
||||||
|
public | dist_table | 1 | time | timestamp with time zone | Time | @ 7 days | | |
|
||||||
|
public | dist_table | 2 | device | integer | Space | | | | 3
|
||||||
|
public | dist_table | 3 | timedim | date | Time | @ 7 days | | |
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT * FROM chunks_detailed_size('dist_table'::regclass)
|
||||||
|
ORDER BY chunk_name, node_name;
|
||||||
|
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-----------------------+-----------------------+-------------+-------------+-------------+-------------+-----------------
|
||||||
|
_timescaledb_internal | _dist_hyper_1_1_chunk | 16384 | 32768 | 8192 | 57344 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_1_1_chunk | 16384 | 32768 | 8192 | 57344 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_1_2_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_1_2_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_3
|
||||||
|
_timescaledb_internal | _dist_hyper_1_3_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_1_3_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_3
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
|
SELECT * FROM hypertable_detailed_size('dist_table'::regclass)
|
||||||
|
ORDER BY node_name;;
|
||||||
|
table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-------------+-------------+-------------+-------------+-----------------
|
||||||
|
24576 | 81920 | 8192 | 114688 | db_dist_views_1
|
||||||
|
24576 | 81920 | 8192 | 114688 | db_dist_views_2
|
||||||
|
16384 | 81920 | 0 | 98304 | db_dist_views_3
|
||||||
|
0 | 16384 | 0 | 16384 |
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
---tables with special characters in the name ----
|
||||||
|
CREATE TABLE "quote'tab" ( a timestamp, b integer);
|
||||||
|
SELECT create_distributed_hypertable( '"quote''tab"', 'a', 'b', replication_factor=>2, chunk_time_interval=>INTERVAL '1 day');
|
||||||
|
WARNING: distributed hypertable is deprecated
|
||||||
|
WARNING: column type "timestamp without time zone" used for "a" does not follow best practices
|
||||||
|
NOTICE: adding not-null constraint to column "a"
|
||||||
|
create_distributed_hypertable
|
||||||
|
-------------------------------
|
||||||
|
(2,public,quote'tab,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT into "quote'tab" select generate_series( '2020-02-02 10:00', '2020-02-05 10:00' , '1 day'::interval), 10;
|
||||||
|
SELECT * FROM chunks_detailed_size( '"quote''tab"') ORDER BY chunk_name, node_name;
|
||||||
|
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-----------------------+-----------------------+-------------+-------------+-------------+-------------+-----------------
|
||||||
|
_timescaledb_internal | _dist_hyper_2_4_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_4_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_2_5_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_5_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_2_6_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_6_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_2_7_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_2_7_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
(8 rows)
|
||||||
|
|
||||||
|
CREATE TABLE "special#tab" ( a timestamp, b integer);
|
||||||
|
SELECT create_hypertable( 'special#tab', 'a', 'b', replication_factor=>2, chunk_time_interval=>INTERVAL '1 day');
|
||||||
|
WARNING: column type "timestamp without time zone" used for "a" does not follow best practices
|
||||||
|
NOTICE: adding not-null constraint to column "a"
|
||||||
|
create_hypertable
|
||||||
|
--------------------------
|
||||||
|
(3,public,special#tab,t)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT into "special#tab" select generate_series( '2020-02-02 10:00', '2020-02-05 10:00' , '1 day'::interval), 10;
|
||||||
|
SELECT * FROM chunks_detailed_size( '"special#tab"') ORDER BY chunk_name, node_name;
|
||||||
|
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
|
||||||
|
-----------------------+------------------------+-------------+-------------+-------------+-------------+-----------------
|
||||||
|
_timescaledb_internal | _dist_hyper_3_10_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_10_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_3_11_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_11_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_3_8_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_8_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
_timescaledb_internal | _dist_hyper_3_9_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_1
|
||||||
|
_timescaledb_internal | _dist_hyper_3_9_chunk | 8192 | 32768 | 0 | 40960 | db_dist_views_2
|
||||||
|
(8 rows)
|
||||||
|
|
||||||
|
SELECT * FROM hypertable_index_size( 'dist_table_time_idx') ;
|
||||||
|
hypertable_index_size
|
||||||
|
-----------------------
|
||||||
|
114688
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Test chunk_replication_status view
|
||||||
|
SELECT * FROM timescaledb_experimental.chunk_replication_status
|
||||||
|
ORDER BY chunk_schema, chunk_name
|
||||||
|
LIMIT 4;
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | desired_num_replicas | num_replicas | replica_nodes | non_replica_nodes
|
||||||
|
-------------------+-----------------+-----------------------+-----------------------+----------------------+--------------+-----------------------------------+-------------------
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_1_chunk | 2 | 2 | {db_dist_views_1,db_dist_views_2} | {db_dist_views_3}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_2_chunk | 2 | 2 | {db_dist_views_2,db_dist_views_3} | {db_dist_views_1}
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_3_chunk | 2 | 2 | {db_dist_views_3,db_dist_views_1} | {db_dist_views_2}
|
||||||
|
public | quote'tab | _timescaledb_internal | _dist_hyper_2_4_chunk | 2 | 2 | {db_dist_views_1,db_dist_views_2} | {db_dist_views_3}
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
-- drop one chunk replica
|
||||||
|
SELECT _timescaledb_functions.chunk_drop_replica(format('%I.%I', chunk_schema, chunk_name)::regclass, replica_nodes[1])
|
||||||
|
FROM timescaledb_experimental.chunk_replication_status
|
||||||
|
ORDER BY chunk_schema, chunk_name
|
||||||
|
LIMIT 1;
|
||||||
|
chunk_drop_replica
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM timescaledb_experimental.chunk_replication_status
|
||||||
|
WHERE num_replicas < desired_num_replicas
|
||||||
|
ORDER BY chunk_schema, chunk_name;
|
||||||
|
hypertable_schema | hypertable_name | chunk_schema | chunk_name | desired_num_replicas | num_replicas | replica_nodes | non_replica_nodes
|
||||||
|
-------------------+-----------------+-----------------------+-----------------------+----------------------+--------------+-------------------+-----------------------------------
|
||||||
|
public | dist_table | _timescaledb_internal | _dist_hyper_1_1_chunk | 2 | 1 | {db_dist_views_2} | {db_dist_views_1,db_dist_views_3}
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Example usage of finding data nodes to copy/move chunks between
|
||||||
|
SELECT
|
||||||
|
format('%I.%I', chunk_schema, chunk_name)::regclass AS chunk,
|
||||||
|
replica_nodes[1] AS copy_from_node,
|
||||||
|
non_replica_nodes[1] AS copy_to_node
|
||||||
|
FROM
|
||||||
|
timescaledb_experimental.chunk_replication_status
|
||||||
|
WHERE
|
||||||
|
num_replicas < desired_num_replicas
|
||||||
|
ORDER BY
|
||||||
|
chunk_schema, chunk_name;
|
||||||
|
chunk | copy_from_node | copy_to_node
|
||||||
|
---------------------------------------------+-----------------+-----------------
|
||||||
|
_timescaledb_internal._dist_hyper_1_1_chunk | db_dist_views_2 | db_dist_views_1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER
|
||||||
|
DROP DATABASE :DATA_NODE_1 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_2 WITH (FORCE);
|
||||||
|
DROP DATABASE :DATA_NODE_3 WITH (FORCE);
|
3
tsl/test/sql/.gitignore
vendored
3
tsl/test/sql/.gitignore
vendored
@ -24,6 +24,9 @@
|
|||||||
/dist_ref_table_join-*.sql
|
/dist_ref_table_join-*.sql
|
||||||
/dist_remote_error-*.sql
|
/dist_remote_error-*.sql
|
||||||
/dist_remote_error.text
|
/dist_remote_error.text
|
||||||
|
/dist_views-*.sql
|
||||||
|
/dist_compression-*.sql
|
||||||
|
/dist_move_chunk-*.sql
|
||||||
/hypertable_distributed-*.sql
|
/hypertable_distributed-*.sql
|
||||||
/jit-*.sql
|
/jit-*.sql
|
||||||
/modify_exclusion-*.sql
|
/modify_exclusion-*.sql
|
||||||
|
@ -29,7 +29,7 @@ set(TEST_FILES
|
|||||||
size_utils_tsl.sql)
|
size_utils_tsl.sql)
|
||||||
|
|
||||||
if(ENABLE_MULTINODE_TESTS AND ${PG_VERSION_MAJOR} LESS "16")
|
if(ENABLE_MULTINODE_TESTS AND ${PG_VERSION_MAJOR} LESS "16")
|
||||||
list(APPEND TEST_FILES dist_param.sql dist_views.sql)
|
list(APPEND TEST_FILES dist_param.sql)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_TELEMETRY)
|
if(USE_TELEMETRY)
|
||||||
@ -99,13 +99,11 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|||||||
debug_notice.sql
|
debug_notice.sql
|
||||||
dist_api_calls.sql
|
dist_api_calls.sql
|
||||||
dist_commands.sql
|
dist_commands.sql
|
||||||
dist_compression.sql
|
|
||||||
dist_copy_available_dns.sql
|
dist_copy_available_dns.sql
|
||||||
dist_copy_format_long.sql
|
dist_copy_format_long.sql
|
||||||
dist_copy_long.sql
|
dist_copy_long.sql
|
||||||
dist_ddl.sql
|
dist_ddl.sql
|
||||||
dist_cagg.sql
|
dist_cagg.sql
|
||||||
dist_move_chunk.sql
|
|
||||||
dist_policy.sql
|
dist_policy.sql
|
||||||
dist_util.sql
|
dist_util.sql
|
||||||
dist_triggers.sql
|
dist_triggers.sql
|
||||||
@ -213,10 +211,16 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|||||||
dist_ref_table_join.sql.in
|
dist_ref_table_join.sql.in
|
||||||
dist_remote_error.sql.in
|
dist_remote_error.sql.in
|
||||||
dist_partial_agg.sql.in
|
dist_partial_agg.sql.in
|
||||||
dist_query.sql.in)
|
dist_query.sql.in
|
||||||
|
dist_compression.sql.in
|
||||||
|
dist_move_chunk.sql.in)
|
||||||
endif()
|
endif()
|
||||||
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
|
|
||||||
|
if(ENABLE_MULTINODE_TESTS AND ${PG_VERSION_MAJOR} LESS "16")
|
||||||
|
list(APPEND TEST_TEMPLATES dist_views.sql.in)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Check if PostgreSQL was compiled with JIT support
|
# Check if PostgreSQL was compiled with JIT support
|
||||||
set(PG_CONFIG_H "${PG_INCLUDEDIR}/pg_config.h")
|
set(PG_CONFIG_H "${PG_INCLUDEDIR}/pg_config.h")
|
||||||
if(EXISTS ${PG_CONFIG_H})
|
if(EXISTS ${PG_CONFIG_H})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user