This repository was archived by the owner on Jan 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ Runrioter Wung <runrioter at gmail.com>
6060Soroush Pour <me at soroushjp.com>
6161Stan Putrya <root.vagner at gmail.com>
6262Stanley Gunawan <gunawan.stanley at gmail.com>
63+ Thomas Parrott <tomp at tomp.uk>
6364Xiangyu Hu <xiangyu.hu at outlook.com>
6465Xiaobing Jiang <s7v7nislands at gmail.com>
6566Xiuming Chen <cc at cxm.cc>
Original file line number Diff line number Diff line change @@ -46,8 +46,15 @@ func (mc *mysqlConn) readPacket() ([]byte, error) {
4646 if data [3 ] > mc .sequence {
4747 return nil , ErrPktSyncMul
4848 }
49- return nil , ErrPktSync
49+
50+ // The MariaDB server sends an error packet with sequence numer 0 during
51+ // server shutdown. Continue to process it so the specific error can be
52+ // detected.
53+ if data [3 ] != 0 {
54+ return nil , ErrPktSync
55+ }
5056 }
57+
5158 mc .sequence ++
5259
5360 // packets with length 0 terminate a previous packet which is a
@@ -585,6 +592,13 @@ func (mc *mysqlConn) handleErrorPacket(data []byte) error {
585592 pos = 9
586593 }
587594
595+ // If error code is for ER_CONNECTION_KILLED, then mark connection as bad.
596+ // https://mariadb.com/kb/en/mariadb/mariadb-error-codes/
597+ if errno == 1927 {
598+ errLog .Print ("Error " , errno , ": " , string (data [pos :]))
599+ return driver .ErrBadConn
600+ }
601+
588602 // Error Message [string]
589603 return & MySQLError {
590604 Number : errno ,
You can’t perform that action at this time.
0 commit comments