Skip to content

Commit

Permalink
storage: skip ApplyConfChange on rejected entry
Browse files Browse the repository at this point in the history
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 etcd-io/etcd#11046

Release note: None
  • Loading branch information
tbg committed Aug 23, 2019
1 parent c9c39d3 commit 1fbdcc1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/storage/replica_application_state_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1fbdcc1

Please sign in to comment.