mirror of https://github.com/citusdata/citus.git
Use ModifyWaitEvent when only wait flags changed
parent
cd2905ec23
commit
71ad5c095b
|
@ -386,6 +386,9 @@ typedef struct WorkerSession
|
||||||
* distributed transaction related commands such as BEGIN/COMMIT etc.
|
* distributed transaction related commands such as BEGIN/COMMIT etc.
|
||||||
*/
|
*/
|
||||||
uint64 commandsSent;
|
uint64 commandsSent;
|
||||||
|
|
||||||
|
/* index in the wait event set */
|
||||||
|
int waitEventSetIndex;
|
||||||
} WorkerSession;
|
} WorkerSession;
|
||||||
|
|
||||||
|
|
||||||
|
@ -540,6 +543,7 @@ static int UsableConnectionCount(WorkerPool *workerPool);
|
||||||
static long NextEventTimeout(DistributedExecution *execution);
|
static long NextEventTimeout(DistributedExecution *execution);
|
||||||
static long MillisecondsBetweenTimestamps(TimestampTz startTime, TimestampTz endTime);
|
static long MillisecondsBetweenTimestamps(TimestampTz startTime, TimestampTz endTime);
|
||||||
static WaitEventSet * BuildWaitEventSet(List *sessionList);
|
static WaitEventSet * BuildWaitEventSet(List *sessionList);
|
||||||
|
static void UpdateWaitEventSetFlags(WaitEventSet *waitEventSet, List *sessionList);
|
||||||
static TaskPlacementExecution * PopPlacementExecution(WorkerSession *session);
|
static TaskPlacementExecution * PopPlacementExecution(WorkerSession *session);
|
||||||
static TaskPlacementExecution * PopAssignedPlacementExecution(WorkerSession *session);
|
static TaskPlacementExecution * PopAssignedPlacementExecution(WorkerSession *session);
|
||||||
static TaskPlacementExecution * PopUnassignedPlacementExecution(WorkerPool *workerPool);
|
static TaskPlacementExecution * PopUnassignedPlacementExecution(WorkerPool *workerPool);
|
||||||
|
@ -1647,14 +1651,12 @@ RunDistributedExecution(DistributedExecution *execution)
|
||||||
ManageWorkerPool(workerPool);
|
ManageWorkerPool(workerPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execution->connectionSetChanged || execution->waitFlagsChanged)
|
if (execution->connectionSetChanged)
|
||||||
{
|
{
|
||||||
FreeWaitEventSet(execution->waitEventSet);
|
FreeWaitEventSet(execution->waitEventSet);
|
||||||
|
|
||||||
execution->waitEventSet = BuildWaitEventSet(execution->sessionList);
|
execution->waitEventSet = BuildWaitEventSet(execution->sessionList);
|
||||||
|
|
||||||
if (execution->connectionSetChanged)
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* The execution might take a while, so explicitly free at this point
|
* The execution might take a while, so explicitly free at this point
|
||||||
* because we don't need anymore.
|
* because we don't need anymore.
|
||||||
|
@ -1665,11 +1667,15 @@ RunDistributedExecution(DistributedExecution *execution)
|
||||||
eventSetSize = list_length(execution->sessionList) + 2;
|
eventSetSize = list_length(execution->sessionList) + 2;
|
||||||
|
|
||||||
events = palloc0(eventSetSize * sizeof(WaitEvent));
|
events = palloc0(eventSetSize * sizeof(WaitEvent));
|
||||||
}
|
|
||||||
|
|
||||||
execution->connectionSetChanged = false;
|
execution->connectionSetChanged = false;
|
||||||
execution->waitFlagsChanged = false;
|
execution->waitFlagsChanged = false;
|
||||||
}
|
}
|
||||||
|
else if (execution->waitFlagsChanged)
|
||||||
|
{
|
||||||
|
UpdateWaitEventSetFlags(execution->waitEventSet, execution->sessionList);
|
||||||
|
execution->waitFlagsChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
/* wait for I/O events */
|
/* wait for I/O events */
|
||||||
#if (PG_VERSION_NUM >= 100000)
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
@ -3413,6 +3419,7 @@ BuildWaitEventSet(List *sessionList)
|
||||||
WorkerSession *session = lfirst(sessionCell);
|
WorkerSession *session = lfirst(sessionCell);
|
||||||
MultiConnection *connection = session->connection;
|
MultiConnection *connection = session->connection;
|
||||||
int socket = 0;
|
int socket = 0;
|
||||||
|
int waitEventSetIndex = 0;
|
||||||
|
|
||||||
if (connection->pgConn == NULL)
|
if (connection->pgConn == NULL)
|
||||||
{
|
{
|
||||||
|
@ -3433,8 +3440,9 @@ BuildWaitEventSet(List *sessionList)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddWaitEventToSet(waitEventSet, connection->waitFlags, socket, NULL,
|
waitEventSetIndex = AddWaitEventToSet(waitEventSet, connection->waitFlags, socket,
|
||||||
(void *) session);
|
NULL, (void *) session);
|
||||||
|
session->waitEventSetIndex = waitEventSetIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddWaitEventToSet(waitEventSet, WL_POSTMASTER_DEATH, PGINVALID_SOCKET, NULL, NULL);
|
AddWaitEventToSet(waitEventSet, WL_POSTMASTER_DEATH, PGINVALID_SOCKET, NULL, NULL);
|
||||||
|
@ -3444,6 +3452,46 @@ BuildWaitEventSet(List *sessionList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* UpdateWaitEventSetFlags modifies the given waitEventSet with the wait flags
|
||||||
|
* for connections in the sessionList.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
UpdateWaitEventSetFlags(WaitEventSet *waitEventSet, List *sessionList)
|
||||||
|
{
|
||||||
|
ListCell *sessionCell = NULL;
|
||||||
|
|
||||||
|
foreach(sessionCell, sessionList)
|
||||||
|
{
|
||||||
|
WorkerSession *session = lfirst(sessionCell);
|
||||||
|
MultiConnection *connection = session->connection;
|
||||||
|
int socket = 0;
|
||||||
|
int waitEventSetIndex = session->waitEventSetIndex;
|
||||||
|
|
||||||
|
if (connection->pgConn == NULL)
|
||||||
|
{
|
||||||
|
/* connection died earlier in the transaction */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connection->waitFlags == 0)
|
||||||
|
{
|
||||||
|
/* not currently waiting for this connection */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket = PQsocket(connection->pgConn);
|
||||||
|
if (socket == -1)
|
||||||
|
{
|
||||||
|
/* connection was closed */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModifyWaitEvent(waitEventSet, waitEventSetIndex, connection->waitFlags, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SetLocalForceMaxQueryParallelization simply a C interface for
|
* SetLocalForceMaxQueryParallelization simply a C interface for
|
||||||
* setting the following:
|
* setting the following:
|
||||||
|
|
Loading…
Reference in New Issue