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 TestOwnerChange #46573

Closed
Tracked by #41316
djshow832 opened this issue Aug 31, 2023 · 0 comments · Fixed by #46594
Closed
Tracked by #41316

Data race in TestOwnerChange #46573

djshow832 opened this issue Aug 31, 2023 · 0 comments · Fixed by #46594
Labels
component/test severity/moderate type/bug The issue is confirmed as a bug.

Comments

@djshow832
Copy link
Contributor

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
Read at 0x00c00a202858 by goroutine 49735:
  github.com/dgraph-io/ristretto.(*Cache).Get()
      external/com_github_dgraph_io_ristretto/cache.go:225 +0x47
  github.com/pingcap/tidb/statistics/handle/cache/internal/lfu.(*LFU).Get()
      statistics/handle/cache/internal/lfu/lfu_cache.go:80 +0x71
  github.com/pingcap/tidb/statistics/handle/cache.(*StatsCache).getCache()
      statistics/handle/cache/statscacheinner.go:101 +0x65
  github.com/pingcap/tidb/statistics/handle/cache.(*StatsCache).GetFromUser()
      statistics/handle/cache/statscacheinner.go:97 +0x49
  github.com/pingcap/tidb/statistics/handle.(*Handle).GetPartitionStats()
      statistics/handle/handle.go:749 +0x1f6
  github.com/pingcap/tidb/statistics/handle.(*Handle).GetTableStats()
      statistics/handle/handle.go:731 +0x72
  github.com/pingcap/tidb/planner/core.getStatsTable()
      planner/core/logical_plan_builder.go:4724 +0x389
  github.com/pingcap/tidb/planner/core.(*DataSource).initStats()
      planner/core/stats.go:252 +0x1ae
  github.com/pingcap/tidb/planner/core.(*DataSource).DeriveStats()
      planner/core/stats.go:434 +0x172
  github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).recursiveDeriveStats()
      planner/core/stats.go:138 +0x452
  github.com/pingcap/tidb/planner/core.(*DataSource).recursiveDeriveStats()
      <autogenerated>:1 +0x57
  github.com/pingcap/tidb/planner/core.(*baseLogicalPlan).recursiveDeriveStats()
      planner/core/stats.go:131 +0x231
  github.com/pingcap/tidb/planner/core.(*LogicalProjection).recursiveDeriveStats()
      <autogenerated>:1 +0x57
  github.com/pingcap/tidb/planner/core.physicalOptimize()
      planner/core/optimizer.go:1158 +0x1bd
  github.com/pingcap/tidb/planner/core.DoOptimizeAndLogicAsRet()
      planner/core/optimizer.go:315 +0x394
  github.com/pingcap/tidb/planner/core.DoOptimize()
      planner/core/optimizer.go:340 +0x1d4
  github.com/pingcap/tidb/planner.optimize()
      planner/optimize.go:515 +0xa44
  github.com/pingcap/tidb/planner.Optimize()
      planner/optimize.go:338 +0x153b
  github.com/pingcap/tidb/executor.(*Compiler).Compile()
      executor/compiler.go:98 +0x87d
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2209 +0xe96
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1644 +0x35a
  github.com/pingcap/tidb/disttask/framework/storage.ExecSQL()
      disttask/framework/storage/task_table.go:93 +0x102
  github.com/pingcap/tidb/disttask/framework/storage.(*TaskManager).executeSQLWithNewSession.func1()
      disttask/framework/storage/task_table.go:175 +0xe8
  github.com/pingcap/tidb/disttask/framework/storage.(*TaskManager).WithNewSession()
      disttask/framework/storage/task_table.go:140 +0x16b
  github.com/pingcap/tidb/disttask/framework/storage.(*TaskManager).executeSQLWithNewSession()
      disttask/framework/storage/task_table.go:174 +0x144
  github.com/pingcap/tidb/disttask/framework/storage.(*TaskManager).GetGlobalTasksInStates()
      disttask/framework/storage/task_table.go:239 +0x13c
  github.com/pingcap/tidb/disttask/framework/dispatcher.(*Manager).dispatchTaskLoop()
      disttask/framework/dispatcher/dispatcher_manager.go:145 +0x357
  github.com/pingcap/tidb/disttask/framework/dispatcher.(*Manager).dispatchTaskLoop-fm()
      <autogenerated>:1 +0x33
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x84

Previous write at 0x00c00a202858 by goroutine 59360:
  github.com/dgraph-io/ristretto.(*Cache).Close()
      external/com_github_dgraph_io_ristretto/cache.go:363 +0xf2
  github.com/pingcap/tidb/statistics/handle/cache/internal/lfu.(*LFU).Close.func1()
      statistics/handle/cache/internal/lfu/lfu_cache.go:222 +0x71
  sync.(*Once).doSlow()
      GOROOT/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      GOROOT/src/sync/once.go:65 +0x44
  github.com/pingcap/tidb/statistics/handle/cache/internal/lfu.(*LFU).Close()
      statistics/handle/cache/internal/lfu/lfu_cache.go:219 +0x5c
  github.com/pingcap/tidb/statistics/handle/cache.(*StatsCache).Close()
      statistics/handle/cache/statscacheinner.go:163 +0x4b
  github.com/pingcap/tidb/statistics/handle.(*Handle).Close()
      statistics/handle/handle.go:2027 +0x97
  github.com/pingcap/tidb/domain.(*Domain).Close()
      domain/domain.go:1033 +0x7b2
  github.com/pingcap/tidb/domain.(*Domain).Close-fm()
      <autogenerated>:1 +0x33
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x84

