Skip to content

Commit 7a5da6e

Browse files
committed
go/mysql: conn.go: Fix read-after-recycle bug in COM_REGISTER_REPLICA and COM_BINLOG_DUMP_GTID.
1 parent 3239bb6 commit 7a5da6e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

go/mysql/conn.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,13 +1424,14 @@ func (c *Conn) handleComRegisterReplica(handler Handler, data []byte) (kontinue
14241424
return true
14251425
}
14261426

1427-
c.recycleReadPacket()
1428-
14291427
replicaHost, replicaPort, replicaUser, replicaPassword, err := c.parseComRegisterReplica(data)
14301428
if err != nil {
14311429
log.Errorf("conn %v: parseComRegisterReplica failed: %v", c.ID(), err)
14321430
return false
14331431
}
1432+
1433+
c.recycleReadPacket()
1434+
14341435
if err := binlogReplicaHandler.ComRegisterReplica(c, replicaHost, replicaPort, replicaUser, replicaPassword); err != nil {
14351436
c.writeErrorPacketFromError(err)
14361437
return false
@@ -1449,7 +1450,6 @@ func (c *Conn) handleComBinlogDumpGTID(handler Handler, data []byte) (kontinue b
14491450
return true
14501451
}
14511452

1452-
c.recycleReadPacket()
14531453
kontinue = true
14541454

14551455
c.startWriterBuffering()
@@ -1465,6 +1465,7 @@ func (c *Conn) handleComBinlogDumpGTID(handler Handler, data []byte) (kontinue b
14651465
log.Errorf("conn %v: parseComBinlogDumpGTID failed: %v", c.ID(), err)
14661466
return false
14671467
}
1468+
c.recycleReadPacket()
14681469
if err := binlogReplicaHandler.ComBinlogDumpGTID(c, logFile, logPos, position.GTIDSet); err != nil {
14691470
log.Error(err.Error())
14701471
c.writeErrorPacketFromError(err)

0 commit comments

Comments
 (0)