diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index f5ae0fd7e..793b0086a 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -527,7 +527,7 @@ CreateDistributedTable(Oid relationId, char *distributionColumnName, * This function does not expect to create Citus local table, so we blindly * create reference table when the method is DISTRIBUTE_BY_NONE. */ - CreateReferenceTableShard(relationId, colocatedTableId); + CreateReferenceTableShard(relationId); } if (ShouldSyncTableMetadata(relationId)) diff --git a/src/backend/distributed/commands/table.c b/src/backend/distributed/commands/table.c index e0ffa37f5..f1d27aa22 100644 --- a/src/backend/distributed/commands/table.c +++ b/src/backend/distributed/commands/table.c @@ -158,7 +158,10 @@ PreprocessDropTableStmt(Node *node, const char *queryString, * prevent concurrent mutations to the placements of the shard groups. */ CitusTableCacheEntry *cacheEntry = GetCitusTableCacheEntry(relationId); - LockColocationId(cacheEntry->colocationId, ShareLock); + if (cacheEntry->colocationId != INVALID_COLOCATION_ID) + { + LockColocationId(cacheEntry->colocationId, ShareLock); + } /* invalidate foreign key cache if the table involved in any foreign key */ if ((TableReferenced(relationId) || TableReferencing(relationId))) diff --git a/src/backend/distributed/operations/create_shards.c b/src/backend/distributed/operations/create_shards.c index 53c43cc46..cc75c8171 100644 --- a/src/backend/distributed/operations/create_shards.c +++ b/src/backend/distributed/operations/create_shards.c @@ -326,7 +326,7 @@ CreateColocatedShards(Oid targetRelationId, Oid sourceRelationId, bool * Also, the shard is replicated to the all active nodes in the cluster. */ void -CreateReferenceTableShard(Oid distributedTableId, Oid colocatedTableId) +CreateReferenceTableShard(Oid distributedTableId) { int workerStartIndex = 0; text *shardMinValue = NULL; diff --git a/src/backend/distributed/utils/reference_table_utils.c b/src/backend/distributed/utils/reference_table_utils.c index dd51c1992..705a3a670 100644 --- a/src/backend/distributed/utils/reference_table_utils.c +++ b/src/backend/distributed/utils/reference_table_utils.c @@ -99,13 +99,7 @@ EnsureReferenceTablesExistOnAllNodesExtended(char transferMode) uint64 shardId = INVALID_SHARD_ID; List *newWorkersList = NIL; const char *referenceTableName = NULL; - int colocationId = GetReferenceTableColocationId(); - - if (colocationId == INVALID_COLOCATION_ID) - { - /* no colocation for reference tables available */ - return; - } + int colocationId = CreateReferenceTableColocationId(); /* * Most of the time this function should result in a conclusion where we do not need diff --git a/src/include/distributed/coordinator_protocol.h b/src/include/distributed/coordinator_protocol.h index d41d16a69..501f5c233 100644 --- a/src/include/distributed/coordinator_protocol.h +++ b/src/include/distributed/coordinator_protocol.h @@ -249,7 +249,7 @@ extern void CreateShardsWithRoundRobinPolicy(Oid distributedTableId, int32 shard bool useExclusiveConnections); extern void CreateColocatedShards(Oid targetRelationId, Oid sourceRelationId, bool useExclusiveConnections); -extern void CreateReferenceTableShard(Oid distributedTableId, Oid colocatedTableId); +extern void CreateReferenceTableShard(Oid distributedTableId); extern List * WorkerCreateShardCommandList(Oid relationId, int shardIndex, uint64 shardId, List *ddlCommandList, List *foreignConstraintCommandList);