diff --git a/session.go b/session.go index 4913930d7c..d2c62b1807 100644 --- a/session.go +++ b/session.go @@ -108,6 +108,8 @@ func (h *stmtHistory) clone() *stmtHistory { return &nh } +const unlimitedRetryCnt = -1 + type session struct { txn kv.Transaction // Current transaction args []interface{} // Statment execution args, this should be cleaned up after exec @@ -254,7 +256,7 @@ func (s *session) Retry() error { } } retryCnt++ - if (s.maxRetryCnt > 0) && (retryCnt >= s.maxRetryCnt) { + if (s.maxRetryCnt != unlimitedRetryCnt) && (retryCnt >= s.maxRetryCnt) { return errors.Trace(err) } } diff --git a/session_test.go b/session_test.go index 2e3258aa57..7f51855dc5 100644 --- a/session_test.go +++ b/session_test.go @@ -1131,10 +1131,13 @@ func (s *testSessionSuite) TestIssue571(c *C) { mustExecSQL(c, se, "commit") se1 := newSession(c, store, s.dbName) + se1.(*session).maxRetryCnt = unlimitedRetryCnt mustExecSQL(c, se1, "SET SESSION autocommit=1;") se2 := newSession(c, store, s.dbName) + se2.(*session).maxRetryCnt = unlimitedRetryCnt mustExecSQL(c, se2, "SET SESSION autocommit=1;") se3 := newSession(c, store, s.dbName) + se3.(*session).maxRetryCnt = unlimitedRetryCnt mustExecSQL(c, se3, "SET SESSION autocommit=0;") var wg sync.WaitGroup