From c861bce438ee5b96cc2dcc78718731dce6949060 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sun, 28 May 2023 19:12:01 +0200 Subject: [PATCH] CancelRequest: don't try to read the reply Postgres will just process the request and close the connection --- pgconn/pgconn.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pgconn/pgconn.go b/pgconn/pgconn.go index 2e07344d..6e8140a6 100644 --- a/pgconn/pgconn.go +++ b/pgconn/pgconn.go @@ -896,17 +896,11 @@ func (pgConn *PgConn) CancelRequest(ctx context.Context) error { binary.BigEndian.PutUint32(buf[4:8], 80877102) binary.BigEndian.PutUint32(buf[8:12], uint32(pgConn.pid)) binary.BigEndian.PutUint32(buf[12:16], uint32(pgConn.secretKey)) + // Postgres will process the request and close the connection + // so when don't need to read the reply + // https://www.postgresql.org/docs/current/protocol-flow.html#id-1.10.6.7.10 _, err = cancelConn.Write(buf) - if err != nil { - return err - } - - _, err = cancelConn.Read(buf) - if err != io.EOF { - return err - } - - return nil + return err } // WaitForNotification waits for a LISTON/NOTIFY message to be received. It returns an error if a notification was not