etcdctl: support mvcc txn

This commit is contained in:
Anthony Romano 2017-02-13 09:38:54 -08:00
parent 0ed3c83e49
commit d1dcc828c8

View File

@ -375,13 +375,12 @@ func makeDB(snapdir, dbfile string, commit int) {
be := backend.NewDefaultBackend(dbpath) be := backend.NewDefaultBackend(dbpath)
// a lessor never timeouts leases // a lessor never timeouts leases
lessor := lease.NewLessor(be, math.MaxInt64) lessor := lease.NewLessor(be, math.MaxInt64)
s := mvcc.NewStore(be, lessor, (*initIndex)(&commit)) s := mvcc.NewStore(be, lessor, (*initIndex)(&commit))
id := s.TxnBegin() txn := s.Write()
btx := be.BatchTx() btx := be.BatchTx()
del := func(k, v []byte) error { del := func(k, v []byte) error {
_, _, err := s.TxnDeleteRange(id, k, nil) txn.DeleteRange(k, nil)
return err return nil
} }
// delete stored members from old cluster since using new members // delete stored members from old cluster since using new members
@ -389,7 +388,7 @@ func makeDB(snapdir, dbfile string, commit int) {
// todo: add back new members when we start to deprecate old snap file. // todo: add back new members when we start to deprecate old snap file.
btx.UnsafeForEach([]byte("members_removed"), del) btx.UnsafeForEach([]byte("members_removed"), del)
// trigger write-out of new consistent index // trigger write-out of new consistent index
s.TxnEnd(id) txn.End()
s.Commit() s.Commit()
s.Close() s.Close()
} }