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 stmtsummaryv2.GlobalStmtSummary #49778

Open
Tracked by #41316
hawkingrei opened this issue Dec 26, 2023 · 1 comment
Open
Tracked by #41316

data race in the stmtsummaryv2.GlobalStmtSummary #49778

hawkingrei opened this issue Dec 26, 2023 · 1 comment

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 0x00000cb334c8 by goroutine 47:
  pkg/util/stmtsummary/v2/tests/tests_test.closeStmtSummary()
      pkg/util/stmtsummary/v2/tests/table_test.go:568 +0x50
  runtime.deferreturn()
      GOROOT/src/runtime/panic.go:477 +0x30
  github.com/pingcap/tidb/pkg/session.runStmt()
      pkg/session/session.go:2386 +0x71a
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2228 +0x1af8
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).ExecWithContext()
      pkg/testkit/testkit.go:364 +0x889
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExecWithContext()
      pkg/testkit/testkit.go:136 +0xab
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExec()
      pkg/testkit/testkit.go:131 +0x128
  pkg/util/stmtsummary/v2/tests/tests_test.TestPerformanceSchemaforPlanCache()
      pkg/util/stmtsummary/v2/tests/table_test.go:515 +0x105
  github.com/pingcap/tidb/pkg/session.runStmt()
      pkg/session/session.go:2386 +0x71a
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2228 +0x1af8
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).ExecWithContext()
      pkg/testkit/testkit.go:364 +0x889
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExecWithContext()
      pkg/testkit/testkit.go:136 +0xab
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExec()
      pkg/testkit/testkit.go:131 +0x128
  pkg/util/stmtsummary/v2/tests/tests_test.TestPerformanceSchemaforPlanCache()
      pkg/util/stmtsummary/v2/tests/table_test.go:514 +0xe8
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadSysVarCacheLoop()
      pkg/domain/domain.go:1715 +0x93
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3350 +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:3722 +0xf4
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2088 +0x184
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1600 +0x3b9
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadPrivilegeLoop()
      pkg/domain/domain.go:1658 +0x108
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3343 +0x6ca
  github.com/pingcap/tidb/pkg/session.BootstrapSession()
      pkg/session/session.go:3264 +0xad
  github.com/pingcap/tidb/pkg/testkit.bootstrap()
      pkg/testkit/mockstore.go:227 +0x94
  github.com/pingcap/tidb/pkg/testkit.CreateMockStoreAndDomain()
      pkg/testkit/mockstore.go:200 +0xd5
  github.com/pingcap/tidb/pkg/testkit.CreateMockStore()
      pkg/testkit/mockstore.go:68 +0x3d1
  pkg/util/stmtsummary/v2/tests/tests_test.TestPerformanceSchemaforPlanCache()
      pkg/util/stmtsummary/v2/tests/table_test.go:508 +0x6c
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44
Previous read at 0x00000cb334c8 by goroutine 43114:
  github.com/pingcap/tidb/pkg/util/stmtsummary/v2.Enabled()
      pkg/util/stmtsummary/v2/stmtsummary.go:548 +0x64
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).SummaryStmt()
      pkg/executor/adapter.go:1828 +0xfa
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).FinishExecuteStmt()
      pkg/executor/adapter.go:1397 +0x5d9
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).CloseRecordSet()
      pkg/executor/adapter.go:1471 +0x4a
  github.com/pingcap/tidb/pkg/executor.(*recordSet).Close()
      pkg/executor/adapter.go:206 +0x219
  github.com/pingcap/tidb/pkg/session.(*execStmtResult).Close()
      pkg/session/session.go:2459 +0x93
  github.com/pingcap/tidb/pkg/util/sqlexec.RecordSet.Close-fm()
      <autogenerated>:1 +0x42
  github.com/pingcap/tidb/pkg/parser/terror.Call()
      pkg/parser/terror/terror.go:315 +0x3e
  github.com/pingcap/tidb/pkg/disttask/framework/storage.ExecSQL.func1()
      pkg/disttask/framework/storage/task_table.go:124 +0x33
  runtime.deferreturn()
      GOROOT/src/runtime/panic.go:477 +0x30
  github.com/pingcap/tidb/pkg/disttask/framework/storage.(*TaskManager).executeSQLWithNewSession.func1()
      pkg/disttask/framework/storage/task_table.go:214 +0xd7
  github.com/pingcap/tidb/pkg/disttask/framework/storage.(*TaskManager).WithNewSession()
      pkg/disttask/framework/storage/task_table.go:179 +0x166
  github.com/pingcap/tidb/pkg/disttask/framework/storage.(*TaskManager).executeSQLWithNewSession()
      pkg/disttask/framework/storage/task_table.go:213 +0x16b
  github.com/pingcap/tidb/pkg/disttask/framework/storage.(*TaskManager).GetTasksInStates()
      pkg/disttask/framework/storage/task_table.go:327 +0xf2
  github.com/pingcap/tidb/pkg/disttask/framework/taskexecutor.(*Manager).fetchAndFastCancelTasksLoop()
      pkg/disttask/framework/taskexecutor/manager.go:186 +0x399
  github.com/pingcap/tidb/pkg/disttask/framework/taskexecutor.(*Manager).fetchAndFastCancelTasksLoop-fm()
      <autogenerated>:1 +0x33
  github.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).Run.func1()
      pkg/util/wait_group_wrapper.go:157 +0x86
Goroutine 47 (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
  go.uber.org/goleak.VerifyTestMain()
      external/org_uber_go_goleak/testmain.go:53 +0x64
  pkg/util/stmtsummary/v2/tests/tests_test.TestMain()
      pkg/util/stmtsummary/v2/tests/main_test.go:33 +0x52a
  main.main()
      bazel-out/k8-fastbuild/bin/pkg/util/stmtsummary/v2/tests/tests_test_/testmain.go:141 +0x5cb
Goroutine 43114 (running) created at:
  github.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).Run()
      pkg/util/wait_group_wrapper.go:155 +0xe4
  github.com/pingcap/tidb/pkg/disttask/framework/taskexecutor.(*Manager).Start()
      pkg/disttask/framework/taskexecutor/manager.go:134 +0x164
  github.com/pingcap/tidb/pkg/domain.(*Domain).distTaskFrameworkLoop()
      pkg/domain/domain.go:1497 +0x76
  github.com/pingcap/tidb/pkg/domain.(*Domain).InitDistTaskLoop.func1()
      pkg/domain/domain.go:1491 +0xc5
  github.com/pingcap/tidb/pkg/util.(*WaitGroupEnhancedWrapper).Run.func1()
      pkg/util/wait_group_wrapper.go:99 +0xd2 

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
Projects
None yet
Development

No branches or pull requests

5 participants