Skip to content

Commit

Permalink
fixup! v2 etcdctl backup: producing consistent state of membership
Browse files Browse the repository at this point in the history
  • Loading branch information
ptabor committed Apr 27, 2021
1 parent befaf41 commit 9ef142c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/etcdserver/api/membership/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,25 @@ func mustReadMembersFromBackend(lg *zap.Logger, be backend.Backend) (map[types.I
// TrimMembershipFromBackend removes all information about members &
// removed_members from the v3 backend.
func TrimMembershipFromBackend(lg *zap.Logger, be backend.Backend) error {
lg.Info("Trimming membership information from the backend...")
tx := be.BatchTx()
tx.Lock()
defer tx.Unlock()
err := tx.UnsafeForEach(membersBucketName, func(k, v []byte) error {
tx.UnsafeDelete(membersBucketName, k)
lg.Debug("Removed member from the backend",
zap.Stringer("member", mustParseMemberIDFromBytes(lg, k)))
return nil
})
if err != nil {
return err
}
err = tx.UnsafeForEach(membersRemovedBucketName, func(k, v []byte) error {
return tx.UnsafeForEach(membersRemovedBucketName, func(k, v []byte) error {
tx.UnsafeDelete(membersRemovedBucketName, k)
lg.Debug("Removed removed_member from the backend",
zap.Stringer("member", mustParseMemberIDFromBytes(lg, k)))
return nil
})
if err != nil {
return err
}
return nil
}

// TrimMembershipFromV2Store removes all information about members &
Expand Down

0 comments on commit 9ef142c

Please sign in to comment.