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

Fix resuming state without inline verifier #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ferry.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,14 +508,25 @@ func (f *Ferry) Start() error {
// miss some records that are inserted between the time the
// DataIterator determines the range of IDs to copy and the time that
// the starting binlog coordinates are determined.
//
// NOTE: If we don't use the inline verifier, we don't consider its last
// position for the resume position. We could be migrating for a long time,
// and the inline verifier position may grow outdated to the point that it
// is no-longer a valid position (the logs could have been deleted). Since
// the inline verifier position is not updated if it's not enabled and we
// use the oldest position in `MinBinlogPosition()`, resume may fail for
// the minimum position.
// In this case, using the last written position is the better state to use
var sourcePos siddontangmysql.Position
var targetPos siddontangmysql.Position

var err error
if f.StateToResumeFrom != nil {
if f.StateToResumeFrom == nil {
sourcePos, err = f.BinlogStreamer.ConnectBinlogStreamerToMysql()
} else if f.inlineVerifier != nil {
sourcePos, err = f.BinlogStreamer.ConnectBinlogStreamerToMysqlFrom(f.StateToResumeFrom.MinSourceBinlogPosition())
} else {
sourcePos, err = f.BinlogStreamer.ConnectBinlogStreamerToMysql()
sourcePos, err = f.BinlogStreamer.ConnectBinlogStreamerToMysqlFrom(f.StateToResumeFrom.LastWrittenBinlogPosition)
}
if err != nil {
return err
Expand Down