fix, the ommission of reference table colocation group unders certain circumstances because it breaks tests

onder/fix/reference-lock-contention
Nils Dijk 2022-08-12 15:17:33 +02:00
parent 5f73e44d7c
commit 4a290560b2
No known key found for this signature in database
GPG Key ID: CA1177EF9434F241
5 changed files with 8 additions and 11 deletions

View File

@ -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))

View File

@ -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)))

View File

@ -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;

View File

@ -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

View File

@ -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);