Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATA RACE in the sessionctx/variable.(*SessionVars) #50715

Closed
Tracked by #41316
hawkingrei opened this issue Jan 25, 2024 · 0 comments · Fixed by #50729
Closed
Tracked by #41316

DATA RACE in the sessionctx/variable.(*SessionVars) #50715

hawkingrei opened this issue Jan 25, 2024 · 0 comments · Fixed by #50729
Assignees
Labels
component/test severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@hawkingrei
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

2. What did you expect to see? (Required)

3. What did you see instead (Required)

==================
WARNING: DATA RACE
Write at 0x00c008b3bc58 by goroutine 281:
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SessionVars).SetStatusFlag()
      pkg/sessionctx/variable/session.go:2274 +0x436
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SessionVars).SetInTxn()
      pkg/sessionctx/variable/session.go:2285 +0x40d
  github.com/pingcap/tidb/pkg/session.(*session).RollbackTxn()
      pkg/session/session.go:1025 +0x3d3
  github.com/pingcap/tidb/pkg/session.(*session).Close()
      pkg/session/session.go:2586 +0x42c
  github.com/pingcap/tidb/pkg/server.(*TiDBContext).Close()
      pkg/server/driver_tidb.go:313 +0x11a
  github.com/pingcap/tidb/pkg/server.closeConn.func1()
      pkg/server/conn.go:401 +0x3c4
  sync.(*Once).doSlow()
      GOROOT/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      GOROOT/src/sync/once.go:65 +0x44
  github.com/pingcap/tidb/pkg/server.closeConn()
      pkg/server/conn.go:383 +0xda
  github.com/pingcap/tidb/pkg/server.(*clientConn).closeWithoutLock()
      pkg/server/conn.go:416 +0x2b3
  github.com/pingcap/tidb/pkg/server.(*Server).KillAllConnections()
      pkg/server/server.go:939 +0x2b1
  github.com/pingcap/tidb/pkg/server.(*Server).DrainClients()
      pkg/server/server.go:986 +0x478
  github.com/pingcap/tidb/pkg/server.TestShutDown()
      pkg/server/conn_test.go:779 +0x78c
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:146 +0x904
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadSysVarCacheLoop()
      pkg/domain/domain.go:1722 +0x93
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3342 +0x724
  github.com/pingcap/tidb/pkg/domain.(*Domain).GetSessionCache()
      pkg/domain/sysvar_cache.go:62 +0x50
  github.com/pingcap/tidb/pkg/session.(*session).loadCommonGlobalVariablesIfNeeded()
      pkg/session/session.go:3719 +0x2ce
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2092 +0x184
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1604 +0x3b9
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadPrivilegeLoop()
      pkg/domain/domain.go:1665 +0x108
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3335 +0x6ca
  github.com/pingcap/tidb/pkg/session.BootstrapSession()
      pkg/session/session.go:3256 +0xad
  github.com/pingcap/tidb/pkg/testkit.bootstrap()
      pkg/testkit/mockstore.go:290 +0x94
  github.com/pingcap/tidb/pkg/testkit.CreateMockStoreAndDomain()
      pkg/testkit/mockstore.go:263 +0xd5
  github.com/pingcap/tidb/pkg/server.TestShutDown()
      pkg/server/conn_test.go:749 +0x4c
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44
Previous read at 0x00c008b3bc58 by goroutine 40943:
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SessionVars).GetStatusFlag()
      pkg/sessionctx/variable/session.go:2279 +0x19d
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SessionVars).InTxn()
      pkg/sessionctx/variable/session.go:2293 +0x195
  github.com/pingcap/tidb/pkg/server.(*Server).DrainClients.func1()
      pkg/server/server.go:968 +0x158
Goroutine 281 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1648 +0x845
  testing.runTests.func1()
      GOROOT/src/testing/testing.go:2054 +0x84
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x261
  testing.runTests()
      GOROOT/src/testing/testing.go:2052 +0x8ad
  testing.(*M).Run()
      GOROOT/src/testing/testing.go:1925 +0xcd7
  github.com/pingcap/tidb/pkg/testkit/testmain.(*testingM).Run()
      pkg/testkit/testmain/wrapper.go:27 +0x43
  go.uber.org/goleak.VerifyTestMain()
      external/org_uber_go_goleak/testmain.go:53 +0x64
  github.com/pingcap/tidb/pkg/server.TestMain()
      pkg/server/main_test.go:84 +0x1076
  main.main()
      bazel-out/k8-fastbuild/bin/pkg/server/server_test_/testmain.go:221 +0x5d1
Goroutine 40943 (running) created at:
  github.com/pingcap/tidb/pkg/server.(*Server).DrainClients()
      pkg/server/server.go:965 +0x38a
  github.com/pingcap/tidb/pkg/server.TestShutDown()
      pkg/server/conn_test.go:779 +0x78c
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:146 +0x904
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadSysVarCacheLoop()
      pkg/domain/domain.go:1722 +0x93
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3342 +0x724
  github.com/pingcap/tidb/pkg/domain.(*Domain).GetSessionCache()
      pkg/domain/sysvar_cache.go:62 +0x50
  github.com/pingcap/tidb/pkg/session.(*session).loadCommonGlobalVariablesIfNeeded()
      pkg/session/session.go:3719 +0x2ce
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2092 +0x184
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1604 +0x3b9
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadPrivilegeLoop()
      pkg/domain/domain.go:1665 +0x108
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3335 +0x6ca
  github.com/pingcap/tidb/pkg/session.BootstrapSession()
      pkg/session/session.go:3256 +0xad
  github.com/pingcap/tidb/pkg/testkit.bootstrap()
      pkg/testkit/mockstore.go:290 +0x94
  github.com/pingcap/tidb/pkg/testkit.CreateMockStoreAndDomain()
      pkg/testkit/mockstore.go:263 +0xd5
  github.com/pingcap/tidb/pkg/server.TestShutDown()
      pkg/server/conn_test.go:749 +0x4c
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44
================== 

4. What is your TiDB version? (Required)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/test severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants