diff --git a/canal/sync.go b/canal/sync.go index 49cb1b59f..14892eae0 100644 --- a/canal/sync.go +++ b/canal/sync.go @@ -309,7 +309,12 @@ func (c *Canal) WaitUntilPos(pos mysql.Position, timeout time.Duration) error { } func (c *Canal) GetMasterPos() (mysql.Position, error) { - rr, err := c.Execute("SHOW MASTER STATUS") + showBinlogStatus := "SHOW BINARY LOG STATUS" + if eq, err := c.conn.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) { + showBinlogStatus = "SHOW MASTER STATUS" + } + + rr, err := c.Execute(showBinlogStatus) if err != nil { return mysql.Position{}, errors.Trace(err) } diff --git a/replication/backup_test.go b/replication/backup_test.go index b4e1e98b6..1f77e8e3e 100644 --- a/replication/backup_test.go +++ b/replication/backup_test.go @@ -13,7 +13,12 @@ import ( func (t *testSyncerSuite) TestStartBackupEndInGivenTime() { t.setupTest(mysql.MySQLFlavor) - t.testExecute("RESET MASTER") + resetBinaryLogs := "RESET BINARY LOGS AND GTIDS" + if eq, err := t.c.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) { + resetBinaryLogs = "RESET MASTER" + } + + t.testExecute(resetBinaryLogs) for times := 1; times <= 2; times++ { t.testSync(nil) diff --git a/replication/replication_test.go b/replication/replication_test.go index 8b70f9e44..3a64df744 100644 --- a/replication/replication_test.go +++ b/replication/replication_test.go @@ -304,7 +304,13 @@ func (t *testSyncerSuite) setupTest(flavor string) { func (t *testSyncerSuite) testPositionSync() { // get current master binlog file and position - r, err := t.c.Execute("SHOW MASTER STATUS") + showBinlogStatus := "SHOW BINARY LOG STATUS" + showReplicas := "SHOW REPLICAS" + if eq, err := t.c.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) { + showBinlogStatus = "SHOW MASTER STATUS" + showReplicas = "SHOW SLAVE HOSTS" + } + r, err := t.c.Execute(showBinlogStatus) require.NoError(t.T(), err) binFile, _ := r.GetString(0, 0) binPos, _ := r.GetInt(0, 1) @@ -312,7 +318,7 @@ func (t *testSyncerSuite) testPositionSync() { s, err := t.b.StartSync(mysql.Position{Name: binFile, Pos: uint32(binPos)}) require.NoError(t.T(), err) - r, err = t.c.Execute("SHOW SLAVE HOSTS") + r, err = t.c.Execute(showReplicas) require.NoError(t.T(), err) // List of replicas must not be empty @@ -406,7 +412,12 @@ func (t *testSyncerSuite) TestMysqlSemiPositionSync() { func (t *testSyncerSuite) TestMysqlBinlogCodec() { t.setupTest(mysql.MySQLFlavor) - t.testExecute("RESET MASTER") + resetBinaryLogs := "RESET BINARY LOGS AND GTIDS" + if eq, err := t.c.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) { + resetBinaryLogs = "RESET MASTER" + } + + t.testExecute(resetBinaryLogs) var wg sync.WaitGroup wg.Add(1)