From aa92d10bc6e2c6ea763cb61c1973bb4d60bbc735 Mon Sep 17 00:00:00 2001 From: shenli Date: Tue, 24 Nov 2015 16:21:41 +0800 Subject: [PATCH] tidb: Make sure TestIssue571 pass Set session maxRetryCnt to unlimited times. --- session.go | 4 +++- session_test.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) 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