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: make leader transferring workable when quorum check is on #5809

Merged
merged 3 commits into from Jul 12, 2016

Conversation

swingbach
Copy link
Contributor

try to make leader transferring works when quorum check is on

i think a few of database guys are gonna need this.

/cc @siddontang

@xiang90 xiang90 added this to the v3.1.0 milestone Jul 1, 2016
@@ -175,8 +175,8 @@ func testNonleaderStartElection(t *testing.T, state StateType) {
msgs := r.readMessages()
sort.Sort(messageSlice(msgs))
wmsgs := []pb.Message{
{From: 1, To: 2, Term: 2, Type: pb.MsgVote},
{From: 1, To: 3, Term: 2, Type: pb.MsgVote},
{From: 1, To: 2, Term: 2, Type: pb.MsgVote, Entries: []pb.Entry{{Data: []byte(LeaderElection)}}},
Copy link
Contributor

Choose a reason for hiding this comment

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

empty should still work, right (from the code change in raft.go, i feel it is already so)? we need to ensure compatibility.

@xiang90
Copy link
Contributor

xiang90 commented Jul 2, 2016

LGTM.

/cc @bdarnell

@@ -575,7 +587,9 @@ func (r *raft) Step(m pb.Message) error {
case m.Term > r.Term:
lead := m.From
if m.Type == pb.MsgVote {
if r.checkQuorum && r.state != StateCandidate && r.electionElapsed < r.electionTimeout {
force := len(m.Entries) == 1 && bytes.Equal(m.Entries[0].Data, []byte(LeaderTransfer))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like using Entries[0].Data to store data in non-MsgApp messages. I'd rather introduce a top-level Data field in raftpb.Message.

@bdarnell
Copy link
Contributor

bdarnell commented Jul 5, 2016

LGTM

@xiang90
Copy link
Contributor

xiang90 commented Jul 5, 2016

@swingbach I agree with what @bdarnell suggested.

@swingbach
Copy link
Contributor Author

@xiang90 @bdarnell

already fixed a few problems you mentioned, thanks

for the last issue, i guess i need to change the .proto file, so would you please provide the version infos of protoc and gogo,

thanks a lot

@xiang90
Copy link
Contributor

xiang90 commented Jul 11, 2016

@swingbach You should run ./script/genproto.sh. It will get the right version of gogo-proto for you.

For protoc, it requires https://github.com/google/protobuf/releases/tag/v3.0.0-beta-3.1

@swingbach
Copy link
Contributor Author

already fixed the last one

@xiang90 PTAL, Thanks

@@ -64,6 +64,7 @@ message Message {
optional Snapshot snapshot = 9 [(gogoproto.nullable) = false];
optional bool reject = 10 [(gogoproto.nullable) = false];
optional uint64 rejectHint = 11 [(gogoproto.nullable) = false];
optional bytes context = 12;
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer defining a campaign enum and use a campaign type here instead of context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@siddontang what you suggested makes sense for this single case, but I hope it can be more generic which can be used for more cases, such as ReadIndexMsg, it still use Entries of Message to store some user context, i wanna store that context into this field too.

thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

got it.

@xiang90
Copy link
Contributor

xiang90 commented Jul 12, 2016

LGTM.

@xiang90 xiang90 merged commit 7432e9f into etcd-io:master Jul 12, 2016
zhangjinpeng87 added a commit to tikv/tikv that referenced this pull request Aug 2, 2016
bdarnell added a commit to bdarnell/cockroach that referenced this pull request Aug 30, 2016
Notable changes include etcd-io/etcd#6286 (which fixes the issue that was
preventing us from upgrading sooner), and etcd-io/etcd#5809 (which fixes
a possible cause of failed leader transfers discussed in cockroachdb#8834)

Fixes cockroachdb#8017
BusyJay pushed a commit to tikv/raft-rs that referenced this pull request Dec 19, 2017
siennathesane pushed a commit to shieldmaidens/pleiades that referenced this pull request Nov 4, 2023
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.

None yet

4 participants