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

do not sync persistent store when get a fake position #397

Merged
merged 3 commits into from
Jul 20, 2019

Conversation

lintanghui
Copy link
Contributor

fixed #396

@lintanghui
Copy link
Contributor Author

@siddontang PTAL

@siddontang
Copy link
Collaborator

PTAL @GregoryIan

canal/sync.go Outdated
@@ -65,6 +65,10 @@ func (c *Canal) runSyncBinlog() error {
// TODO: If we meet any DDL query, we must save too.
switch e := ev.Event.(type) {
case *replication.RotateEvent:
// if event pos equal to local pos.maybe be fake rotate event,do nothing.
if string(e.NextLogName) == pos.Name && uint32(e.Position) == pos.Pos {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in MySQL, a fake rotate event is an event with timestamp equals to 0 (see https://github.com/mysql/mysql-server/blob/8cc757da3d87bf4a1f07dcfb2d3c96fed3806870/sql/rpl_binlog_sender.cc#L899), and also with log pos equals to 0 in the implementation (see https://github.com/mysql/mysql-server/blob/8cc757da3d87bf4a1f07dcfb2d3c96fed3806870/sql/rpl_binlog_sender.cc#L906).

I don't know whether some corner cases exist if checking by string(e.NextLogName) == pos.Name && uint32(e.Position) == pos.Pos.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendly ping @lintanghui

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in MySQL, a fake rotate event is an event with timestamp equals to 0 (see https://github.com/mysql/mysql-server/blob/8cc757da3d87bf4a1f07dcfb2d3c96fed3806870/sql/rpl_binlog_sender.cc#L899), and also with log pos equals to 0 in the implementation (see https://github.com/mysql/mysql-server/blob/8cc757da3d87bf4a1f07dcfb2d3c96fed3806870/sql/rpl_binlog_sender.cc#L906).

I don't know whether some corner cases exist if checking by string(e.NextLogName) == pos.Name && uint32(e.Position) == pos.Pos.

yes, timestamp 0 and pos 0 is set in event header, but in event body, pos and file name is also be set, https://github.com/mysql/mysql-server/blob/8cc757da3d87bf4a1f07dcfb2d3c96fed3806870/sql/rpl_binlog_sender.cc#L909 . in sync.go we just get event body and compare it. we can also do such below
ev.Header.Pos==0 {continue }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lintanghui I know, in this special case string(e.NextLogName) == pos.Name && uint32(e.Position) == pos.Pos is right, but I don't know whether some corner cases exist.

BTW, will you update it to ev.Header.Pos==0 {continue }?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine, it seem better to compare header pos.

@lintanghui
Copy link
Contributor Author

PTAL @GregoryIan . it's that ok to be merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

执行大事务时出现binlog解析失败
3 participants