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/tracker: visit Progress in stable order #11004

Merged
merged 2 commits into from
Aug 9, 2019

Conversation

tbg
Copy link
Contributor

@tbg tbg commented Aug 7, 2019

This is helpful for upcoming testing work which allows datadriven testing
of the interaction of multiple nodes. This testing requires determinism to
work correctly.

@tbg tbg requested a review from bdarnell August 7, 2019 16:55
tbg added a commit to tbg/etcd that referenced this pull request Aug 7, 2019
@codecov-io
Copy link

codecov-io commented Aug 7, 2019

Codecov Report

Merging #11004 into master will decrease coverage by 0.09%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #11004     +/-   ##
=========================================
- Coverage    63.9%    63.8%   -0.1%     
=========================================
  Files         401      401             
  Lines       37558    37572     +14     
=========================================
- Hits        24001    23973     -28     
- Misses      11926    11970     +44     
+ Partials     1631     1629      -2
Impacted Files Coverage Δ
raft/util.go 71.87% <ø> (+3.21%) ⬆️
raft/tracker/tracker.go 97.14% <100%> (+0.51%) ⬆️
raft/quorum/majority.go 100% <100%> (ø) ⬆️
client/members.go 65.32% <0%> (-20.17%) ⬇️
pkg/transport/timeout_conn.go 60% <0%> (-20%) ⬇️
auth/simple_token.go 67.47% <0%> (-19.52%) ⬇️
clientv3/txn.go 82.22% <0%> (-17.78%) ⬇️
clientv3/naming/grpc.go 63.15% <0%> (-12.29%) ⬇️
client/client.go 53.26% <0%> (-11.77%) ⬇️
clientv3/leasing/util.go 91.66% <0%> (-6.67%) ⬇️
... and 26 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 03bd100...1b3e082. Read the comment docs.

@@ -166,10 +166,34 @@ func (p *ProgressTracker) Committed() uint64 {
return uint64(p.Voters.CommittedIndex(matchAckIndexer(p.Progress)))
}

// Visit invokes the supplied closure for all tracked progresses.
func insertionSort(sl []uint64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to a common util pkg? no need for two insertionSort.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

@tbg tbg Aug 8, 2019

Choose a reason for hiding this comment

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

I intentionally didn't do that (https://www.youtube.com/watch?v=PAAkCSZUG1c&t=9m28s). Just to double check, are you suggesting I make an insertionsortutil package that only includes this method? Because it won't be able to include much more than that because quorum's dependency tree is quite small and that's a good thing (plus, lots of our existing util-like code actually depends on raft).

@xiang90
Copy link
Contributor

xiang90 commented Aug 7, 2019

lgtm

// We need to sort the IDs and don't want to allocate since this is hot code.
// The optimization here mirrors that in `(MajorityConfig).CommittedIndex`,
// see there for details.
var sl [7]uint64
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say to avoid the double slice, but you're moving this code from somewhere else, so feel free to keep as is.

var ids []uint64
var sl [7]uint64
if n <= len(sl) {
    ids = sl[:n]
} else {
    ids = make([]uint64, n)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed both up (the one here was even wrong!)

@@ -166,10 +166,34 @@ func (p *ProgressTracker) Committed() uint64 {
return uint64(p.Voters.CommittedIndex(matchAckIndexer(p.Progress)))
}

// Visit invokes the supplied closure for all tracked progresses.
func insertionSort(sl []uint64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

This is helpful for upcoming testing work which allows datadriven
testing of the interaction of multiple nodes. This testing requires
determinism to work correctly.
@tbg
Copy link
Contributor Author

tbg commented Aug 9, 2019

Thanks for the reviews!

@tbg tbg merged commit 7948f39 into etcd-io:master Aug 9, 2019
@tbg tbg deleted the interaction/unused-type branch August 9, 2019 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants