diff --git a/session/session.go b/session/session.go index e220ed42def4f..e25198f8b57e5 100644 --- a/session/session.go +++ b/session/session.go @@ -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 } } diff --git a/session/session_test.go b/session/session_test.go index 714001eac15c7..93d51601e17f0 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -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")