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

raft: extract 'tracker' package #10807

Merged
merged 1 commit into from
Jun 21, 2019
Merged

raft: extract 'tracker' package #10807

merged 1 commit into from
Jun 21, 2019

Conversation

tbg
Copy link
Contributor

@tbg tbg commented Jun 8, 2019

First four comments are #10779.
Please don't review them here.


Create a new tracker package, clean up and add comments. The code movement is
in the first commit and is largely mechanical, with a priority on avoiding
anything that reviewers may want to see but wouldn't spot in the midst of the
code movement.

You'll want to hold off on nits after you've also looked at the second commit
(which addresses lots of potential nits and generally tries to leave things in
a good place).

I can squash this before merging if requested.

@tbg
Copy link
Contributor Author

tbg commented Jun 19, 2019

@bdarnell, friendly ping.

// RecentlyContacted is used in StateProbe.
// When RecentlyContacted is true, raft should pause sending replication
// message to this peer until RecentlyContacted is reset. See IsPaused().
RecentlyContacted bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RecentActive and RecentlyContacted are confusingly similar (and the fact that only one uses ly bugs me). I think the old name Paused was probably better. Or maybe something like ProbeSent to tie it to StateProbe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I like ProbeSent because it indicates what happens and also makes it not surprising that this is reset periodically (to send another probe).

// Otherwise it updates the progress and returns true.
func (pr *Progress) MaybeUpdate(n uint64) bool {
var updated bool
if pr.Match < n {
pr.Match = n
updated = true
pr.Resume()
pr.RecentlyContacted = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think inlining this assignment obscures what's going on - the contact hasn't become any less recent. What's happening is that we've received an ack to our probe. I think it would be better to indirect through a method, called either Resume as before or something like ProbeReceived().

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 inlined this because I found Resume() opaque, but I like ProbeReceived(). Actually ProbeAcked() is even better I think, going with that.

StateProbe StateType = iota
// StateReplicate is the state steady in which a follower receives a steady
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/state steady/steady state/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (refined the sentence a bit while I was there).

@tbg
Copy link
Contributor Author

tbg commented Jun 20, 2019

Thanks for the review! I just rebased and addressed your comments in fixup commits (Planning to squash the whole thing). I'll leave this open until later tomorrow so that you (or anyone else who feels like it) can give it another look.

@codecov-io
Copy link

codecov-io commented Jun 20, 2019

Codecov Report

Merging #10807 into master will increase coverage by 0.14%.
The diff coverage is 92.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10807      +/-   ##
==========================================
+ Coverage   62.97%   63.12%   +0.14%     
==========================================
  Files         395      398       +3     
  Lines       37439    37446       +7     
==========================================
+ Hits        23578    23637      +59     
+ Misses      12274    12231      -43     
+ Partials     1587     1578       -9
Impacted Files Coverage Δ
etcdserver/raft.go 77.23% <ø> (ø) ⬆️
raft/status.go 56.41% <100%> (ø) ⬆️
raft/tracker/state.go 100% <100%> (ø)
raft/node.go 92.74% <100%> (ø) ⬆️
raft/rawnode.go 63.35% <33.33%> (ø) ⬆️
raft/tracker/tracker.go 87.2% <87.2%> (ø)
raft/tracker/inflights.go 95.55% <95.55%> (ø)
raft/tracker/progress.go 96.87% <96.87%> (ø)
raft/raft.go 91.98% <96.96%> (ø) ⬆️
auth/options.go 47.5% <0%> (-45%) ⬇️
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6953ccc...f9c2d00. Read the comment docs.

Mechanically extract `progressTracker`, `Progress`, and `inflights`
to their own package named `tracker`. Add lots of comments in the
progress, and take the opportunity to rename and clarify various
fields.
@tbg tbg changed the title raft: extract progressTracker, Progress, inflights raft: extract 'tracker' package Jun 21, 2019
@tbg
Copy link
Contributor Author

tbg commented Jun 21, 2019

Squashed, updated commit message, green. Merging.

@tbg tbg merged commit 948e276 into etcd-io:master Jun 21, 2019
@tbg tbg deleted the extract-prs branch June 21, 2019 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants