Skip to content

Commit

Permalink
Merge pull request #3255 from alainjobart/binlog
Browse files Browse the repository at this point in the history
Fixing binlog server panic.
  • Loading branch information
alainjobart authored Sep 27, 2017
2 parents d88b601 + 9afa58f commit 8fd9c75
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions go/vt/mysqlctl/slave_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,16 @@ func (sc *SlaveConnection) Close() {
log.Infof("closing slave socket to unblock reads")
sc.Conn.Close()

log.Infof("waiting for slave dump thread to end")
sc.cancel()
sc.wg.Wait()
// sc.cancel is set at the beginning of the StartBinlogDump*
// methods. If we error out before then, it's nil.
// Note we also may error out before adding 1 to sc.wg,
// but then the Wait() still works.
if sc.cancel != nil {
log.Infof("waiting for slave dump thread to end")
sc.cancel()
sc.wg.Wait()
sc.cancel = nil
}

log.Infof("closing slave MySQL client, recycling slaveID %v", sc.slaveID)
sc.Conn = nil
Expand Down

0 comments on commit 8fd9c75

Please sign in to comment.