Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendBinlogDumpCommand: apply BinlogThroughGTID flag #17580

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion go/mysql/flavor_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,14 @@ func (mysqlFlavor) sendBinlogDumpCommand(c *Conn, serverID uint32, binlogFilenam

// Build the command.
sidBlock := gtidSet.SIDBlock()
return c.WriteComBinlogDumpGTID(serverID, binlogFilename, 4, 0, sidBlock)
var flags2 uint16
if binlogFilename != "" {
flags2 |= BinlogThroughPosition
}
if len(sidBlock) > 0 {
flags2 |= BinlogThroughGTID
}
return c.WriteComBinlogDumpGTID(serverID, binlogFilename, 4, flags2, sidBlock)
}

// setReplicationPositionCommands is part of the Flavor interface.
Expand Down
15 changes: 15 additions & 0 deletions go/mysql/replication/mysql56_gtid_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,3 +854,18 @@ func TestMysql56GTIDSet_RemoveUUID(t *testing.T) {
})
}
}

func TestSIDs(t *testing.T) {
var set Mysql56GTIDSet // nil
sids := set.SIDs()
assert.NotNil(t, sids)
assert.Empty(t, sids)

gtid := "8bc65cca-3fe4-11ed-bbfb-091034d48b3e:1:4-24"
gtidSet, err := ParseMysql56GTIDSet(gtid)
require.NoError(t, err)
sids = gtidSet.SIDs()
assert.NotNil(t, sids)
require.Len(t, sids, 1)
assert.Equal(t, "8bc65cca-3fe4-11ed-bbfb-091034d48b3e", sids[0].String())
}
4 changes: 3 additions & 1 deletion go/mysql/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ func TestComBinlogDumpGTID(t *testing.T) {

t.Run("WriteComBinlogDumpGTID", func(t *testing.T) {
// Write ComBinlogDumpGTID packet, read it, compare.
err := cConn.WriteComBinlogDumpGTID(0x01020304, "moofarm", 0x05060708090a0b0c, 0x0d0e, []byte{0xfa, 0xfb})
var flags uint16 = 0x0d0e
assert.Equal(t, flags, flags|BinlogThroughGTID)
err := cConn.WriteComBinlogDumpGTID(0x01020304, "moofarm", 0x05060708090a0b0c, flags, []byte{0xfa, 0xfb})
assert.NoError(t, err)
data, err := sConn.ReadPacket()
require.NoError(t, err, "sConn.ReadPacket - ComBinlogDumpGTID failed: %v", err)
Expand Down
Loading