-
Notifications
You must be signed in to change notification settings - Fork 65
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
Removed StateTracker complexity #123
Removed StateTracker complexity #123
Conversation
68fbf33
to
4f17d4d
Compare
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.
Looks good 👍 but please leave out the binlog reverifier bits for now if it makes sense. I would like to review that more thoroughly once #122 has been reviewed 🙏
state_tracker.go
Outdated
} | ||
} | ||
lastWrittenBinlogPosition mysql.Position | ||
lastStoredBinlogPositionForInlineVerifier mysql.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.
nit: lastVerifiedBinlogPosition
is simpler? Do we need to introduce this in this PR? Seems to me like a followup to #122
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.
It's not quite the last verified binlog position. As soon as the binlog event is added to the reverify store, we record this position. The reverify store will be dumped anyway so we won't lose anything.
Either way, I'll remove it for now and send a follow up PR after #122.
state_tracker.go
Outdated
return s.CopyStage.LastProcessedBinlogPosition | ||
nilPosition := mysql.Position{} | ||
if s.LastWrittenBinlogPosition == nilPosition { | ||
return s.LastStoredBinlogPositionForInlineVerifier |
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 there was no LastWrittenBinlogPosition
(nothing was written by the binlog writer), how could we have a LastStoredBinlogPositionForInlineVerifier
?
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.
Both the LastWrittenBinlogPosition
and the LastStoredBinlogPositionForInlineVerifier
are initialized during Ferry.Start
, right after the binlog streamer is connected. This is done to address a bug where if the application database got not writes to it while Ghostferry is running, Ghostferry could not resume.
// The binlog writer and the verify binlog positions are different because the | ||
// binlog writer is buffered in a background go routine. Its position can race | ||
// with respect to the verifier binlog position. The minimum position between | ||
// the two are always safe to resume from. | ||
func (s *SerializableState) MinBinlogPosition() mysql.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.
Why is this method defined on this struct? Seems like a consumer concern
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 was more thinking of this as an "attribute" of the SerializableState and hence put it here.
This commit can be reverted in a later PR.
The
StateTracker
code was complex as it was split between theCopyStateTracker
and theVerifierStateTracker
. Since we are moving towards theInlineVerifier
, which requires very little state, we don't need this complexity anymore.This PR removes the extra complexity and only retains a single
StateTracker
andSerializableState
.