-
Notifications
You must be signed in to change notification settings - Fork 990
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
Proper way to save position after Canal OnRow event #816
Comments
I'm not a canel user (we directly use BinlogSyncer) but that's not much difference. Considering DML, I think it's XIDEvent rather than RowsEvent that can be used to (re)start a binlog replication. So |
Initial position GTIDSet can be retrieved from:
Then start with: Line 204 in cfe6012
Maintain the GTIDSet in memory and then keep adding the GTID next from the Event handler to it: To resume from the place you stopped, call StartFromGTID again next time. |
@cameron-p-m thanks, I don't have GTID_MODE=ON so I can't use GTIDSet. I believe it would have the same issue there where every time I save the GTIDSet back to the database it would fire the event. @lance6716 it appears that Thanks! |
这里有个问题 大批量插入 或者更新 他会让你记录 最后面的 GTID点 程序异常之后 你会从最新点开始读取 会丢失数据 |
What is the recommended way to save position to the database after each
OnRow
event?The reason I'd like to save the position is so I can restart the program and have it start where it left off. I'm guessing this is a common use case and others are already doing this.
I've tried
OnPosSynced
but because I'm saving the position to the same database it causes it to fire endlessly.My current implementation is to use
e.Header.LogPos
something like below. It appears to work but I'm worried there are cases I'm not considering.Any issues with the current implementation or better ways to go about this?
The text was updated successfully, but these errors were encountered: