From 8083e6df574f81fa48d686143a793890491fd9a6 Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Sat, 25 Nov 2023 15:06:35 +0000 Subject: [PATCH] stop writing v2store We already generate v2 snapshot using v3store to be compatible with 3.5. It makes no sense to write any data into v2store, which isn't used at all. Signed-off-by: Benjamin Wang --- server/etcdserver/api/membership/cluster.go | 43 --------------------- server/etcdserver/api/membership/storev2.go | 21 ---------- 2 files changed, 64 deletions(-) diff --git a/server/etcdserver/api/membership/cluster.go b/server/etcdserver/api/membership/cluster.go index ed035856f9dc..d28efb097811 100644 --- a/server/etcdserver/api/membership/cluster.go +++ b/server/etcdserver/api/membership/cluster.go @@ -263,9 +263,6 @@ func (c *RaftCluster) Recover(onSet func(*zap.Logger, *semver.Version)) { if c.be != nil { c.version = c.be.ClusterVersionFromBackend() c.members, c.removed = c.be.MustReadMembersFromBackend() - } else { - c.version = clusterVersionFromStore(c.lg, c.v2store) - c.members, c.removed = membersFromStore(c.lg, c.v2store) } c.buildMembershipMetric() @@ -390,9 +387,6 @@ func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange) error { func (c *RaftCluster) AddMember(m *Member, shouldApplyV3 ShouldApplyV3) { c.Lock() defer c.Unlock() - if c.v2store != nil { - mustSaveMemberToStore(c.lg, c.v2store, m) - } if c.be != nil && shouldApplyV3 { c.be.MustSaveMemberToBackend(m) @@ -423,9 +417,6 @@ func (c *RaftCluster) AddMember(m *Member, shouldApplyV3 ShouldApplyV3) { func (c *RaftCluster) RemoveMember(id types.ID, shouldApplyV3 ShouldApplyV3) { c.Lock() defer c.Unlock() - if c.v2store != nil { - mustDeleteMemberFromStore(c.lg, c.v2store, id) - } if c.be != nil && shouldApplyV3 { c.be.MustDeleteMemberFromBackend(id) @@ -467,9 +458,6 @@ func (c *RaftCluster) UpdateAttributes(id types.ID, attr Attributes, shouldApply if m, ok := c.members[id]; ok { m.Attributes = attr - if c.v2store != nil { - mustUpdateMemberAttrInStore(c.lg, c.v2store, m) - } if c.be != nil && shouldApplyV3 { c.be.MustSaveMemberToBackend(m) } @@ -499,12 +487,6 @@ func (c *RaftCluster) PromoteMember(id types.ID, shouldApplyV3 ShouldApplyV3) { c.Lock() defer c.Unlock() - if c.v2store != nil { - m := *(c.members[id]) - m.RaftAttributes.IsLearner = false - mustUpdateMemberInStore(c.lg, c.v2store, &m) - } - if c.be != nil && shouldApplyV3 { c.members[id].RaftAttributes.IsLearner = false c.updateMembershipMetric(id, true) @@ -528,11 +510,6 @@ func (c *RaftCluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes, c.Lock() defer c.Unlock() - if c.v2store != nil { - m := *(c.members[id]) - m.RaftAttributes = raftAttr - mustUpdateMemberInStore(c.lg, c.v2store, &m) - } if c.be != nil && shouldApplyV3 { c.members[id].RaftAttributes = raftAttr c.be.MustSaveMemberToBackend(c.members[id]) @@ -589,9 +566,6 @@ func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*zap.Logger, *s c.version = ver sv := semver.Must(semver.NewVersion(version.Version)) serverversion.MustDetectDowngrade(c.lg, sv, c.version) - if c.v2store != nil { - mustSaveClusterVersionToStore(c.lg, c.v2store, ver) - } if c.be != nil && shouldApplyV3 { c.be.MustSaveClusterVersionToBackend(ver) } @@ -823,23 +797,6 @@ func (c *RaftCluster) VotingMemberIDs() []types.ID { return ids } -// PushMembershipToStorage is overriding storage information about cluster's -// members, such that they fully reflect internal RaftCluster's storage. -func (c *RaftCluster) PushMembershipToStorage() { - if c.be != nil { - c.be.TrimMembershipFromBackend() - for _, m := range c.members { - c.be.MustSaveMemberToBackend(m) - } - } - if c.v2store != nil { - TrimMembershipFromV2Store(c.lg, c.v2store) - for _, m := range c.members { - mustSaveMemberToStore(c.lg, c.v2store, m) - } - } -} - // buildMembershipMetric sets the knownPeers metric based on the current // members of the cluster. func (c *RaftCluster) buildMembershipMetric() { diff --git a/server/etcdserver/api/membership/storev2.go b/server/etcdserver/api/membership/storev2.go index 956b2ee21e4e..4a1e702aa582 100644 --- a/server/etcdserver/api/membership/storev2.go +++ b/server/etcdserver/api/membership/storev2.go @@ -56,27 +56,6 @@ func IsMetaStoreOnly(store v2store.Store) (bool, error) { return true, nil } -// TrimMembershipFromV2Store removes all information about members & -// removed_members from the v2 store. -func TrimMembershipFromV2Store(lg *zap.Logger, s v2store.Store) error { - members, removed := membersFromStore(lg, s) - - for mID := range members { - _, err := s.Delete(MemberStoreKey(mID), true, true) - if err != nil { - return err - } - } - for mID := range removed { - _, err := s.Delete(RemovedMemberStoreKey(mID), true, true) - if err != nil { - return err - } - } - - return nil -} - func verifyNoMembersInStore(lg *zap.Logger, s v2store.Store) { members, removed := membersFromStore(lg, s) if len(members) != 0 || len(removed) != 0 {