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 progress tracking into own component #10683

Merged
merged 9 commits into from
May 22, 2019
Merged

Conversation

tbg
Copy link
Contributor

@tbg tbg commented Apr 26, 2019

The Progress maps contain both the active configuration and information
about the replication status. By pulling it into its own component, this
becomes easier to unit test and also clarifies the code, which will see
changes as #7625 is addressed.

I broke this up into multiple commits to avoid staring at too much code
movement at once, but the bulk of the changes are still mechanical.

@tbg tbg requested review from gyuho and bdarnell April 26, 2019 11:27
@codecov-io
Copy link

Codecov Report

Merging #10683 into master will decrease coverage by 0.17%.
The diff coverage is 84.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10683      +/-   ##
==========================================
- Coverage   71.63%   71.46%   -0.18%     
==========================================
  Files         394      394              
  Lines       36658    36697      +39     
==========================================
- Hits        26261    26224      -37     
- Misses       8564     8627      +63     
- Partials     1833     1846      +13
Impacted Files Coverage Δ
raft/status.go 28.2% <0%> (-1.53%) ⬇️
raft/node.go 92.74% <100%> (ø) ⬆️
raft/rawnode.go 63.35% <20%> (+0.47%) ⬆️
raft/read_only.go 88.09% <88.88%> (ø) ⬆️
raft/progress.go 92.74% <91.01%> (-3.41%) ⬇️
raft/raft.go 92.2% <98.14%> (ø) ⬆️
pkg/fileutil/purge.go 65.9% <0%> (-6.82%) ⬇️
clientv3/leasing/util.go 91.66% <0%> (-6.67%) ⬇️
clientv3/retry_interceptor.go 63.72% <0%> (-4.42%) ⬇️
proxy/grpcproxy/watch.go 88.55% <0%> (-4.22%) ⬇️
... and 28 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 cca0d5c...9011fbb. Read the comment docs.

@gyuho gyuho requested a review from xiang90 April 29, 2019 23:52
@@ -1392,6 +1408,9 @@ func (r *raft) removeNode(id uint64) {
return
}

// TODO(tbg): won't bad (or at least unfortunate) things happen if the
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's not ideal. But even if the leader steps down, the nodes that remain need to elect a new leader (which could have interactions with read leases, etc). So best practice would continue to be to transfer leadership away before removing the leader. But as a fallback, having the leader step down would probably be a good idea (unless we're missing something and this is already happening).

raft/progress.go Outdated
// prs tracks the currently active configuration and the information known about
// the nodes and learners in it. In particular, it tracks the match index for
// each peer which in turn allows reasoning about the committed index.
type prs struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we give the type a better name? Maybe progressTracker?

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.

raft/progress.go Outdated
pN := p.nodes[id]
pL := p.learners[id]

switch {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use if instead of this switch idiom.

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.

@tbg
Copy link
Contributor Author

tbg commented May 1, 2019

@gyuho CI seems to be really flaky. Do you know why that is/is it being worked on?

@jingyih
Copy link
Contributor

jingyih commented May 1, 2019

Regarding the failed tests:

https://travis-ci.com/etcd-io/etcd/jobs/196938400#L820
We are fixing it now.

https://travis-ci.com/etcd-io/etcd/jobs/196938397#L1132
This is a flake.

https://travis-ci.com/etcd-io/etcd/jobs/196938398#L1885
Not quite sure about this panic. Might be a flake. But it is not related to this PR.

tbg added 9 commits May 21, 2019 16:02
The Progress maps contain both the active configuration and information
about the replication status. By pulling it into its own component, this
becomes easier to unit test and also clarifies the code, which will see
changes as etcd-io#7625 is addressed.

More functionality will move into `prs` in self-contained follow-up commits.
Continues what was initiated in the last commit.
This doesn't completely eliminate access to prs.nodes, but that's not
really necessary. This commit uses the existing APIs in a few more
places where it's convenient, and also sprinkles some assertions.
This is purely mechanical. Cleanup deferred to the next commit.
This cleans up the mechanical refactor in the last commit and will
help with etcd-io#7625 as well.
It's looking at each voter's Progress and needs to know how quorums
work, so this is the ideal new home for it.
This particular caller just wanted to know whether it was in a single-voter
cluster configuration, which is now a question prs can answer.
This now delegates the quorum computation to r.prs, which will allow
it to generalize in a straightforward way when etcd-io#7625 is
addressed.
@tbg
Copy link
Contributor Author

tbg commented May 22, 2019

Haven't changed the code since the last round of reviews, and just gave myself another self-review.

@tbg tbg merged commit c38e965 into etcd-io:master May 22, 2019
@tbg tbg deleted the prs branch May 22, 2019 14:53
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.

5 participants