Skip to content

Commit

Permalink
test: fix data race in TestDisableTxnAutoRetry (#14825)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored Feb 19, 2020
1 parent 6151db3 commit 5a00c80
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,11 @@ func (s *testSchemaSuite) TestDisableTxnAutoRetry(c *C) {

// test for disable transaction local latch
tk1.Se.GetSessionVars().InRestrictedSQL = false
config.GetGlobalConfig().TxnLocalLatches.Enabled = false
orgCfg := config.GetGlobalConfig()
disableLatchCfg := *orgCfg
disableLatchCfg.TxnLocalLatches.Enabled = false
config.StoreGlobalConfig(&disableLatchCfg)
defer config.StoreGlobalConfig(orgCfg)
tk1.MustExec("begin")
tk1.MustExec("update no_retry set id = 9")

Expand All @@ -2686,7 +2690,9 @@ func (s *testSchemaSuite) TestDisableTxnAutoRetry(c *C) {
c.Assert(strings.Contains(err.Error(), kv.TxnRetryableMark), IsTrue, Commentf("error: %s", err))
tk1.MustExec("rollback")

config.GetGlobalConfig().TxnLocalLatches.Enabled = true
enableLatchCfg := *orgCfg
enableLatchCfg.TxnLocalLatches.Enabled = true
config.StoreGlobalConfig(&enableLatchCfg)
tk1.MustExec("begin")
tk2.MustExec("alter table no_retry add index idx(id)")
tk2.MustQuery("select * from no_retry").Check(testkit.Rows("8"))
Expand Down

0 comments on commit 5a00c80

Please sign in to comment.