From e06cf9a8223d42bfe83a7da0d700f3977da79f07 Mon Sep 17 00:00:00 2001 From: Nils Dijk Date: Fri, 23 Oct 2020 15:57:27 +0200 Subject: [PATCH] on shutdown, consume any response before sending shutdown packet --- .../distributed/connection/connection_management.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); }