diff --git a/src/backend/distributed/operations/stage_protocol.c b/src/backend/distributed/operations/stage_protocol.c index 891d3fb7e..f2e45e473 100644 --- a/src/backend/distributed/operations/stage_protocol.c +++ b/src/backend/distributed/operations/stage_protocol.c @@ -415,7 +415,7 @@ CreateAppendDistributedShardPlacements(Oid relationId, int64 shardId, if (NodeIsCoordinator(workerNode)) { ereport(NOTICE, (errmsg( - "Creating placements for the append partitioned tables on the coordinator is not allowed."))); + "Creating placements for the append partitioned tables on the coordinator is not supported, skipping coordinator ..."))); continue; } diff --git a/src/test/regress/expected/coordinator_shouldhaveshards.out b/src/test/regress/expected/coordinator_shouldhaveshards.out index c847efb87..55a4febac 100644 --- a/src/test/regress/expected/coordinator_shouldhaveshards.out +++ b/src/test/regress/expected/coordinator_shouldhaveshards.out @@ -510,6 +510,36 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM (coordinat (1 row) ROLLBACK; +-- issue #4237: preventing empty placement creation on coordinator +CREATE TABLE test_append_table(a int); +SELECT create_distributed_table('test_append_table', 'a', 'append'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +-- this will fail since it will try to create an empty placement in the +-- coordinator as well +SET citus.shard_replication_factor TO 3; +SELECT master_create_empty_shard('test_append_table'); +NOTICE: Creating placements for the append partitioned tables on the coordinator is not supported, skipping coordinator ... +ERROR: could only create 2 of 3 of required shard replicas +-- this will create an empty shard with replicas in the two worker nodes +SET citus.shard_replication_factor TO 2; +SELECT 1 FROM master_create_empty_shard('test_append_table'); + ?column? +--------------------------------------------------------------------- + 1 +(1 row) + +-- verify groupid is not 0 for each placement +SELECT COUNT(*) FROM pg_dist_placement p, pg_dist_shard s WHERE p.shardid = s.shardid AND s.logicalrelid = 'test_append_table'::regclass AND p.groupid > 0; + count +--------------------------------------------------------------------- + 2 +(1 row) + +SET citus.shard_replication_factor TO 1; \set VERBOSITY terse DROP TABLE ref_table; NOTICE: executing the command locally: DROP TABLE IF EXISTS coordinator_shouldhaveshards.ref_table_xxxxx CASCADE @@ -518,6 +548,7 @@ DROP TABLE test; DROP TABLE dist_table; DROP TABLE ref; NOTICE: executing the command locally: DROP TABLE IF EXISTS coordinator_shouldhaveshards.ref_xxxxx CASCADE +DROP TABLE test_append_table; DROP SCHEMA coordinator_shouldhaveshards CASCADE; NOTICE: drop cascades to table local SELECT 1 FROM master_set_node_property('localhost', :master_port, 'shouldhaveshards', false); diff --git a/src/test/regress/sql/coordinator_shouldhaveshards.sql b/src/test/regress/sql/coordinator_shouldhaveshards.sql index 7c1157610..944842355 100644 --- a/src/test/regress/sql/coordinator_shouldhaveshards.sql +++ b/src/test/regress/sql/coordinator_shouldhaveshards.sql @@ -214,6 +214,20 @@ INSERT INTO ref_table SELECT *, * FROM generate_series(1, 100); SELECT COUNT(*) FROM test JOIN ref_table USING(x); ROLLBACK; +-- issue #4237: preventing empty placement creation on coordinator +CREATE TABLE test_append_table(a int); +SELECT create_distributed_table('test_append_table', 'a', 'append'); +-- this will fail since it will try to create an empty placement in the +-- coordinator as well +SET citus.shard_replication_factor TO 3; +SELECT master_create_empty_shard('test_append_table'); +-- this will create an empty shard with replicas in the two worker nodes +SET citus.shard_replication_factor TO 2; +SELECT 1 FROM master_create_empty_shard('test_append_table'); +-- verify groupid is not 0 for each placement +SELECT COUNT(*) FROM pg_dist_placement p, pg_dist_shard s WHERE p.shardid = s.shardid AND s.logicalrelid = 'test_append_table'::regclass AND p.groupid > 0; +SET citus.shard_replication_factor TO 1; + \set VERBOSITY terse DROP TABLE ref_table; @@ -221,6 +235,7 @@ DELETE FROM test; DROP TABLE test; DROP TABLE dist_table; DROP TABLE ref; +DROP TABLE test_append_table; DROP SCHEMA coordinator_shouldhaveshards CASCADE;