Skip to content

MysqlBinlogModel 存在重复读取 binlog event 的问题 #19

Description

@excelwang

在阅读 api/etl/data_models/mysql_binlog.py 源码时,发现 MysqlBinlogModel 在 binlog 读取时可能存在重复读取 event 的风险。
主要问题表现为:

没有持久化 binlog 的文件名和位置(log_file, log_pos),也未在初始化时恢复到上次断点。
BinLogStreamReader 的 server_id 每次都随机生成,导致 MySQL 服务器认为是新的 slave,无法断点续读。
这样在应用重启或多次调用读取函数时,可能会重复读取 binlog event,造成数据重复消费。
建议

建议增加 binlog 位置的持久化和恢复功能,初始化 BinLogStreamReader 时指定 log_file 和 log_pos。
server_id 建议可配置并保持稳定。
引用相关代码位置:
api/etl/data_models/mysql_binlog.py#L5

感谢作者的开源与付出!

@xuwei95

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions