From 54e4a105e9345ab0d1cf62a7223cd6d02099fd72 Mon Sep 17 00:00:00 2001 From: Sait Talha Nisanci Date: Fri, 13 Aug 2021 16:49:08 +0300 Subject: [PATCH] wip --- .../distributed/executor/adaptive_executor.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/backend/distributed/executor/adaptive_executor.c b/src/backend/distributed/executor/adaptive_executor.c index ed4ad6b07..3b9038b01 100644 --- a/src/backend/distributed/executor/adaptive_executor.c +++ b/src/backend/distributed/executor/adaptive_executor.c @@ -712,6 +712,7 @@ static void SetAttributeInputMetadata(DistributedExecution *execution, static void LookupTaskPlacementHostAndPort(ShardPlacement *taskPlacement, char **nodeName, int *nodePort); static bool IsDummyPlacement(ShardPlacement *taskPlacement); +static void LockParentShardResouceIfPartitionTaskList(List* taskList); /* * AdaptiveExecutorPreExecutorRun gets called right before postgres starts its executor @@ -1603,6 +1604,9 @@ AcquireExecutorShardLocksForExecution(DistributedExecution *execution) /* acquire the locks for both the remote and local tasks */ List *taskList = execution->remoteAndLocalTaskList; + if (modLevel == ROW_MODIFY_NONE) { + LockParentShardResouceIfPartitionTaskList(taskList); + } if (modLevel <= ROW_MODIFY_READONLY && !SelectForUpdateOnReferenceTable(taskList)) { @@ -1632,6 +1636,22 @@ AcquireExecutorShardLocksForExecution(DistributedExecution *execution) } +static void LockParentShardResouceIfPartitionTaskList(List* taskList) { + if (list_length(taskList) < 1) return; + Task* task = (Task*) linitial(taskList); + uint64 shardId = task->anchorShardId; + if (shardId == INVALID_SHARD_ID) { + return; + } + ShardInterval *shardInterval = LoadShardInterval(shardId); + Oid relationId = shardInterval->relationId; + if (PartitionTable(relationId)) { + LockParentShardResourceIfPartition(shardId, AccessShareLock); + } + + +} + /* * FinishDistributedExecution cleans up resources associated with a * distributed execution.