bingo2sql icon indicating copy to clipboard operation
bingo2sql copied to clipboard

如果--stop-pos和MySQL最新position一样,且MySQL binlog只有DDL、没有其他更新,会导致bingo2sql无法正常结束

Open wxl356 opened this issue 1 year ago • 0 comments

如何复现: 1 flush logs生成新的binlog,该binlog只执行DDL,show master status; 得到binlog file和position flush logs; create table t2(id int); show master status; -- | mysql-bin.004720 | 402 | ---后续不再执行其他SQL、binlog保持不变。

2 bingo2sql解析时,--stop-file --stop-pos使用第一步获取的binlog file和position。由于MySQL binlog 一直没有更新,bingo2sql将无法结束,需要Ctrl+C kill: ./bingo2sql -h=xxx -P 3306 -uxxx -p'xxx' -d monitor --start-file="mysql-bin.004720" --start-pos=4 --stop-file="mysql-bin.004720" --stop-pos=402 -B

[2023/10/17 07:00:08] [info] binlogsyncer.go:392 begin to sync binlog from position (mysql-bin.004720, 4) [2023/10/17 07:00:08] [info] binlogsyncer.go:808 rotate to (mysql-bin.004720, 4) INFO[2023-10-17T07:00:08Z] 超出最新binlog位置 file=parser.go line=571 当前位置=402 当前文件=mysql-bin.004720 结束位置=402 结束文件=mysql-bin.004720

原因: checkFinish(https://github.com/hanchuanchuan/bingo2sql/blob/master/core/parser.go#L523) 和finishFlag(https://github.com/hanchuanchuan/bingo2sql/blob/master/core/parser.go#L2271) 可能需要对只有DDL的场景做处理?

wxl356 avatar Oct 17 '23 06:10 wxl356