diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index 931471b55..26cf67f97 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -436,11 +436,6 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName, char replicationModel = DecideDistTableReplicationModel(distributionMethod, colocateWithTableName); - if (replicationModel != REPLICATION_MODEL_STREAMING) - { - ereport(ERROR, (errmsg("cannot create a replicated distributed " - "table concurrently"))); - } /* * we fail transaction before local table conversion if the table could not be colocated with @@ -450,6 +445,19 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName, if (!IsColocateWithDefault(colocateWithTableName) && !IsColocateWithNone( colocateWithTableName)) { + if (replicationModel != REPLICATION_MODEL_STREAMING) + { + ereport(ERROR, (errmsg("cannot create distributed table " + "concurrently because Citus allows " + "concurrent table distribution only when " + "citus.shard_replication_factor = 1"), + errhint("table %s is requested to be colocated " + "with %s which has " + "citus.shard_replication_factor > 1", + get_rel_name(relationId), + colocateWithTableName))); + } + EnsureColocateWithTableIsValid(relationId, distributionMethod, distributionColumnName, colocateWithTableName); diff --git a/src/test/regress/expected/create_distributed_table_concurrently.out b/src/test/regress/expected/create_distributed_table_concurrently.out index 579373af8..1bf366fb3 100644 --- a/src/test/regress/expected/create_distributed_table_concurrently.out +++ b/src/test/regress/expected/create_distributed_table_concurrently.out @@ -47,7 +47,8 @@ select create_distributed_table('dist_1', 'a'); set citus.shard_replication_factor to 1; create table dist_2(a int); select create_distributed_table_concurrently('dist_2', 'a', colocate_with=>'dist_1'); -ERROR: cannot create a replicated distributed table concurrently +ERROR: cannot create distributed table concurrently because Citus allows concurrent table distribution only when citus.shard_replication_factor = 1 +HINT: table dist_2 is requested to be colocated with dist_1 which has citus.shard_replication_factor > 1 begin; select create_distributed_table_concurrently('test','key'); ERROR: create_distributed_table_concurrently cannot run inside a transaction block