Skip to content

Commit

Permalink
etcdctl: support mvcc txn
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Romano committed Mar 1, 2017
1 parent a0cdfa5 commit bed1b26
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions etcdctl/ctlv3/command/snapshot_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,21 +375,20 @@ func makeDB(snapdir, dbfile string, commit int) {
be := backend.NewDefaultBackend(dbpath)
// a lessor never timeouts leases
lessor := lease.NewLessor(be, math.MaxInt64)

s := mvcc.NewStore(be, lessor, (*initIndex)(&commit))
id := s.TxnBegin()
txn := s.Write()
btx := be.BatchTx()
del := func(k, v []byte) error {
_, _, err := s.TxnDeleteRange(id, k, nil)
return err
txn.DeleteRange(k, nil)
return nil
}

// delete stored members from old cluster since using new members
btx.UnsafeForEach([]byte("members"), del)
// todo: add back new members when we start to deprecate old snap file.
btx.UnsafeForEach([]byte("members_removed"), del)
// trigger write-out of new consistent index
s.TxnEnd(id)
txn.End()
s.Commit()
s.Close()
}
Expand Down

0 comments on commit bed1b26

Please sign in to comment.