From 50ffa41e9ce38bd06803d1cfbd7ce565554e73a4 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Wed, 21 Aug 2019 18:32:56 +0200 Subject: [PATCH] storage: skip ApplyConfChange on rejected entry When in a joint configuration, passing an empty conf change to ApplyConfChange doesn't do the right thing any more: it tells Raft that we're leaving the joint config. It's not a good idea to try to tell Raft anything about a ConfChange that got rejected. Raft internally knows that we handled it because it knows the applied index. This also adds a case match for ConfChangeV2 which is necessary to route atomic replication changes (ConfChangeV2). See https://github.com/etcd-io/etcd/pull/11046 Release note: None --- pkg/storage/replica_application_state_machine.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/storage/replica_application_state_machine.go b/pkg/storage/replica_application_state_machine.go index 0f579702b410..11d95503b665 100644 --- a/pkg/storage/replica_application_state_machine.go +++ b/pkg/storage/replica_application_state_machine.go @@ -998,10 +998,11 @@ func (sm *replicaStateMachine) maybeApplyConfChange(ctx context.Context, cmd *re log.Fatalf(ctx, "unexpected replication change from command %s", &cmd.raftCmd) } return nil - case raftpb.EntryConfChange: + case raftpb.EntryConfChange, raftpb.EntryConfChangeV2: if cmd.replicatedResult().ChangeReplicas == nil { - // The command was rejected. - cmd.confChange.ConfChangeI = raftpb.ConfChange{} + // The command was rejected. There is no need to report a ConfChange + // to raft. + return nil } return sm.r.withRaftGroup(true, func(raftGroup *raft.RawNode) (bool, error) { raftGroup.ApplyConfChange(cmd.confChange.ConfChangeI)