@@ -293,6 +293,7 @@ func (s *testSessionSuite) TestRowLock(c *C) {
293
293
tk .MustExec ("insert t values (12, 2, 3)" )
294
294
tk .MustExec ("insert t values (13, 2, 3)" )
295
295
296
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
296
297
tk1 .MustExec ("begin" )
297
298
tk1 .MustExec ("update t set c2=21 where c1=11" )
298
299
@@ -507,6 +508,7 @@ func (s *testSessionSuite) TestRetryResetStmtCtx(c *C) {
507
508
tk := testkit .NewTestKitWithInit (c , s .store )
508
509
tk .MustExec ("create table retrytxn (a int unique, b int)" )
509
510
tk .MustExec ("insert retrytxn values (1, 1)" )
511
+ tk .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
510
512
tk .MustExec ("begin" )
511
513
tk .MustExec ("update retrytxn set b = b + 1 where a = 1" )
512
514
@@ -665,6 +667,7 @@ func (s *testSessionSuite) TestRetryPreparedStmt(c *C) {
665
667
tk .MustExec ("create table t (c1 int, c2 int, c3 int)" )
666
668
tk .MustExec ("insert t values (11, 2, 3)" )
667
669
670
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
668
671
tk1 .MustExec ("begin" )
669
672
tk1 .MustExec ("update t set c2=? where c1=11;" , 21 )
670
673
@@ -881,6 +884,7 @@ func (s *testSessionSuite) TestAutoIncrementWithRetry(c *C) {
881
884
tk := testkit .NewTestKitWithInit (c , s .store )
882
885
tk1 := testkit .NewTestKitWithInit (c , s .store )
883
886
887
+ tk .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
884
888
tk .MustExec ("create table t (c2 int, c1 int not null auto_increment, PRIMARY KEY (c1))" )
885
889
tk .MustExec ("insert into t (c2) values (1), (2), (3), (4), (5)" )
886
890
@@ -1308,6 +1312,9 @@ func (s *testSessionSuite) TestRetry(c *C) {
1308
1312
tk2 := testkit .NewTestKitWithInit (c , s .store )
1309
1313
tk3 := testkit .NewTestKitWithInit (c , s .store )
1310
1314
tk3 .MustExec ("SET SESSION autocommit=0;" )
1315
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1316
+ tk2 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1317
+ tk3 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1311
1318
1312
1319
var wg sync.WaitGroup
1313
1320
wg .Add (3 )
@@ -1449,6 +1456,7 @@ func (s *testSessionSuite) TestResetCtx(c *C) {
1449
1456
1450
1457
tk .MustExec ("create table t (i int auto_increment not null key);" )
1451
1458
tk .MustExec ("insert into t values (1);" )
1459
+ tk .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1452
1460
tk .MustExec ("begin;" )
1453
1461
tk .MustExec ("insert into t values (10);" )
1454
1462
tk .MustExec ("update t set i = i + row_count();" )
@@ -1480,6 +1488,8 @@ func (s *testSessionSuite) TestUnique(c *C) {
1480
1488
tk1 := testkit .NewTestKitWithInit (c , s .store )
1481
1489
tk2 := testkit .NewTestKitWithInit (c , s .store )
1482
1490
1491
+ tk .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1492
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1483
1493
tk .MustExec (`CREATE TABLE test ( id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, val int UNIQUE, PRIMARY KEY (id)); ` )
1484
1494
tk .MustExec ("begin;" )
1485
1495
tk .MustExec ("insert into test(id, val) values(1, 1);" )
@@ -1764,6 +1774,7 @@ func (s *testSchemaSuite) TestSchemaCheckerSQL(c *C) {
1764
1774
tk .MustExec (`insert into t values(1, 1);` )
1765
1775
1766
1776
// The schema version is out of date in the first transaction, but the SQL can be retried.
1777
+ tk .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1767
1778
tk .MustExec (`begin;` )
1768
1779
tk1 .MustExec (`alter table t add index idx(c);` )
1769
1780
tk .MustExec (`insert into t values(2, 2);` )
@@ -1808,6 +1819,7 @@ func (s *testSchemaSuite) TestPrepareStmtCommitWhenSchemaChanged(c *C) {
1808
1819
tk1 .MustExec ("execute stmt using @a, @a" )
1809
1820
tk1 .MustExec ("commit" )
1810
1821
1822
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1811
1823
tk1 .MustExec ("begin" )
1812
1824
tk .MustExec ("alter table t drop column b" )
1813
1825
tk1 .MustExec ("execute stmt using @a, @a" )
@@ -1820,6 +1832,7 @@ func (s *testSchemaSuite) TestCommitWhenSchemaChanged(c *C) {
1820
1832
tk1 := testkit .NewTestKitWithInit (c , s .store )
1821
1833
tk .MustExec ("create table t (a int, b int)" )
1822
1834
1835
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1823
1836
tk1 .MustExec ("begin" )
1824
1837
tk1 .MustExec ("insert into t values (1, 1)" )
1825
1838
@@ -1837,6 +1850,7 @@ func (s *testSchemaSuite) TestRetrySchemaChange(c *C) {
1837
1850
tk .MustExec ("create table t (a int primary key, b int)" )
1838
1851
tk .MustExec ("insert into t values (1, 1)" )
1839
1852
1853
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1840
1854
tk1 .MustExec ("begin" )
1841
1855
tk1 .MustExec ("update t set b = 5 where a = 1" )
1842
1856
@@ -1867,6 +1881,7 @@ func (s *testSchemaSuite) TestRetryMissingUnionScan(c *C) {
1867
1881
tk .MustExec ("create table t (a int primary key, b int unique, c int)" )
1868
1882
tk .MustExec ("insert into t values (1, 1, 1)" )
1869
1883
1884
+ tk1 .MustExec ("set @@tidb_disable_txn_auto_retry = 0" )
1870
1885
tk1 .MustExec ("begin" )
1871
1886
tk1 .MustExec ("update t set b = 1, c = 2 where b = 2" )
1872
1887
tk1 .MustExec ("update t set b = 1, c = 2 where a = 1" )
@@ -2320,9 +2335,12 @@ func (s *testSessionSuite) TestKVVars(c *C) {
2320
2335
tk .MustExec ("insert kvvars values (1, 1)" )
2321
2336
tk2 := testkit .NewTestKitWithInit (c , s .store )
2322
2337
tk2 .MustExec ("set @@tidb_backoff_lock_fast = 1" )
2338
+ tk2 .MustExec ("set @@tidb_back_off_weight = 100" )
2323
2339
backoffVal := new (int64 )
2340
+ backOffWeightVal := new (int32 )
2324
2341
tk2 .Se .GetSessionVars ().KVVars .Hook = func (name string , vars * kv.Variables ) {
2325
2342
atomic .StoreInt64 (backoffVal , int64 (vars .BackoffLockFast ))
2343
+ atomic .StoreInt32 (backOffWeightVal , int32 (vars .BackOffWeight ))
2326
2344
}
2327
2345
wg := new (sync.WaitGroup )
2328
2346
wg .Add (2 )
@@ -2345,7 +2363,14 @@ func (s *testSessionSuite) TestKVVars(c *C) {
2345
2363
wg .Done ()
2346
2364
}()
2347
2365
wg .Wait ()
2366
+ for {
2367
+ tk2 .MustQuery ("select * from kvvars" )
2368
+ if atomic .LoadInt32 (backOffWeightVal ) != 0 {
2369
+ break
2370
+ }
2371
+ }
2348
2372
c .Assert (atomic .LoadInt64 (backoffVal ), Equals , int64 (1 ))
2373
+ c .Assert (atomic .LoadInt32 (backOffWeightVal ), Equals , int32 (100 ))
2349
2374
}
2350
2375
2351
2376
func (s * testSessionSuite ) TestCommitRetryCount (c * C ) {
0 commit comments