From 31679208840e1a2a05db26638c7bcda4ff362bf1 Mon Sep 17 00:00:00 2001 From: Reed Allman Date: Wed, 24 Jan 2018 21:47:45 -0800 Subject: [PATCH] driver.ErrBadConn when init packet read fails (#736) Thank you! --- AUTHORS | 1 + packets.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/AUTHORS b/AUTHORS index 5d84a6eb1..d9144aece 100644 --- a/AUTHORS +++ b/AUTHORS @@ -61,6 +61,7 @@ oscarzhao Paul Bonser Peter Schultz Rebecca Chin +Reed Allman Runrioter Wung Robert Russell Shuode Li diff --git a/packets.go b/packets.go index e6d8e4e88..2e9cb4984 100644 --- a/packets.go +++ b/packets.go @@ -157,6 +157,11 @@ func (mc *mysqlConn) writePacket(data []byte) error { func (mc *mysqlConn) readInitPacket() ([]byte, error) { data, err := mc.readPacket() if err != nil { + // for init we can rewrite this to ErrBadConn for sql.Driver to retry, since + // in connection initialization we don't risk retrying non-idempotent actions. + if err == ErrInvalidConn { + return nil, driver.ErrBadConn + } return nil, err }