Skip to content

Commit

Permalink
Merge pull request #517 from leosocy/master
Browse files Browse the repository at this point in the history
fix: adapt for a mysql's Server Status bug
  • Loading branch information
flike authored Feb 23, 2024
2 parents dd76ee0 + f4a4c2f commit 1fc233b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions backend/backend_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,18 @@ func (c *Conn) ReConnect() error {
return err
}

//we must always use autocommit
if !c.IsAutoCommit() {
if _, err := c.exec("set autocommit = 1"); err != nil {
c.conn.Close()

return err
}
// we must always use autocommit
// since there is a bug in MySQL,
//
// When the global 'autocommit' variable is 0, and client connects to server,
// the 'SERVER_STATUS_AUTOCOMMIT' bit is always set,
// even when it should not at this situation.
// This wrong status can affect how client handles transaction status.
// Please visit https://bugs.mysql.com/bug.php?id=87813 for more detail.
//
// Until the official fixes this bug, we set `autocommit=1` unconditionally.
if err := c.SetAutoCommit(1); err != nil {
return err
}

return nil
Expand Down

0 comments on commit 1fc233b

Please sign in to comment.