diff --git a/go/mysql/conn.go b/go/mysql/conn.go index 7d0d9e4e146..564990c4588 100644 --- a/go/mysql/conn.go +++ b/go/mysql/conn.go @@ -1394,7 +1394,6 @@ func (c *Conn) handleNextCommand(ctx context.Context, handler Handler) error { case ComBinlogDumpGTID: ok := c.handleComBinlogDumpGTID(handler, data) - c.recycleReadPacket() if !ok { return fmt.Errorf("error handling ComBinlogDumpGTID packet") } @@ -1402,7 +1401,6 @@ func (c *Conn) handleNextCommand(ctx context.Context, handler Handler) error { case ComRegisterReplica: ok := c.handleComRegisterReplica(handler, data) - c.recycleReadPacket() if !ok { return fmt.Errorf("error handling ComRegisterReplica packet") } @@ -1433,6 +1431,8 @@ func (c *Conn) handleComRegisterReplica(handler Handler, data []byte) (kontinue return false } + c.recycleReadPacket() + if err := binlogReplicaHandler.ComRegisterReplica(c, replicaHost, replicaPort, replicaUser, replicaPassword); err != nil { c.writeErrorPacketFromError(err) return false @@ -1467,6 +1467,8 @@ func (c *Conn) handleComBinlogDumpGTID(handler Handler, data []byte) (kontinue b return false } + c.recycleReadPacket() + if err := binlogReplicaHandler.ComBinlogDumpGTID(c, logFile, logPos, position.GTIDSet); err != nil { log.Error(err.Error()) c.writeErrorPacketFromError(err)