Skip to content

Commit

Permalink
driver.ErrBadConn when init packet read fails (go-sql-driver#736)
Browse files Browse the repository at this point in the history
Thank you!
  • Loading branch information
Reed Allman authored and Brigitte Lamarche committed Mar 23, 2018
1 parent d1a8b86 commit 3167920
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ oscarzhao <oscarzhaosl at gmail.com>
Paul Bonser <misterpib at gmail.com>
Peter Schultz <peter.schultz at classmarkets.com>
Rebecca Chin <rchin at pivotal.io>
Reed Allman <rdallman10 at gmail.com>
Runrioter Wung <runrioter at gmail.com>
Robert Russell <robert at rrbrussell.com>
Shuode Li <elemount at qq.com>
Expand Down
5 changes: 5 additions & 0 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3167920

Please sign in to comment.