Defer pool start to first session

preventConflictingFlags
Onder Kalaci 2020-04-01 09:55:25 +02:00
parent 3961f4517b
commit 75fb6556b5
1 changed files with 12 additions and 3 deletions

View File

@ -1946,9 +1946,6 @@ FindOrCreateWorkerPool(DistributedExecution *execution, char *nodeName, int node
workerPool->nodeName = pstrdup(nodeName);
workerPool->nodePort = nodePort;
INSTR_TIME_SET_ZERO(workerPool->poolStartTime);
workerPool->distributedExecution = execution;
/* "open" connections aggressively when there are cached connections */
int nodeConnectionCount = MaxCachedConnectionsPerWorker;
workerPool->maxNewConnectionsPerCycle = Max(1, nodeConnectionCount);
@ -2422,6 +2419,18 @@ ManageWorkerPool(WorkerPool *workerPool)
*/
connection->claimedExclusively = true;
if (list_length(workerPool->sessionList) == 0)
{
/*
* The worker pool has just started to establish connections. We need to
* defer this initilization after StartNodeUserDatabaseConnection()
* because for non-optional connections, we have some logic to wait
* until a connection is allowed to be established for a duration of
* citus.connection_retry_timeout.
*/
INSTR_TIME_SET_ZERO(workerPool->poolStartTime);
}
/* create a session for the connection */
WorkerSession *session = FindOrCreateWorkerSession(workerPool, connection);