From 0d791f674097bf01d870547e918ceaae50446f68 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Fri, 30 Jun 2017 18:20:54 -0700 Subject: [PATCH] Cancel statements when closing connection at transaction end. That's important because the currently running statement on a worker might continue to hold locks and consume resources, even after the connection is closed. Unfortunately postgres will only notice closed connections when reading from / writing to the network. That might only happen much later. --- src/backend/distributed/connection/connection_management.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/distributed/connection/connection_management.c b/src/backend/distributed/connection/connection_management.c index a056b852e..11a0f1640 100644 --- a/src/backend/distributed/connection/connection_management.c +++ b/src/backend/distributed/connection/connection_management.c @@ -718,8 +718,7 @@ AfterXactHostConnectionHandling(ConnectionHashEntry *entry, bool isCommit) PQstatus(connection->pgConn) != CONNECTION_OK || PQtransactionStatus(connection->pgConn) != PQTRANS_IDLE) { - PQfinish(connection->pgConn); - connection->pgConn = NULL; + ShutdownConnection(connection); /* unlink from list */ dlist_delete(iter.cur);