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 getIntFromSessionVars #47613

Closed
Tracked by #41316
hawkingrei opened this issue Oct 13, 2023 · 0 comments · Fixed by #47614
Closed
Tracked by #41316

DATA RACE getIntFromSessionVars #47613

hawkingrei opened this issue Oct 13, 2023 · 0 comments · Fixed by #47614
Labels
severity/moderate sig/planner SIG: Planner 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)

==================
WARNING: DATA RACE
Write at 0x00c006bd3530 by goroutine 62409:
  runtime.mapassign_faststr()
      GOROOT/src/runtime/map_faststr.go:203 +0x0
  github.com/pingcap/tidb/sessionctx/variable.(*SessionVars).GetSessionOrGlobalSystemVar()
      sessionctx/variable/session.go:2474 +0x2f7
  github.com/pingcap/tidb/executor.getIntFromSessionVars()
      executor/analyze_utils.go:34 +0x77
  github.com/pingcap/tidb/executor.getBuildSamplingStatsConcurrency()
      executor/analyze_utils.go:47 +0x50
  github.com/pingcap/tidb/executor.(*AnalyzeColumnsExecV2).buildSamplingStats()
      executor/analyze_col_v2.go:267 +0x8f8
  github.com/pingcap/tidb/executor.(*AnalyzeColumnsExecV2).analyzeColumnsPushDownV2()
      executor/analyze_col_v2.go:140 +0x8d1
  github.com/pingcap/tidb/executor.(*AnalyzeColumnsExecV2).analyzeColumnsPushDownWithRetryV2()
      executor/analyze_col_v2.go:59 +0x51
  github.com/pingcap/tidb/executor.analyzeColumnsPushDownEntry()
      executor/analyze_col.go:69 +0xd0
  github.com/pingcap/tidb/executor.(*AnalyzeExec).analyzeWorker()
      executor/analyze.go:496 +0x284
  github.com/pingcap/tidb/executor.(*AnalyzeExec).Next.func1()
      executor/analyze.go:115 +0x58
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x84
Previous read at 0x00c006bd3530 by goroutine 62546:
  runtime.mapaccess2_faststr()
      GOROOT/src/runtime/map_faststr.go:108 +0x0
  github.com/pingcap/tidb/sessionctx/variable.(*SysVar).GetSessionFromHook()
      sessionctx/variable/variable.go:217 +0x2bc
  github.com/pingcap/tidb/sessionctx/variable.(*SessionVars).GetSessionOrGlobalSystemVar()
      sessionctx/variable/session.go:2480 +0x430
  github.com/pingcap/tidb/executor.getIntFromSessionVars()
      executor/analyze_utils.go:34 +0x77
  github.com/pingcap/tidb/executor.getBuildStatsConcurrency()
      executor/analyze_utils.go:43 +0x50
  github.com/pingcap/tidb/executor.(*AnalyzeColumnsExecV2).handleNDVForSpecialIndexes()
      executor/analyze_col_v2.go:483 +0x138
  github.com/pingcap/tidb/executor.(*AnalyzeColumnsExecV2).analyzeColumnsPushDownV2.func1()
      executor/analyze_col_v2.go:136 +0x73
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x84
Goroutine 62409 (running) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:152 +0xf0
  github.com/pingcap/tidb/executor.(*AnalyzeExec).Next()
      executor/analyze.go:115 +0x3bd
  github.com/pingcap/tidb/executor/internal/exec.Next()
      executor/internal/exec/executor.go:283 +0x3d5
  github.com/pingcap/tidb/executor.(*ExecStmt).next()
      executor/adapter.go:1223 +0x94
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor()
      executor/adapter.go:968 +0x559
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay()
      executor/adapter.go:794 +0x41b
  github.com/pingcap/tidb/executor.(*ExecStmt).Exec()
      executor/adapter.go:575 +0x1437
  github.com/pingcap/tidb/session.runStmt()
      session/session.go:2421 +0x701
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2271 +0x1bc4
  github.com/pingcap/tidb/session.(*session).ExecuteInternalStmt()
      session/session.go:2122 +0x1ca
  github.com/pingcap/tidb/session.(*session).ExecRestrictedSQL.func1()
      session/session.go:2087 +0x38c
  github.com/pingcap/tidb/session.(*session).withRestrictedSQLExecutor()
      session/session.go:2073 +0x3a5
  github.com/pingcap/tidb/session.(*session).ExecRestrictedSQL()
      session/session.go:2077 +0x129
  github.com/pingcap/tidb/statistics/handle/util.ExecWithOpts()
      statistics/handle/util/util.go:197 +0x136
  github.com/pingcap/tidb/statistics/handle/autoanalyze.execAnalyzeStmt()
      statistics/handle/autoanalyze/autoanalyze.go:437 +0x54a
  github.com/pingcap/tidb/statistics/handle/autoanalyze.execAutoAnalyze()
      statistics/handle/autoanalyze/autoanalyze.go:409 +0xeb
  github.com/pingcap/tidb/statistics/handle/autoanalyze.autoAnalyzeTable()
      statistics/handle/autoanalyze/autoanalyze.go:247 +0x594
  github.com/pingcap/tidb/statistics/handle/autoanalyze.HandleAutoAnalyze()
      statistics/handle/autoanalyze/autoanalyze.go:194 +0x124c
  github.com/pingcap/tidb/statistics/handle.(*Handle).HandleAutoAnalyze.func1()
      statistics/handle/update.go:38 +0x24b
  github.com/pingcap/tidb/statistics/handle/util.CallWithSCtx()
      statistics/handle/util/util.go:86 +0x3a4
  github.com/pingcap/tidb/statistics/handle.(*Handle).callWithSCtx()
      statistics/handle/update.go:25 +0x76
  github.com/pingcap/tidb/statistics/handle.(*Handle).HandleAutoAnalyze()
      statistics/handle/update.go:37 +0x9b
  github.com/pingcap/tidb/ttl/ttlworker_test.TestTTLAutoAnalyze()
      ttl/ttlworker/job_manager_integration_test.go:229 +0x8b0
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1686 +0xa4
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3368 +0x7aa
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x64
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3740 +0x130
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2132 +0x15a
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1645 +0x35a
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1629 +0x11a
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3361 +0x74a
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3282 +0x4b
  github.com/pingcap/tidb/testkit.bootstrap()
      testkit/mockstore.go:227 +0x86
  github.com/pingcap/tidb/testkit.CreateMockStoreAndDomain()
      testkit/mockstore.go:200 +0xde
  github.com/pingcap/tidb/ttl/ttlworker_test.TestTTLAutoAnalyze()
      ttl/ttlworker/job_manager_integration_test.go:187 +0x2ec
  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 +0x23c
  github.com/pingcap/tidb/ttl/ttlworker_test.TestTTLAutoAnalyze()
      ttl/ttlworker/job_manager_integration_test.go:178 +0x1d7
  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 +0x1b2
  github.com/pingcap/tidb/ttl/ttlworker_test.TestTTLAutoAnalyze()
      ttl/ttlworker/job_manager_integration_test.go:176 +0x14d
  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 +0x124
  github.com/pingcap/tidb/ttl/ttlworker_test.TestTTLAutoAnalyze()
      ttl/ttlworker/job_manager_integration_test.go:174 +0xbc
  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 +0x97
  github.com/pingcap/tidb/ttl/ttlworker_test.TestTTLAutoAnalyze()
      ttl/ttlworker/job_manager_integration_test.go:172 +0x32
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44
Goroutine 62546 (finished) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:152 +0xf0
  github.com/pingcap/tidb/executor.(*AnalyzeColumnsExecV2).analyzeColumnsPushDownV2()
      executor/analyze_col_v2.go:135 +0x824
  github.com/pingcap/tidb/executor.(*AnalyzeColumnsExecV2).analyzeColumnsPushDownWithRetryV2()
      executor/analyze_col_v2.go:59 +0x51
  github.com/pingcap/tidb/executor.analyzeColumnsPushDownEntry()
      executor/analyze_col.go:69 +0xd0
  github.com/pingcap/tidb/executor.(*AnalyzeExec).analyzeWorker()
      executor/analyze.go:496 +0x284
  github.com/pingcap/tidb/executor.(*AnalyzeExec).Next.func1()
      executor/analyze.go:115 +0x58
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x84
================== 

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

3. What did you see instead (Required)

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
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant