mirror of https://github.com/citusdata/citus.git
Avoid creating a redundant event set at the start
parent
32e7a80960
commit
4c0c33365e
|
@ -1638,8 +1638,8 @@ RunDistributedExecution(DistributedExecution *execution)
|
||||||
/* additional 2 is for postmaster and latch */
|
/* additional 2 is for postmaster and latch */
|
||||||
int eventSetSize = list_length(execution->sessionList) + 2;
|
int eventSetSize = list_length(execution->sessionList) + 2;
|
||||||
|
|
||||||
execution->waitEventSet = BuildWaitEventSet(execution->sessionList);
|
/* always (re)build the wait event set the first time */
|
||||||
events = palloc0(eventSetSize * sizeof(WaitEvent));
|
execution->connectionSetChanged = true;
|
||||||
|
|
||||||
while (execution->unfinishedTaskCount > 0 && !cancellationReceived)
|
while (execution->unfinishedTaskCount > 0 && !cancellationReceived)
|
||||||
{
|
{
|
||||||
|
@ -1655,16 +1655,24 @@ RunDistributedExecution(DistributedExecution *execution)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execution->connectionSetChanged)
|
if (execution->connectionSetChanged)
|
||||||
|
{
|
||||||
|
if (execution->waitEventSet != NULL)
|
||||||
{
|
{
|
||||||
FreeWaitEventSet(execution->waitEventSet);
|
FreeWaitEventSet(execution->waitEventSet);
|
||||||
|
execution->waitEventSet = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
execution->waitEventSet = BuildWaitEventSet(execution->sessionList);
|
if (events != NULL)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
pfree(events);
|
pfree(events);
|
||||||
|
events = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
execution->waitEventSet = BuildWaitEventSet(execution->sessionList);
|
||||||
|
|
||||||
/* recalculate (and allocate) since the sessions have changed */
|
/* recalculate (and allocate) since the sessions have changed */
|
||||||
eventSetSize = list_length(execution->sessionList) + 2;
|
eventSetSize = list_length(execution->sessionList) + 2;
|
||||||
|
@ -1731,8 +1739,16 @@ RunDistributedExecution(DistributedExecution *execution)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (events != NULL)
|
||||||
|
{
|
||||||
pfree(events);
|
pfree(events);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (execution->waitEventSet != NULL)
|
||||||
|
{
|
||||||
FreeWaitEventSet(execution->waitEventSet);
|
FreeWaitEventSet(execution->waitEventSet);
|
||||||
|
execution->waitEventSet = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
CleanUpSessions(execution);
|
CleanUpSessions(execution);
|
||||||
}
|
}
|
||||||
|
@ -1744,7 +1760,11 @@ RunDistributedExecution(DistributedExecution *execution)
|
||||||
*/
|
*/
|
||||||
UnclaimAllSessionConnections(execution->sessionList);
|
UnclaimAllSessionConnections(execution->sessionList);
|
||||||
|
|
||||||
|
if (execution->waitEventSet != NULL)
|
||||||
|
{
|
||||||
FreeWaitEventSet(execution->waitEventSet);
|
FreeWaitEventSet(execution->waitEventSet);
|
||||||
|
execution->waitEventSet = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
PG_RE_THROW();
|
PG_RE_THROW();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue