Skip to content

Commit 8d4de0f

Browse files
dveedenlance6716
andauthored
Use new terms for replication on MySQL 8.4.0 (#867)
Co-authored-by: lance6716 <[email protected]>
1 parent 2525200 commit 8d4de0f

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

canal/sync.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,12 @@ func (c *Canal) WaitUntilPos(pos mysql.Position, timeout time.Duration) error {
309309
}
310310

311311
func (c *Canal) GetMasterPos() (mysql.Position, error) {
312-
rr, err := c.Execute("SHOW MASTER STATUS")
312+
showBinlogStatus := "SHOW BINARY LOG STATUS"
313+
if eq, err := c.conn.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) {
314+
showBinlogStatus = "SHOW MASTER STATUS"
315+
}
316+
317+
rr, err := c.Execute(showBinlogStatus)
313318
if err != nil {
314319
return mysql.Position{}, errors.Trace(err)
315320
}

replication/backup_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import (
1313
func (t *testSyncerSuite) TestStartBackupEndInGivenTime() {
1414
t.setupTest(mysql.MySQLFlavor)
1515

16-
t.testExecute("RESET MASTER")
16+
resetBinaryLogs := "RESET BINARY LOGS AND GTIDS"
17+
if eq, err := t.c.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) {
18+
resetBinaryLogs = "RESET MASTER"
19+
}
20+
21+
t.testExecute(resetBinaryLogs)
1722

1823
for times := 1; times <= 2; times++ {
1924
t.testSync(nil)

replication/replication_test.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,21 @@ func (t *testSyncerSuite) setupTest(flavor string) {
304304

305305
func (t *testSyncerSuite) testPositionSync() {
306306
// get current master binlog file and position
307-
r, err := t.c.Execute("SHOW MASTER STATUS")
307+
showBinlogStatus := "SHOW BINARY LOG STATUS"
308+
showReplicas := "SHOW REPLICAS"
309+
if eq, err := t.c.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) {
310+
showBinlogStatus = "SHOW MASTER STATUS"
311+
showReplicas = "SHOW SLAVE HOSTS"
312+
}
313+
r, err := t.c.Execute(showBinlogStatus)
308314
require.NoError(t.T(), err)
309315
binFile, _ := r.GetString(0, 0)
310316
binPos, _ := r.GetInt(0, 1)
311317

312318
s, err := t.b.StartSync(mysql.Position{Name: binFile, Pos: uint32(binPos)})
313319
require.NoError(t.T(), err)
314320

315-
r, err = t.c.Execute("SHOW SLAVE HOSTS")
321+
r, err = t.c.Execute(showReplicas)
316322
require.NoError(t.T(), err)
317323

318324
// List of replicas must not be empty
@@ -406,7 +412,12 @@ func (t *testSyncerSuite) TestMysqlSemiPositionSync() {
406412
func (t *testSyncerSuite) TestMysqlBinlogCodec() {
407413
t.setupTest(mysql.MySQLFlavor)
408414

409-
t.testExecute("RESET MASTER")
415+
resetBinaryLogs := "RESET BINARY LOGS AND GTIDS"
416+
if eq, err := t.c.CompareServerVersion("8.4.0"); (err == nil) && (eq < 0) {
417+
resetBinaryLogs = "RESET MASTER"
418+
}
419+
420+
t.testExecute(resetBinaryLogs)
410421

411422
var wg sync.WaitGroup
412423
wg.Add(1)

0 commit comments

Comments
 (0)