Skip to content

Commit

Permalink
kv, store: remove Rollback in RunInNewTxn (#8250) (#8277)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored and zz-jason committed Nov 12, 2018
1 parent a59be18 commit 99837f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 0 additions & 2 deletions kv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions store/tikv/2pc_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down

0 comments on commit 99837f5

Please sign in to comment.