Commit 1c50248
committed
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.1 parent 95109e7 commit 1c50248
1 file changed
+10
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
237 | 244 | | |
238 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
239 | 249 | | |
240 | 250 | | |
241 | 251 | | |
| |||
0 commit comments