Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replication: Handle empty previous gtid
From `mysqlbinlog --read-from-remote-server --hexdump ...`: ``` # at 127 #241120 10:36:02 server id 1 end_log_pos 158 CRC32 0xa7f45443 # Position Timestamp Type Source ID Size Source Pos Flags # 0000007f 82 ad 3d 67 23 01 00 00 00 1f 00 00 00 9e 00 00 00 80 00 # 00000092 01 00 00 00 00 00 00 01 43 54 f4 a7 |........CT..| # Previous-GTIDs # [empty] ``` So the `uuidCount` is 1 (from `01 00 00 00 00 00 00 01`) Note that `43 54 f4 a7` is the `CRC32 0xa7f45443` checksum. Without this, this happens: ``` [2024/11/20 10:37:40] [error] binlogstreamer.go:78 close sync with err: Err: runtime error: slice bounds out of range [:24] with capacity 12 Stack: goroutine 8 [running]: github.com/go-mysql-org/go-mysql/mysql.Pstack(...) /home/dvaneeden/go/pkg/mod/github.com/go-mysql-org/[email protected]/mysql/util.go:25 github.com/go-mysql-org/go-mysql/replication.(*BinlogSyncer).onStream.func1() /home/dvaneeden/go/pkg/mod/github.com/go-mysql-org/[email protected]/replication/binlogsyncer.go:730 +0x7e panic({0x834dc0?, 0xc0000285e8?}) /usr/lib/golang/src/runtime/panic.go:785 +0x132 github.com/go-mysql-org/go-mysql/replication.(*PreviousGTIDsEvent).Decode(0xc0000228a0, {0xc00002e8f4, 0x0?, 0xc}) /home/dvaneeden/go/pkg/mod/github.com/go-mysql-org/[email protected]/replication/event.go:239 +0x4ea github.com/go-mysql-org/go-mysql/replication.(*BinlogParser).parseEvent(0xc0000d2190, 0xc0000285d0, {0xc00002e8f4, 0xc, 0xc}, {0xc00002e8e1?, 0xc00008de58?, 0x407f47?}) /home/dvaneeden/go/pkg/mod/github.com/go-mysql-org/[email protected]/replication/parser.go:328 +0x59f github.com/go-mysql-org/go-mysql/replication.(*BinlogParser).Parse(0xc0000d2190, {0xc00002e8e1, 0x1f, 0x1f}) ``` This is because it expects 8 bytes for the `uuidCount` an 16 bytes for the UUID, making 24 in total. But there is only 8 for the `uuidCount and 4 for the checksum, resulting in a capacity of 12.
- Loading branch information