From 362d72853c04584f89e8da9183a5451b0db64654 Mon Sep 17 00:00:00 2001 From: SaitTalhaNisanci Date: Thu, 9 Apr 2020 10:10:49 +0300 Subject: [PATCH] return early in ExecuteTaskListExtended (#3738) It is possible to return an error in ExecuteTaskListExtended after performing local execution with the current structure. However there is no point in execution the local tasks if we are going to return an error later. So the local execution is moved after the error check. --- src/backend/distributed/executor/adaptive_executor.c | 5 ++--- src/backend/distributed/executor/local_executor.c | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/executor/adaptive_executor.c b/src/backend/distributed/executor/adaptive_executor.c index 330f2a410..c79ef0f18 100644 --- a/src/backend/distributed/executor/adaptive_executor.c +++ b/src/backend/distributed/executor/adaptive_executor.c @@ -961,11 +961,8 @@ ExecuteTaskListExtended(RowModifyLevel modLevel, List *taskList, if (localExecutionSupported && ShouldExecuteTasksLocally(taskList)) { bool readOnlyPlan = false; - - /* set local (if any) & remote tasks */ ExtractLocalAndRemoteTasks(readOnlyPlan, taskList, &localTaskList, &remoteTaskList); - locallyProcessedRows += ExecuteLocalTaskList(localTaskList, tupleStore); } else { @@ -983,6 +980,8 @@ ExecuteTaskListExtended(RowModifyLevel modLevel, List *taskList, ErrorIfTransactionAccessedPlacementsLocally(); } + locallyProcessedRows += ExecuteLocalTaskList(localTaskList, tupleStore); + if (MultiShardConnectionType == SEQUENTIAL_CONNECTION) { targetPoolSize = 1; diff --git a/src/backend/distributed/executor/local_executor.c b/src/backend/distributed/executor/local_executor.c index e2a91079b..df3818883 100644 --- a/src/backend/distributed/executor/local_executor.c +++ b/src/backend/distributed/executor/local_executor.c @@ -136,6 +136,10 @@ static void LocallyExecuteUdfTaskQuery(Query *localUdfCommandQuery); uint64 ExecuteLocalTaskList(List *taskList, Tuplestorestate *tupleStoreState) { + if (list_length(taskList) == 0) + { + return 0; + } DistributedPlan *distributedPlan = NULL; ParamListInfo paramListInfo = NULL; return ExecuteLocalTaskListExtended(taskList, paramListInfo, distributedPlan,