From 99837f5927e7ac003028e0b2569490f0b8c6faee Mon Sep 17 00:00:00 2001 From: Lynn Date: Tue, 13 Nov 2018 01:09:46 +0800 Subject: [PATCH] kv, store: remove `Rollback` in `RunInNewTxn` (#8250) (#8277) --- kv/txn.go | 2 -- store/tikv/2pc_fail_test.go | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/kv/txn.go b/kv/txn.go index 5bea8f384ae94..323722040dbc5 100644 --- a/kv/txn.go +++ b/kv/txn.go @@ -60,8 +60,6 @@ func RunInNewTxn(store Storage, retryable bool, f func(txn Transaction) error) e } if retryable && IsRetryableError(err) { log.Warnf("[kv] Retry txn %v original txn %v err %v", txn, originalTxnTS, err) - err1 := txn.Rollback() - terror.Log(errors.Trace(err1)) BackOff(i) continue } diff --git a/store/tikv/2pc_fail_test.go b/store/tikv/2pc_fail_test.go index 63701dd1b5f9c..3a440f878307d 100644 --- a/store/tikv/2pc_fail_test.go +++ b/store/tikv/2pc_fail_test.go @@ -17,6 +17,7 @@ import ( gofail "github.com/etcd-io/gofail/runtime" "github.com/juju/errors" . "github.com/pingcap/check" + "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/terror" "golang.org/x/net/context" ) @@ -33,6 +34,10 @@ func (s *testCommitterSuite) TestFailCommitPrimaryRpcErrors(c *C) { err = t1.Commit(context.Background()) c.Assert(err, NotNil) c.Assert(terror.ErrorEqual(err, terror.ErrResultUndetermined), IsTrue, Commentf("%s", errors.ErrorStack(err))) + + // We don't need to call "Rollback" after "Commit" fails. + err = t1.Rollback() + c.Assert(err, Equals, kv.ErrInvalidTxn) } // TestFailCommitPrimaryRegionError tests RegionError is handled properly when