From 6e8605c27b20f0f95726065178f6b38002afe076 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Fri, 18 Nov 2022 16:27:30 +0100 Subject: [PATCH] w --- .../distributed/executor/adaptive_executor.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/backend/distributed/executor/adaptive_executor.c b/src/backend/distributed/executor/adaptive_executor.c index 88702cdae..bcc751d14 100644 --- a/src/backend/distributed/executor/adaptive_executor.c +++ b/src/backend/distributed/executor/adaptive_executor.c @@ -2689,15 +2689,6 @@ RunDistributedExecution(DistributedExecution *execution) } else if (execution->rebuildWaitEventSet) { - if (execution->events != NULL) - { - /* - * The execution might take a while, so explicitly free at this point - * because we don't need anymore. - */ - pfree(execution->events); - execution->events = NULL; - } eventSetSize = RebuildWaitEventSet(execution, false); skipWaitEvents = @@ -2844,6 +2835,16 @@ HasIncompleteConnectionEstablishment(DistributedExecution *execution) static int RebuildWaitEventSet(DistributedExecution *execution, bool socketClosedOnly) { + if (execution->events != NULL) + { + /* + * The execution might take a while, so explicitly free at this point + * because we don't need anymore. + */ + pfree(execution->events); + execution->events = NULL; + } + if (execution->waitEventSet != NULL) { FreeWaitEventSet(execution->waitEventSet); @@ -3413,7 +3414,11 @@ OpenNewConnections(WorkerPool *workerPool, int newConnectionCount, long timeout = 0;/* don't wait */ - int eventCount = WaitEventSetWait(workerPool->distributedExecution->waitEventSet, timeout, workerPool->distributedExecution->events, size, WAIT_EVENT_CLIENT_READ); + int eventCount = + WaitEventSetWait(workerPool->distributedExecution->waitEventSet, + timeout, workerPool->distributedExecution->events, + size, WAIT_EVENT_CLIENT_READ); + ProcessWaitEventsForSocketClosed(workerPool->distributedExecution->events, eventCount); workerPool->distributedExecution->waitFlagsChanged = true;