preventConflictingFlags
SaitTalhaNisanci 2020-04-09 11:11:16 +03:00
parent fdd401956f
commit ea09b3309b
3 changed files with 16 additions and 2 deletions

View File

@ -381,6 +381,18 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
}
void
SetCriticalConnectionFlag(int *prevFlags, MultiConnectionMode connectionFlag)
{
*prevFlags |= connectionFlag;
if ((*prevFlags & WAIT_FOR_CONNECTION) && (*prevFlags & OPTIONAL_CONNECTION))
{
ereport(ERROR, (errmsg(
"connection cannot have both wait for connection and optional connection flag")));
}
}
/*
* FindAvailableConnection searches the given list of connections for one that
* is not claimed exclusively.

View File

@ -2393,7 +2393,7 @@ ManageWorkerPool(WorkerPool *workerPool)
* remaining are optional. If the executor can get more connections,
* it can increase the parallelism.
*/
connectionFlags |= OPTIONAL_CONNECTION;
SetCriticalConnectionFlag(&connectionFlags, OPTIONAL_CONNECTION);
}
else if (!UseConnectionPerPlacement())
{
@ -2403,7 +2403,7 @@ ManageWorkerPool(WorkerPool *workerPool)
* always finish the execution with a single connection, so wait until we get
* one connection.
*/
connectionFlags |= WAIT_FOR_CONNECTION;
SetCriticalConnectionFlag(&connectionFlags, WAIT_FOR_CONNECTION);
}
/* open a new connection to the worker */

View File

@ -222,6 +222,8 @@ extern void CloseConnection(MultiConnection *connection);
extern void ShutdownAllConnections(void);
extern void ShutdownConnection(MultiConnection *connection);
extern void SetCriticalConnectionFlag(int *prevFlags, MultiConnectionMode connectionFlag);
/* dealing with a connection */
extern void FinishConnectionListEstablishment(List *multiConnectionList);
extern void FinishConnectionEstablishment(MultiConnection *connection);