Skip to content

Commit

Permalink
kv, store: remove Rollback in RunInNewTxn (#8250) (#8276)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored Nov 14, 2018
1 parent 4ec85cd commit f0df5c6
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 @@ -63,8 +63,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 @@ -16,6 +16,7 @@ package tikv
import (
gofail "github.com/etcd-io/gofail/runtime"
. "github.com/pingcap/check"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/terror"
"github.com/pkg/errors"
"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 f0df5c6

Please sign in to comment.