Merge pull request #5503 from citusdata/fix_undist_table_test_metadata_sync_fails

Fix fails with metadata syncing in undistribute_table
pull/5506/head
Halil Ozan Akgül 2021-12-03 14:11:06 +03:00 committed by GitHub
commit ae134c209f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 10 deletions

View File

@ -130,6 +130,16 @@ HINT: Use cascade option to undistribute all the relations involved in a foreig
DROP TABLE referenced_table, referencing_table;
-- test distributed foreign tables
-- we expect errors
-- and we need metadata sync off for foreign tables
SELECT stop_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
NOTICE: dropping metadata on the node (localhost,57638)
NOTICE: dropping metadata on the node (localhost,57637)
stop_metadata_sync_to_node
---------------------------------------------------------------------
(2 rows)
CREATE FOREIGN TABLE foreign_table (
id bigint not null,
full_name text not null default ''
@ -145,6 +155,13 @@ NOTICE: foreign-data wrapper "fake_fdw" does not have an extension defined
SELECT undistribute_table('foreign_table');
ERROR: cannot complete operation because it is a foreign table
DROP FOREIGN TABLE foreign_table;
SELECT start_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
start_metadata_sync_to_node
---------------------------------------------------------------------
(2 rows)
-- test partitioned tables
CREATE TABLE partitioned_table (id INT, a INT) PARTITION BY RANGE (id);
CREATE TABLE partitioned_table_1_5 PARTITION OF partitioned_table FOR VALUES FROM (1) TO (5);
@ -164,7 +181,7 @@ SELECT logicalrelid FROM pg_dist_partition WHERE logicalrelid::regclass::text LI
partitioned_table_6_10
(3 rows)
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname LIKE 'partitioned\_table%'$$);
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname SIMILAR TO 'partitioned\_table%\d{3,}'$$);
run_command_on_workers
---------------------------------------------------------------------
(localhost,57637,t,6)
@ -225,7 +242,7 @@ SELECT logicalrelid FROM pg_dist_partition WHERE logicalrelid::regclass::text LI
---------------------------------------------------------------------
(0 rows)
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname LIKE 'partitioned\_table%'$$);
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname SIMILAR TO 'partitioned\_table%\d{3,}'$$);
run_command_on_workers
---------------------------------------------------------------------
(localhost,57637,t,0)

View File

@ -58,12 +58,6 @@ test: pg13 pg12
test: pg14
test: tableam drop_column_partitioned_table
# mx-less tests
test: check_mx
test: turn_mx_off
test: undistribute_table
test: turn_mx_on
# ----------
# Miscellaneous tests to check our query planning behavior
# ----------
@ -97,6 +91,7 @@ test: alter_table_set_access_method
test: alter_distributed_table
test: issue_5248 issue_5099
test: object_propagation_debug
test: undistribute_table
# ---------

View File

@ -54,6 +54,8 @@ DROP TABLE referenced_table, referencing_table;
-- test distributed foreign tables
-- we expect errors
-- and we need metadata sync off for foreign tables
SELECT stop_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
CREATE FOREIGN TABLE foreign_table (
id bigint not null,
full_name text not null default ''
@ -62,6 +64,7 @@ SELECT create_distributed_table('foreign_table', 'id');
SELECT undistribute_table('foreign_table');
DROP FOREIGN TABLE foreign_table;
SELECT start_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
-- test partitioned tables
CREATE TABLE partitioned_table (id INT, a INT) PARTITION BY RANGE (id);
@ -71,7 +74,7 @@ SELECT create_distributed_table('partitioned_table', 'id');
INSERT INTO partitioned_table VALUES (2, 12), (7, 2);
SELECT logicalrelid FROM pg_dist_partition WHERE logicalrelid::regclass::text LIKE 'partitioned\_table%' ORDER BY 1;
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname LIKE 'partitioned\_table%'$$);
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname SIMILAR TO 'partitioned\_table%\d{3,}'$$);
SELECT inhrelid::regclass FROM pg_catalog.pg_inherits WHERE inhparent = 'partitioned_table'::regclass ORDER BY 1;
SELECT * FROM partitioned_table ORDER BY 1, 2;
SELECT * FROM partitioned_table_1_5 ORDER BY 1, 2;
@ -83,7 +86,7 @@ SELECT undistribute_table('partitioned_table_1_5');
SELECT undistribute_table('partitioned_table');
SELECT logicalrelid FROM pg_dist_partition WHERE logicalrelid::regclass::text LIKE 'partitioned\_table%' ORDER BY 1;
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname LIKE 'partitioned\_table%'$$);
SELECT run_command_on_workers($$SELECT COUNT(*) FROM pg_catalog.pg_class WHERE relname SIMILAR TO 'partitioned\_table%\d{3,}'$$);
SELECT inhrelid::regclass FROM pg_catalog.pg_inherits WHERE inhparent = 'partitioned_table'::regclass ORDER BY 1;
SELECT * FROM partitioned_table ORDER BY 1, 2;
SELECT * FROM partitioned_table_1_5 ORDER BY 1, 2;