citus/src/test/regress/expected/multi_move_mx.out

235 lines
7.5 KiB
Plaintext

--
-- MULTI_MOVE_MX
--
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 1550000;
SELECT start_metadata_sync_to_node('localhost', :worker_2_port);
start_metadata_sync_to_node
---------------------------------------------------------------------
(1 row)
-- Create mx test tables
SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1;
CREATE TABLE mx_table_1 (a int);
SELECT create_distributed_table('mx_table_1', 'a');
create_distributed_table
---------------------------------------------------------------------
(1 row)
CREATE TABLE mx_table_2 (a int);
SELECT create_distributed_table('mx_table_2', 'a');
create_distributed_table
---------------------------------------------------------------------
(1 row)
CREATE TABLE mx_table_3 (a text);
SELECT create_distributed_table('mx_table_3', 'a');
create_distributed_table
---------------------------------------------------------------------
(1 row)
-- Check that the first two tables are colocated
SELECT
logicalrelid, repmodel
FROM
pg_dist_partition
WHERE
logicalrelid = 'mx_table_1'::regclass
OR logicalrelid = 'mx_table_2'::regclass
OR logicalrelid = 'mx_table_3'::regclass
ORDER BY
logicalrelid;
logicalrelid | repmodel
---------------------------------------------------------------------
mx_table_1 | s
mx_table_2 | s
mx_table_3 | s
(3 rows)
-- Check the list of shards
SELECT
logicalrelid, shardid, nodename, nodeport
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
logicalrelid = 'mx_table_1'::regclass
OR logicalrelid = 'mx_table_2'::regclass
OR logicalrelid = 'mx_table_3'::regclass
ORDER BY
logicalrelid, shardid;
logicalrelid | shardid | nodename | nodeport
---------------------------------------------------------------------
mx_table_1 | 1550000 | localhost | 57637
mx_table_1 | 1550001 | localhost | 57638
mx_table_1 | 1550002 | localhost | 57637
mx_table_1 | 1550003 | localhost | 57638
mx_table_2 | 1550004 | localhost | 57637
mx_table_2 | 1550005 | localhost | 57638
mx_table_2 | 1550006 | localhost | 57637
mx_table_2 | 1550007 | localhost | 57638
mx_table_3 | 1550008 | localhost | 57637
mx_table_3 | 1550009 | localhost | 57638
mx_table_3 | 1550010 | localhost | 57637
mx_table_3 | 1550011 | localhost | 57638
(12 rows)
-- Check the data on the worker
\c - - - :worker_2_port
SELECT
logicalrelid, shardid, nodename, nodeport
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
logicalrelid = 'mx_table_1'::regclass
OR logicalrelid = 'mx_table_2'::regclass
OR logicalrelid = 'mx_table_3'::regclass
ORDER BY
logicalrelid, shardid;
logicalrelid | shardid | nodename | nodeport
---------------------------------------------------------------------
mx_table_1 | 1550000 | localhost | 57637
mx_table_1 | 1550001 | localhost | 57638
mx_table_1 | 1550002 | localhost | 57637
mx_table_1 | 1550003 | localhost | 57638
mx_table_2 | 1550004 | localhost | 57637
mx_table_2 | 1550005 | localhost | 57638
mx_table_2 | 1550006 | localhost | 57637
mx_table_2 | 1550007 | localhost | 57638
mx_table_3 | 1550008 | localhost | 57637
mx_table_3 | 1550009 | localhost | 57638
mx_table_3 | 1550010 | localhost | 57637
mx_table_3 | 1550011 | localhost | 57638
(12 rows)
\c - - - :master_port
-- Check that master_copy_shard_placement cannot be run with MX tables
SELECT
master_copy_shard_placement(shardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port, false, 'force_logical')
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
logicalrelid = 'mx_table_1'::regclass
AND nodeport = :worker_1_port
ORDER BY
shardid
LIMIT 1;
ERROR: the force_logical transfer mode is currently unsupported
-- Move a shard from worker 1 to worker 2
SELECT
master_move_shard_placement(shardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port)
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
logicalrelid = 'mx_table_1'::regclass
AND nodeport = :worker_1_port
ORDER BY
shardid
LIMIT 1;
master_move_shard_placement
---------------------------------------------------------------------
(1 row)
-- Check that the shard and its colocated shard is moved, but not the other shards
SELECT
logicalrelid, shardid, nodename, nodeport
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
(logicalrelid = 'mx_table_1'::regclass
OR logicalrelid = 'mx_table_2'::regclass
OR logicalrelid = 'mx_table_3'::regclass)
AND shardstate != 4
ORDER BY
logicalrelid, shardid;
logicalrelid | shardid | nodename | nodeport
---------------------------------------------------------------------
mx_table_1 | 1550000 | localhost | 57638
mx_table_1 | 1550001 | localhost | 57638
mx_table_1 | 1550002 | localhost | 57637
mx_table_1 | 1550003 | localhost | 57638
mx_table_2 | 1550004 | localhost | 57638
mx_table_2 | 1550005 | localhost | 57638
mx_table_2 | 1550006 | localhost | 57637
mx_table_2 | 1550007 | localhost | 57638
mx_table_3 | 1550008 | localhost | 57637
mx_table_3 | 1550009 | localhost | 57638
mx_table_3 | 1550010 | localhost | 57637
mx_table_3 | 1550011 | localhost | 57638
(12 rows)
-- Check that the changes are made in the worker as well
\c - - - :worker_2_port
SELECT
logicalrelid, shardid, nodename, nodeport
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
logicalrelid = 'mx_table_1'::regclass
OR logicalrelid = 'mx_table_2'::regclass
OR logicalrelid = 'mx_table_3'::regclass
ORDER BY
logicalrelid, shardid;
logicalrelid | shardid | nodename | nodeport
---------------------------------------------------------------------
mx_table_1 | 1550000 | localhost | 57638
mx_table_1 | 1550001 | localhost | 57638
mx_table_1 | 1550002 | localhost | 57637
mx_table_1 | 1550003 | localhost | 57638
mx_table_2 | 1550004 | localhost | 57638
mx_table_2 | 1550005 | localhost | 57638
mx_table_2 | 1550006 | localhost | 57637
mx_table_2 | 1550007 | localhost | 57638
mx_table_3 | 1550008 | localhost | 57637
mx_table_3 | 1550009 | localhost | 57638
mx_table_3 | 1550010 | localhost | 57637
mx_table_3 | 1550011 | localhost | 57638
(12 rows)
-- Check that the UDFs cannot be called from the workers
SELECT
master_copy_shard_placement(shardid, 'localhost', :worker_2_port, 'localhost', :worker_1_port, false, 'force_logical')
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
logicalrelid = 'mx_table_1'::regclass
AND nodeport = :worker_2_port
ORDER BY
shardid
LIMIT 1 OFFSET 1;
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
SELECT
master_move_shard_placement(shardid, 'localhost', :worker_2_port, 'localhost', :worker_1_port, 'force_logical')
FROM
pg_dist_shard NATURAL JOIN pg_dist_shard_placement
WHERE
logicalrelid = 'mx_table_1'::regclass
AND nodeport = :worker_2_port
ORDER BY
shardid
LIMIT 1 OFFSET 1;
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
-- Cleanup
\c - - - :master_port
DROP TABLE mx_table_1;
DROP TABLE mx_table_2;
DROP TABLE mx_table_3;
SELECT stop_metadata_sync_to_node('localhost', :worker_2_port);
NOTICE: dropping metadata on the node (localhost,57638)
stop_metadata_sync_to_node
---------------------------------------------------------------------
(1 row)
\c - - - :worker_2_port
DELETE FROM pg_dist_node;
DELETE FROM pg_dist_partition;
DELETE FROM pg_dist_shard;
DELETE FROM pg_dist_shard_placement;