Goroutine 49735 (running) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:152 +0xf0
  github.com/pingcap/tidb/disttask/framework/dispatcher.(*Manager).Start()
      disttask/framework/dispatcher/dispatcher_manager.go:110 +0xab
  github.com/pingcap/tidb/domain.(*Domain).distTaskFrameworkLoop.func2()
      domain/domain.go:1485 +0x329
  github.com/pingcap/tidb/domain.(*Domain).distTaskFrameworkLoop()
      domain/domain.go:1503 +0x36d
  github.com/pingcap/tidb/domain.(*Domain).InitDistTaskLoop.func1()
      domain/domain.go:1460 +0xeb
  github.com/pingcap/tidb/util.(*WaitGroupEnhancedWrapper).Run.func1()
      util/wait_group_wrapper.go:96 +0xd0

Goroutine 59360 (finished) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:152 +0xf0
  disttask/framework/framework_test_test.TestOwnerChange.(*DistExecutionContext).Close.func2()
      testkit/mockstore.go:156 +0x249
  testing.(*common).Cleanup.func1()
      GOROOT/src/testing/testing.go:1169 +0x182
  testing.(*common).runCleanup()
      GOROOT/src/testing/testing.go:1347 +0x1c2
  testing.tRunner.func2()
      GOROOT/src/testing/testing.go:1589 +0x50
  runtime.deferreturn()
      GOROOT/src/runtime/panic.go:477 +0x30
  github.com/pingcap/failpoint.parse()
      external/com_github_pingcap_failpoint/terms.go:126 +0xa5
  github.com/pingcap/failpoint.newTerms()
      external/com_github_pingcap_failpoint/terms.go:98 +0x3e
  github.com/pingcap/failpoint.(*Failpoint).Enable()
      external/com_github_pingcap_failpoint/failpoint.go:54 +0x3e
  github.com/pingcap/failpoint.(*Failpoints).Enable()
      external/com_github_pingcap_failpoint/failpoints.go:105 +0x276
  github.com/pingcap/failpoint.Enable()
      external/com_github_pingcap_failpoint/failpoints.go:222 +0x1d6
  disttask/framework/framework_test_test.TestOwnerChange()
      disttask/framework/framework_test.go:344 +0x1d7
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1667 +0xa4
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3376 +0x7aa
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x64
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3748 +0x130
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2130 +0x15a
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1644 +0x35a
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1610 +0x11a
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3369 +0x74a
  github.com/pingcap/tidb/session.BootstrapSession4DistExecution()
      session/session.go:3295 +0x4b
  github.com/pingcap/tidb/testkit.bootstrap4DistExecution()
      testkit/mockstore.go:215 +0x72
  github.com/pingcap/tidb/testkit.NewDistExecutionContext()
      testkit/mockstore.go:180 +0x20a
  github.com/pingcap/tidb/domain.(*Domain).rebuildSysVarCache()
      domain/sysvar_cache.go:146 +0x7d0
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1667 +0xa4
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3376 +0x7aa
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x64
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3748 +0x130
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2130 +0x15a
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1644 +0x35a
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1610 +0x11a
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3369 +0x74a
  github.com/pingcap/tidb/session.BootstrapSession4DistExecution()
      session/session.go:3295 +0x4b
  github.com/pingcap/tidb/testkit.bootstrap4DistExecution()
      testkit/mockstore.go:215 +0x72
  github.com/pingcap/tidb/testkit.NewDistExecutionContext()
      testkit/mockstore.go:180 +0x20a
  github.com/pingcap/tidb/domain.(*Domain).rebuildSysVarCache()
      domain/sysvar_cache.go:146 +0x7d0
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1667 +0xa4
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3376 +0x7aa
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x64
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3748 +0x130
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2130 +0x15a
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1644 +0x35a
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1610 +0x11a
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3369 +0x74a
  github.com/pingcap/tidb/session.BootstrapSession4DistExecution()
      session/session.go:3295 +0x4b
  github.com/pingcap/tidb/testkit.bootstrap4DistExecution()
      testkit/mockstore.go:215 +0x72
  github.com/pingcap/tidb/testkit.NewDistExecutionContext()
      testkit/mockstore.go:180 +0x20a
  disttask/framework/framework_test_test.TestOwnerChange()
      disttask/framework/framework_test.go:340 +0xf3
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44

See https://do.pingcap.net/jenkins/blue/organizations/jenkins/pingcap%2Ftidb%2Fghpr_unit_test/detail/ghpr_unit_test/31636/pipeline/

4. What is your TiDB version? (Required)

master

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

Successfully merging a pull request may close this issue.

2 participants