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: leader respond to learner read index message #10590

Merged
merged 1 commit into from
Mar 28, 2019

Conversation

jingyih
Copy link
Contributor

@jingyih jingyih commented Mar 27, 2019

Leader should check message sender upon receiving MsgReadIndex message, even when raft quorum is 1. The message could be sent from learner node. In this case, leader should respond to the sender.

Fixes #10589.

cc @xiang90 @gyuho @WIZARD-CXY @jpbetz

@jingyih
Copy link
Contributor Author

jingyih commented Mar 27, 2019

In this case, does the leader need to check if it has committed any log entry at the current term?

@codecov-io
Copy link

Codecov Report

Merging #10590 into master will decrease coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10590      +/-   ##
==========================================
- Coverage    71.6%   71.49%   -0.11%     
==========================================
  Files         393      393              
  Lines       36568    36571       +3     
==========================================
- Hits        26183    26146      -37     
- Misses       8549     8588      +39     
- Partials     1836     1837       +1
Impacted Files Coverage Δ
raft/raft.go 92.19% <100%> (+0.68%) ⬆️
pkg/adt/interval_tree.go 79.27% <0%> (-11.12%) ⬇️
clientv3/leasing/util.go 91.66% <0%> (-6.67%) ⬇️
etcdctl/ctlv3/command/lease_command.go 65.34% <0%> (-5.95%) ⬇️
proxy/httpproxy/director.go 80% <0%> (-2.86%) ⬇️
proxy/grpcproxy/register.go 80.55% <0%> (-2.78%) ⬇️
etcdserver/api/v3rpc/watch.go 80.06% <0%> (-2.29%) ⬇️
clientv3/op.go 72.5% <0%> (-1.25%) ⬇️
proxy/grpcproxy/watch.go 88.55% <0%> (-1.21%) ⬇️
raft/node.go 91.98% <0%> (-0.77%) ⬇️
... and 15 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 9c2b88d...60224f3. Read the comment docs.

@jingyih jingyih changed the title raft: leader response to learner read index message raft: leader respond to learner read index message Mar 28, 2019
raft/raft.go Outdated Show resolved Hide resolved
@xiang90
Copy link
Contributor

xiang90 commented Mar 28, 2019

lgtm

Leader should check message sender after receiving MsgReadIndex, even
when raft quorum is 1. The message could be sent from learner node, and
leader should respond.
@xiang90 xiang90 merged commit 952b9e7 into etcd-io:master Mar 28, 2019
} else { // there is only one voting member (the leader) in the cluster
if m.From == None || m.From == r.id { // from leader itself
r.readStates = append(r.readStates, ReadState{Index: r.raftLog.committed, RequestCtx: m.Entries[0].Data})
} else { // from learner member
Copy link
Contributor

Choose a reason for hiding this comment

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

i just hit the merge button... but actually you can check if m.From is indeed a learner for extra safety.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since here we have r.quorum()==1, which means r.prs only has leader itself?

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.

3 participants