From 61a8ed44a1f28850f91157752c864d0f42b5be94 Mon Sep 17 00:00:00 2001 From: Rafael Chacon Date: Fri, 10 Jan 2020 16:38:59 -0800 Subject: [PATCH] Updates how master gtid position is obtained for file:pos flavor When generating masterGTIDSet in file:pos most likely you will have a topology like the following: Source A -> Target B (B has a vreplication stream from A) From the target perspective, the source A is the master and you want to generate a gtid that is based on binlog file position of that server. As an example, let's see this topology: Master A -> Source B -> Target C (C has vreplication stream from B) Prior to this change, masterGTIDSet was returning the binlogfile:pos of A. But in reality, the Target C wants the position of B. Signed-off-by: Rafael Chacon --- go/mysql/flavor_filepos.go | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/go/mysql/flavor_filepos.go b/go/mysql/flavor_filepos.go index 7ecb9e3ddc1..9b943ba5eab 100644 --- a/go/mysql/flavor_filepos.go +++ b/go/mysql/flavor_filepos.go @@ -40,44 +40,25 @@ func newFilePosFlavor() flavor { // masterGTIDSet is part of the Flavor interface. func (flv *filePosFlavor) masterGTIDSet(c *Conn) (GTIDSet, error) { - qr, err := c.ExecuteFetch("SHOW SLAVE STATUS", 100, true /* wantfields */) + qr, err := c.ExecuteFetch("SHOW MASTER STATUS", 100, true /* wantfields */) if err != nil { return nil, err } if len(qr.Rows) == 0 { - qr, err = c.ExecuteFetch("SHOW MASTER STATUS", 100, true /* wantfields */) - if err != nil { - return nil, err - } - if len(qr.Rows) == 0 { - return nil, errors.New("no master or slave status") - } - resultMap, err := resultToMap(qr) - if err != nil { - return nil, err - } - pos, err := strconv.Atoi(resultMap["Position"]) - if err != nil { - return nil, fmt.Errorf("invalid FilePos GTID (%v): expecting pos to be an integer", resultMap["Position"]) - } - - return filePosGTID{ - file: resultMap["File"], - pos: pos, - }, nil + return nil, errors.New("no master status") } resultMap, err := resultToMap(qr) if err != nil { return nil, err } - pos, err := strconv.Atoi(resultMap["Exec_Master_Log_Pos"]) + pos, err := strconv.Atoi(resultMap["Position"]) if err != nil { - return nil, fmt.Errorf("invalid FilePos GTID (%v): expecting pos to be an integer", resultMap["Exec_Master_Log_Pos"]) + return nil, fmt.Errorf("invalid FilePos GTID (%v): expecting pos to be an integer", resultMap["Position"]) } return filePosGTID{ - file: resultMap["Relay_Master_Log_File"], + file: resultMap["File"], pos: pos, }, nil }