From 412869121aa9c6f941eedcb0d7c8a243ce8378ca Mon Sep 17 00:00:00 2001 From: Shuaipeng Yu Date: Sun, 5 May 2019 19:25:04 +0800 Subject: [PATCH] disable auto retry by default Signed-off-by: Shuaipeng Yu --- ddl/db_test.go | 1 + executor/write_test.go | 1 + server/server_test.go | 1 + session/session_test.go | 15 +++++++++++++++ sessionctx/variable/tidb_vars.go | 2 +- 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ddl/db_test.go b/ddl/db_test.go index 5c10247ba7f76..576dd61fb0524 100644 --- a/ddl/db_test.go +++ b/ddl/db_test.go @@ -1280,6 +1280,7 @@ func (s *testDBSuite8) TestColumn(c *C) { s.tk = testkit.NewTestKit(c, s.store) s.tk.MustExec("use " + s.schemaName) s.tk.MustExec("create table t2 (c1 int, c2 int, c3 int)") + s.tk.MustExec("set @@tidb_disable_txn_auto_retry = 0") s.testAddColumn(c) s.testDropColumn(c) s.tk.MustExec("drop table t2") diff --git a/executor/write_test.go b/executor/write_test.go index 7bb7906f9a214..a9c2eb8cdfc4c 100644 --- a/executor/write_test.go +++ b/executor/write_test.go @@ -2467,6 +2467,7 @@ func (s *testSuite2) TestAutoIDInRetry(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("create table t (id int not null auto_increment primary key)") + tk.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk.MustExec("begin") tk.MustExec("insert into t values ()") tk.MustExec("insert into t values (),()") diff --git a/server/server_test.go b/server/server_test.go index 8271c2391b584..f23d2b0c793ed 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -682,6 +682,7 @@ func runTestConcurrentUpdate(c *C) { dbt.mustExec("drop table if exists test2") dbt.mustExec("create table test2 (a int, b int)") dbt.mustExec("insert test2 values (1, 1)") + dbt.mustExec("set @@tidb_disable_txn_auto_retry = 0") txn1, err := dbt.db.Begin() c.Assert(err, IsNil) diff --git a/session/session_test.go b/session/session_test.go index 1a4d3955ea16b..7d1d8d0029772 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -293,6 +293,7 @@ func (s *testSessionSuite) TestRowLock(c *C) { tk.MustExec("insert t values (12, 2, 3)") tk.MustExec("insert t values (13, 2, 3)") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk1.MustExec("begin") tk1.MustExec("update t set c2=21 where c1=11") @@ -507,6 +508,7 @@ func (s *testSessionSuite) TestRetryResetStmtCtx(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("create table retrytxn (a int unique, b int)") tk.MustExec("insert retrytxn values (1, 1)") + tk.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk.MustExec("begin") tk.MustExec("update retrytxn set b = b + 1 where a = 1") @@ -665,6 +667,7 @@ func (s *testSessionSuite) TestRetryPreparedStmt(c *C) { tk.MustExec("create table t (c1 int, c2 int, c3 int)") tk.MustExec("insert t values (11, 2, 3)") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk1.MustExec("begin") tk1.MustExec("update t set c2=? where c1=11;", 21) @@ -881,6 +884,7 @@ func (s *testSessionSuite) TestAutoIncrementWithRetry(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk1 := testkit.NewTestKitWithInit(c, s.store) + tk.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk.MustExec("create table t (c2 int, c1 int not null auto_increment, PRIMARY KEY (c1))") tk.MustExec("insert into t (c2) values (1), (2), (3), (4), (5)") @@ -1308,6 +1312,9 @@ func (s *testSessionSuite) TestRetry(c *C) { tk2 := testkit.NewTestKitWithInit(c, s.store) tk3 := testkit.NewTestKitWithInit(c, s.store) tk3.MustExec("SET SESSION autocommit=0;") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") + tk2.MustExec("set @@tidb_disable_txn_auto_retry = 0") + tk3.MustExec("set @@tidb_disable_txn_auto_retry = 0") var wg sync.WaitGroup wg.Add(3) @@ -1449,6 +1456,7 @@ func (s *testSessionSuite) TestResetCtx(c *C) { tk.MustExec("create table t (i int auto_increment not null key);") tk.MustExec("insert into t values (1);") + tk.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk.MustExec("begin;") tk.MustExec("insert into t values (10);") tk.MustExec("update t set i = i + row_count();") @@ -1480,6 +1488,8 @@ func (s *testSessionSuite) TestUnique(c *C) { tk1 := testkit.NewTestKitWithInit(c, s.store) tk2 := testkit.NewTestKitWithInit(c, s.store) + tk.MustExec("set @@tidb_disable_txn_auto_retry = 0") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk.MustExec(`CREATE TABLE test ( id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, val int UNIQUE, PRIMARY KEY (id)); `) tk.MustExec("begin;") tk.MustExec("insert into test(id, val) values(1, 1);") @@ -1764,6 +1774,7 @@ func (s *testSchemaSuite) TestSchemaCheckerSQL(c *C) { tk.MustExec(`insert into t values(1, 1);`) // The schema version is out of date in the first transaction, but the SQL can be retried. + tk.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk.MustExec(`begin;`) tk1.MustExec(`alter table t add index idx(c);`) tk.MustExec(`insert into t values(2, 2);`) @@ -1808,6 +1819,7 @@ func (s *testSchemaSuite) TestPrepareStmtCommitWhenSchemaChanged(c *C) { tk1.MustExec("execute stmt using @a, @a") tk1.MustExec("commit") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk1.MustExec("begin") tk.MustExec("alter table t drop column b") tk1.MustExec("execute stmt using @a, @a") @@ -1820,6 +1832,7 @@ func (s *testSchemaSuite) TestCommitWhenSchemaChanged(c *C) { tk1 := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("create table t (a int, b int)") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk1.MustExec("begin") tk1.MustExec("insert into t values (1, 1)") @@ -1837,6 +1850,7 @@ func (s *testSchemaSuite) TestRetrySchemaChange(c *C) { tk.MustExec("create table t (a int primary key, b int)") tk.MustExec("insert into t values (1, 1)") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk1.MustExec("begin") tk1.MustExec("update t set b = 5 where a = 1") @@ -1867,6 +1881,7 @@ func (s *testSchemaSuite) TestRetryMissingUnionScan(c *C) { tk.MustExec("create table t (a int primary key, b int unique, c int)") tk.MustExec("insert into t values (1, 1, 1)") + tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0") tk1.MustExec("begin") tk1.MustExec("update t set b = 1, c = 2 where b = 2") tk1.MustExec("update t set b = 1, c = 2 where a = 1") diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index 581481a78cb73..516f45d7a57b7 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -303,7 +303,7 @@ const ( DefTiDBMemQuotaDistSQL = 32 << 30 // 32GB. DefTiDBGeneralLog = 0 DefTiDBRetryLimit = 10 - DefTiDBDisableTxnAutoRetry = false + DefTiDBDisableTxnAutoRetry = true DefTiDBConstraintCheckInPlace = false DefTiDBHashJoinConcurrency = 5 DefTiDBProjectionConcurrency = 4