diff --git a/kv/kv.go b/kv/kv.go index 68369bf1eb..0b0067a79f 100644 --- a/kv/kv.go +++ b/kv/kv.go @@ -66,9 +66,6 @@ type Transaction interface { UnionStore // Commit commits the transaction operations to KV store. Commit() error - // CommittedVersion returns the version of this committed transaction. If this - // transaction has not been committed, returns ErrNotCommitted error. - CommittedVersion() (Version, error) // Rollback undoes the transaction operations to KV store. Rollback() error // String implements fmt.Stringer interface. diff --git a/store/hbase/txn.go b/store/hbase/txn.go index 4910959789..2e76fbcee9 100644 --- a/store/hbase/txn.go +++ b/store/hbase/txn.go @@ -155,14 +155,6 @@ func (txn *hbaseTxn) Commit() error { return txn.doCommit() } -func (txn *hbaseTxn) CommittedVersion() (kv.Version, error) { - // Check if this transaction is not committed. - if txn.version.Cmp(kv.MinVersion) == 0 { - return kv.MinVersion, kv.ErrNotCommitted - } - return txn.version, nil -} - func (txn *hbaseTxn) close() error { txn.UnionStore.Release() txn.valid = false diff --git a/store/localstore/mvcc_test.go b/store/localstore/mvcc_test.go index 086f90ca9a..5ec39ce378 100644 --- a/store/localstore/mvcc_test.go +++ b/store/localstore/mvcc_test.go @@ -165,14 +165,14 @@ func (t *testMvccSuite) TestSnapshotGet(c *C) { c.Assert(err, IsNil) tx.Commit() + lastVer, err := globalVersionProvider.CurrentVersion() + c.Assert(err, IsNil) // Modify tx, _ = t.s.Begin() err = tx.Set(encodeInt(1), []byte("new")) c.Assert(err, IsNil) err = tx.Commit() c.Assert(err, IsNil) - v, err := tx.CommittedVersion() - c.Assert(err, IsNil) testKey := encodeTestDataKey(1) snapshot, err := t.s.GetSnapshot(kv.MaxVersion) @@ -182,7 +182,7 @@ func (t *testMvccSuite) TestSnapshotGet(c *C) { c.Assert(string(b), Equals, "new") // Get last version - lastVerSnapshot, err := t.s.GetSnapshot(kv.NewVersion(v.Ver - 1)) + lastVerSnapshot, err := t.s.GetSnapshot(lastVer) c.Assert(err, IsNil) b, err = lastVerSnapshot.Get(testKey) c.Assert(err, IsNil) @@ -230,7 +230,7 @@ func (t *testMvccSuite) TestMvccSeek(c *C) { c.Assert(err, IsNil) err = txn.Commit() c.Assert(err, IsNil) - v1, err := txn.CommittedVersion() + v1, err := globalVersionProvider.CurrentVersion() c.Assert(err, IsNil) txn, err = t.s.Begin() @@ -239,7 +239,7 @@ func (t *testMvccSuite) TestMvccSeek(c *C) { c.Assert(err, IsNil) err = txn.Commit() c.Assert(err, IsNil) - v2, err := txn.CommittedVersion() + v2, err := globalVersionProvider.CurrentVersion() c.Assert(err, IsNil) s = t.getSnapshot(c, v2) diff --git a/store/localstore/txn.go b/store/localstore/txn.go index 44092f2d57..dc87e651b9 100644 --- a/store/localstore/txn.go +++ b/store/localstore/txn.go @@ -142,14 +142,6 @@ func (txn *dbTxn) Commit() error { return errors.Trace(txn.doCommit()) } -func (txn *dbTxn) CommittedVersion() (kv.Version, error) { - // Check if this transaction is not committed. - if txn.version.Cmp(kv.MinVersion) == 0 { - return kv.MinVersion, kv.ErrNotCommitted - } - return txn.version, nil -} - func (txn *dbTxn) close() error { txn.UnionStore.Release() txn.snapshotVals = nil