diff --git a/src/backend/distributed/connection/connection_management.c b/src/backend/distributed/connection/connection_management.c index 2e6bce06b..1354f8ebd 100644 --- a/src/backend/distributed/connection/connection_management.c +++ b/src/backend/distributed/connection/connection_management.c @@ -616,7 +616,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); }