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

session: make tidb_disable_txn_auto_retry disable retry for the explicit transactions #10339

Merged
merged 2 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func (s *session) doCommitWithRetry(ctx context.Context) error {
// For autocommit single statement transactions, the history count is always 1.
// For explicit transactions, the statement count is more than 1.
history := GetHistory(s)
if history.Count() > 1 && strings.Contains(err.Error(), util.WriteConflictMarker) {
if history.Count() > 1 {
commitRetryLimit = 0
}
}
Expand Down
6 changes: 3 additions & 3 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2421,12 +2421,12 @@ func (s *testSchemaSuite) TestDisableTxnAutoRetry(c *C) {
tk2.MustExec("alter table no_retry add index idx(id)")
tk2.MustQuery("select * from no_retry").Check(testkit.Rows("8"))
tk1.MustExec("update no_retry set id = 10")
tk1.MustExec("commit")
tk2.MustQuery("select * from no_retry").Check(testkit.Rows("10"))
_, err = tk1.Se.Execute(context.Background(), "commit")
c.Assert(err, NotNil)

// set autocommit to begin and commit
tk1.MustExec("set autocommit = 0")
tk1.MustQuery("select * from no_retry").Check(testkit.Rows("10"))
tk1.MustQuery("select * from no_retry").Check(testkit.Rows("8"))
tk2.MustExec("update no_retry set id = 11")
tk1.MustExec("update no_retry set id = 12")
_, err = tk1.Se.Execute(context.Background(), "set autocommit = 1")
Expand Down