-
Notifications
You must be signed in to change notification settings - Fork 985
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
support download flushed binlog and parse event for cloud comput… #741
base: master
Are you sure you want to change the base?
Conversation
…ing platform (etc. aliyun)
canal/local.go
Outdated
|
||
if mysqlErr, ok := err.(*mysql.MyError); ok { | ||
// change to local binlog file streamer to adapter the steamer | ||
if mysqlErr.Code == mysql.ER_MASTER_FATAL_ERROR_READING_BINLOG && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the binlog file is purged just at the time we are switching to it, should we also generate a "fake rotate evnet" as the real binlog streamer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if syncer switch to a purged binlog file, 'not find first log file' happen and syncer closed. it try to download binlog to local. the local file contains rotate event, and will put the rotate event to streamer. then canal's masterInfo will change to the new position and it restart syncer to try if new position file is on master, if not the new started syncer will also closed by 'not find first log file' and download next binlog to local. so generate a "fake rotate evnet" maybe not necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the "fake rorate event" which comes before the beginning of any events in binlog, not the real rotate event at the end of each binlog file. You can find it when reading binlog
=== RotateEvent ===
Date: 2022-12-08 11:13:59
Log position: 1969
Event size: 47
Position: 4
Next log name: mysql-bin.000002
=== RotateEvent ===
Date: 1970-01-01 08:00:00
Log position: 0
Event size: 47
Position: 4
Next log name: mysql-bin.000002
for above two events, the first one is the real rotate event which can be found at the end of mysql-bin.000001, and the second one is a fake rotate event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fake rorate event" not exist in binlog file, so no need to process?
I find this in mariadb docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fake rorate event" does not exist in binlog file but it is sent to downstream and can be find when reading binlog 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when using local binlog, the real syncer is closed, canal will not read event from server's binlog, all event read from AdapterStreamer is parsed from binlog file, that will not exist "fake rorate event". "fake rorate event" will send to streamer after finish parse binlog file and restart the read syncer, and runSyncBinlog will process that event
if be.Header.LogPos == position.Pos || position.Pos == 4 { // go ahead to check if begin | ||
beginFromHere = true | ||
} | ||
if beginFromHere { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add an error that no matching position for position.Pos
? For example user downlaods wrong binlog file
} | ||
if beginFromHere { | ||
if err := s.canal.syncer.StorePosAndGTID(be); err != nil { | ||
streamer.CloseWithError(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can return err
to let caller streamer.CloseWithError(err)
in line 112
s.canal.cfg.Logger.Info("Could not find first log, try to download the local binlog for retry") | ||
|
||
// local binlog need next position to find binlog file and begin event | ||
pos := s.canal.master.Position() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we don't check it's a GTID-based replication? For GTID-based replication, filename and position is not dependable to reset replication because upstream master may failover to a new MySQL node and they have same binlog filename but different position.
canal/local.go
Outdated
|
||
if mysqlErr, ok := err.(*mysql.MyError); ok { | ||
// change to local binlog file streamer to adapter the steamer | ||
if mysqlErr.Code == mysql.ER_MASTER_FATAL_ERROR_READING_BINLOG && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fake rorate event" does not exist in binlog file but it is sent to downstream and can be find when reading binlog 😅
any progress for this support? |
you may try gitee.com/Blazz/go-mysql-plus.git. PS: cloud computing platform will auto switch master to salver and raise |
in cloud computing paltform, binlog may flush to cloud storage, that will cause 'not find first log', this change support to consume the position from a flushed binlog
for aliyun example
use RDSBinlogDownloader