mirror of https://github.com/citusdata/citus.git
Don't return in PG_TRY() block when cancellations happen in WaitForConnections(). (#1923)
We shouldn't return in middle of a PG_TRY() block because if we do, we won't reset PG_exception_stack, and later when a re-throw tries to jump to the jump-point which was active in this PG_TRY() block, it seg-faults. We used to return in middle of PG_TRY() block in WaitForConnections() where we checked for cancellations. Whenever cancellations were caught here, Citus crashed. And example was reported by @onderkalaci at #1903.pull/1928/head
parent
8f69973411
commit
5d7c52ffa6
|
@ -781,6 +781,7 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
||||||
|
|
||||||
while (pendingConnectionsStartIndex < totalConnectionCount)
|
while (pendingConnectionsStartIndex < totalConnectionCount)
|
||||||
{
|
{
|
||||||
|
bool cancellationReceived = false;
|
||||||
int eventIndex = 0;
|
int eventIndex = 0;
|
||||||
int eventCount = 0;
|
int eventCount = 0;
|
||||||
long timeout = -1;
|
long timeout = -1;
|
||||||
|
@ -837,9 +838,13 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
||||||
if (InterruptHoldoffCount > 0 && (QueryCancelPending ||
|
if (InterruptHoldoffCount > 0 && (QueryCancelPending ||
|
||||||
ProcDiePending))
|
ProcDiePending))
|
||||||
{
|
{
|
||||||
/* return immediately in case of cancellation */
|
/*
|
||||||
FreeWaitEventSet(waitEventSet);
|
* Break out of event loop immediately in case of cancellation.
|
||||||
return;
|
* We cannot use "return" here inside a PG_TRY() block since
|
||||||
|
* then the exception stack won't be reset.
|
||||||
|
*/
|
||||||
|
cancellationReceived = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -905,6 +910,11 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cancellationReceived)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* move non-ready connections to the back of the array */
|
/* move non-ready connections to the back of the array */
|
||||||
for (connectionIndex = pendingConnectionsStartIndex;
|
for (connectionIndex = pendingConnectionsStartIndex;
|
||||||
connectionIndex < totalConnectionCount; connectionIndex++)
|
connectionIndex < totalConnectionCount; connectionIndex++)
|
||||||
|
|
Loading…
Reference in New Issue