Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv, store: remove Rollback in RunInNewTxn #8250

Merged
merged 4 commits into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I said

If "Commit" is completed, it will call txn's close. So we can remove Rollback and the print log in RunInNewTxn.

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 @@ -18,6 +18,7 @@ import (
. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/parser/terror"
"github.com/pingcap/tidb/kv"
"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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment confuses me. Why do you call the Rollback() in line 39?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is used to prove why the rollback was removed in "RunInNewTxn".

err = t1.Rollback()
c.Assert(err, Equals, kv.ErrInvalidTxn)
}

// TestFailCommitPrimaryRegionError tests RegionError is handled properly when
Expand Down