From 340bfece2c33b6375414a694688d05b56f6c31af Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Thu, 29 Oct 2020 21:20:28 -0500 Subject: [PATCH] Do not asyncClose in response to a FATAL PG error This will reduce spurious server log messages on authentication failures. See https://github.com/jackc/pgconn/pull/53. --- pgconn.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pgconn.go b/pgconn.go index ff812069..3652cedb 100644 --- a/pgconn.go +++ b/pgconn.go @@ -485,7 +485,8 @@ func (pgConn *PgConn) receiveMessage() (pgproto3.BackendMessage, error) { pgConn.parameterStatuses[msg.Name] = msg.Value case *pgproto3.ErrorResponse: if msg.Severity == "FATAL" { - pgConn.asyncClose() + pgConn.status = connStatusClosed + pgConn.conn.Close() // Ignore error as the connection is already broken and there is already an error to return. return nil, ErrorResponseToPgError(msg) } case *pgproto3.NoticeResponse: