From b93defa381c8de1e509a5c5ecdabdd07ad14e65b Mon Sep 17 00:00:00 2001 From: pingcap-github-bot Date: Tue, 3 Mar 2020 16:36:41 +0800 Subject: [PATCH] test: fix data race in TestDisableTxnAutoRetry (#14825) (#14856) --- session/session_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/session/session_test.go b/session/session_test.go index ec9c1b2f838bd..bc74ef40bdf78 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -2540,7 +2540,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") @@ -2552,7 +2556,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"))