Skip to content

Commit

Permalink
Don't recover, apply or verify membership in v2 store
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
  • Loading branch information
serathius committed Nov 23, 2023
1 parent 6474163 commit 7d019bd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions server/etcdserver/api/membership/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions server/etcdserver/apply/uber_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions server/etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 7d019bd

Please sign in to comment.