diff --git a/server/etcdserver/api/membership/cluster.go b/server/etcdserver/api/membership/cluster.go index ed035856f9dc..87f58434e4f6 100644 --- a/server/etcdserver/api/membership/cluster.go +++ b/server/etcdserver/api/membership/cluster.go @@ -73,8 +73,8 @@ type ConfigChangeContext struct { type ShouldApplyV3 bool const ( - ApplyBoth = ShouldApplyV3(true) - ApplyV2storeOnly = ShouldApplyV3(false) + ApplyV3Store = ShouldApplyV3(true) + DontApply = ShouldApplyV3(false) ) // NewClusterFromURLsMap creates a new raft cluster using provided urls map. Currently, it does not support creating @@ -305,7 +305,7 @@ func (c *RaftCluster) Recover(onSet func(*zap.Logger, *semver.Version)) { // ensures that it is still valid. func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange) error { // TODO: this must be switched to backend as well. - membersMap, removedMap := membersFromStore(c.lg, c.v2store) + membersMap, removedMap := c.be.MustReadMembersFromBackend() id := types.ID(cc.NodeID) if removedMap[id] { return ErrIDRemoved diff --git a/server/etcdserver/apply/uber_applier.go b/server/etcdserver/apply/uber_applier.go index d3184e6963c6..c7db2581d18d 100644 --- a/server/etcdserver/apply/uber_applier.go +++ b/server/etcdserver/apply/uber_applier.go @@ -131,6 +131,10 @@ func (a *uberApplier) dispatch(ctx context.Context, r *pb.InternalRaftRequest, s } }(time.Now()) + if !shouldApplyV3 { + return nil + } + switch { case r.ClusterVersionSet != nil: // Implemented in 3.5.x op = "ClusterVersionSet" @@ -146,10 +150,6 @@ func (a *uberApplier) dispatch(ctx context.Context, r *pb.InternalRaftRequest, s return ar } - if !shouldApplyV3 { - return nil - } - switch { case r.Range != nil: op = "Range" diff --git a/server/etcdserver/bootstrap.go b/server/etcdserver/bootstrap.go index 466aa549ecd1..81571bb4eb31 100644 --- a/server/etcdserver/bootstrap.go +++ b/server/etcdserver/bootstrap.go @@ -442,7 +442,6 @@ func (c *bootstrapedCluster) Finalize(cfg config.ServerConfig, s *bootstrappedSt if !s.wal.haveWAL { c.cl.SetID(c.nodeID, c.cl.ID()) } - c.cl.SetStore(s.st) c.cl.SetBackend(schema.NewMembershipBackend(cfg.Logger, s.backend.be)) if s.wal.haveWAL { c.cl.Recover(api.UpdateCapability) diff --git a/server/etcdserver/server.go b/server/etcdserver/server.go index 7086067c4e01..44d5b749a808 100644 --- a/server/etcdserver/server.go +++ b/server/etcdserver/server.go @@ -1787,12 +1787,12 @@ func (s *EtcdServer) apply( // We need to toApply all WAL entries on top of v2store // and only 'unapplied' (e.Index>backend.ConsistentIndex) on the backend. - shouldApplyV3 := membership.ApplyV2storeOnly + shouldApplyV3 := membership.DontApply // set the consistent index of current executing entry if e.Index > s.consistIndex.ConsistentIndex() { s.consistIndex.SetConsistentApplyingIndex(e.Index, e.Term) - shouldApplyV3 = membership.ApplyBoth + shouldApplyV3 = membership.ApplyV3Store } var cc raftpb.ConfChange @@ -1817,13 +1817,13 @@ func (s *EtcdServer) apply( // applyEntryNormal applies an EntryNormal type raftpb request to the EtcdServer func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) { - shouldApplyV3 := membership.ApplyV2storeOnly + shouldApplyV3 := membership.DontApply var ar *apply.Result index := s.consistIndex.ConsistentIndex() if e.Index > index { // set the consistent index of current executing entry s.consistIndex.SetConsistentApplyingIndex(e.Index, e.Term) - shouldApplyV3 = membership.ApplyBoth + shouldApplyV3 = membership.ApplyV3Store defer func() { // The txPostLockInsideApplyHook will not get called in some cases, // in which we should move the consistent index forward directly. @@ -1946,7 +1946,7 @@ func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.Con // The txPostLock callback will not get called in this case, // so we should set the consistent index directly. - if s.consistIndex != nil && membership.ApplyBoth == shouldApplyV3 { + if s.consistIndex != nil && membership.ApplyV3Store == shouldApplyV3 { applyingIndex, applyingTerm := s.consistIndex.ConsistentApplyingIndex() s.consistIndex.SetConsistentIndex(applyingIndex, applyingTerm) } diff --git a/server/etcdserver/server_test.go b/server/etcdserver/server_test.go index 58dd2f8365d2..20dd3c2b4ce3 100644 --- a/server/etcdserver/server_test.go +++ b/server/etcdserver/server_test.go @@ -194,7 +194,7 @@ func TestV2SetClusterVersion(t *testing.T) { be, _ := betesting.NewDefaultTmpBackend(t) defer betesting.Close(t, be) cl := newTestClusterWithBackend(t, []*membership.Member{}, be) - cl.SetVersion(semver.New("3.4.0"), api.UpdateCapability, membership.ApplyBoth) + cl.SetVersion(semver.New("3.4.0"), api.UpdateCapability, membership.ApplyV3Store) srv := &EtcdServer{ lgMu: new(sync.RWMutex), lg: zaptest.NewLogger(t),