pull/4271/merge
Nils Dijk 2025-06-24 07:47:14 -07:00 committed by GitHub
commit d259685550
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -792,7 +792,17 @@ ShutdownConnection(MultiConnection *connection)
if (PQstatus(connection->pgConn) == CONNECTION_OK &&
PQtransactionStatus(connection->pgConn) == PQTRANS_ACTIVE)
{
SendCancelationRequest(connection);
bool sentCancel = SendCancelationRequest(connection);
if (sentCancel)
{
/*
* If we have sent a cancelation we need to wait and consume the response to
* make sure the cancelation is processed. In case of network delay
* cancelation might hit other backend/query. Poolers might introduce out of
* order delivery.
*/
ClearResultsDiscardWarnings(connection, false);
}
}
CitusPQFinish(connection);
}

View File

@ -1178,6 +1178,12 @@ SendCancelationRequest(MultiConnection *connection)
{
char errorBuffer[ERROR_BUFFER_SIZE] = { 0 };
if (!PQisBusy(connection->pgConn))
{
/* no statement in progress, nothing to cancel */
return false;
}
PGcancel *cancelObject = PQgetCancel(connection->pgConn);
if (cancelObject == NULL)
{