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

Removed StateTracker complexity #123

Merged
merged 2 commits into from
Jul 23, 2019

Conversation

shuhaowu
Copy link
Contributor

The StateTracker code was complex as it was split between the CopyStateTracker and the VerifierStateTracker. Since we are moving towards the InlineVerifier, which requires very little state, we don't need this complexity anymore.

This PR removes the extra complexity and only retains a single StateTracker and SerializableState.

@shuhaowu shuhaowu changed the title Removed StateTracker complexity [WIP] Removed StateTracker complexity Jul 15, 2019
@shuhaowu shuhaowu force-pushed the state-tracker-complexity-removal branch from 68fbf33 to 4f17d4d Compare July 15, 2019 18:27
@shuhaowu shuhaowu changed the title [WIP] Removed StateTracker complexity Removed StateTracker complexity Jul 22, 2019
@shuhaowu shuhaowu requested review from fjordan and hkdsun July 22, 2019 13:31
Copy link
Contributor

@hkdsun hkdsun left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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.
@shuhaowu
Copy link
Contributor Author

Removed the Verifier state tracking from here in 3caa901. I'll re-add it in a PR following #122.

@shuhaowu shuhaowu merged commit d00221e into Shopify:master Jul 23, 2019
@shuhaowu shuhaowu deleted the state-tracker-complexity-removal branch July 23, 2019 13:16
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.

None yet

3 participants