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 session.(*session).useCurrentSession #55469

Closed
Tracked by #41316
hawkingrei opened this issue Aug 16, 2024 · 0 comments · Fixed by #55596
Closed
Tracked by #41316

DATA RACE session.(*session).useCurrentSession #55469

hawkingrei opened this issue Aug 16, 2024 · 0 comments · Fixed by #55596
Assignees

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 0x00c0060a39e0 by goroutine 65:
  github.com/pingcap/tidb/pkg/session.(*session).useCurrentSession.func1()
      pkg/session/session.go:1847 +0x156
  runtime.deferreturn()
      GOROOT/src/runtime/panic.go:477 +0x30
  github.com/pingcap/tidb/pkg/session.(*session).ExecRestrictedSQL()
      pkg/session/session.go:1952 +0x144
  github.com/pingcap/tidb/pkg/statistics/handle/util.ExecWithOpts()
      pkg/statistics/handle/util/util.go:240 +0x101
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.RunAnalyzeStmt()
      pkg/statistics/handle/autoanalyze/exec/exec.go:101 +0x88e
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.AutoAnalyze()
      pkg/statistics/handle/autoanalyze/exec/exec.go:55 +0x104
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).analyzeIndexes()
      pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:181 +0x2c8
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).Analyze.func1()
      pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:82 +0xbc
  github.com/pingcap/tidb/pkg/statistics/handle/util.CallWithSCtx()
      pkg/statistics/handle/util/util.go:104 +0x2c1
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).Analyze()
      pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:77 +0x116
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/refresher.(*Refresher).PickOneTableAndAnalyzeByPriority()
      pkg/statistics/handle/autoanalyze/refresher/refresher.go:106 +0x932
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze.HandleAutoAnalyze()
      pkg/statistics/handle/autoanalyze/autoanalyze.go:316 +0x2ad
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze.(*statsAnalyze).HandleAutoAnalyze.func1()
      pkg/statistics/handle/autoanalyze/autoanalyze.go:272 +0x8c
  github.com/pingcap/tidb/pkg/statistics/handle/util.CallWithSCtx()
      pkg/statistics/handle/util/util.go:104 +0x2c1
  github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze.(*statsAnalyze).HandleAutoAnalyze()
      pkg/statistics/handle/autoanalyze/autoanalyze.go:271 +0xbd
  pkg/executor/test/analyzetest/analyzetest_test.TestKillAutoAnalyzeIndex.func2()
      pkg/executor/test/analyzetest/analyze_test.go:2019 +0x7f1
  pkg/executor/test/analyzetest/analyzetest_test.TestKillAutoAnalyzeIndex()
      pkg/executor/test/analyzetest/analyze_test.go:2031 +0xb84
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:365 +0x23e
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:144 +0x944
  github.com/pingcap/tidb/pkg/domain.(*Domain).NotifyUpdateSysVarCache()
      pkg/domain/domain.go:2777 +0x27c
  github.com/pingcap/tidb/pkg/session.(*session).replaceGlobalVariablesTableValue()
      pkg/session/session.go:1280 +0x244
  github.com/pingcap/tidb/pkg/session.(*session).SetGlobalSysVar()
      pkg/session/session.go:1342 +0x2f0
  github.com/pingcap/tidb/pkg/executor.(*SetExecutor).setSysVariable()
      pkg/executor/set.go:155 +0x74d
  github.com/pingcap/tidb/pkg/executor.(*SetExecutor).Next()
      pkg/executor/set.go:105 +0xee6
  github.com/pingcap/tidb/pkg/executor/internal/exec.Next()
      pkg/executor/internal/exec/executor.go:451 +0x418
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).next()
      pkg/executor/adapter.go:1252 +0x84
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelayExecutor()
      pkg/executor/adapter.go:1001 +0x5b1
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelay()
      pkg/executor/adapter.go:834 +0x3d5
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec()
      pkg/executor/adapter.go:598 +0x1344
  github.com/pingcap/tidb/pkg/session.runStmt()
      pkg/session/session.go:2284 +0x5ce
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2145 +0x1ac4
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).ExecWithContext()
      pkg/testkit/testkit.go:423 +0xe29
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExecWithContext()
      pkg/testkit/testkit.go:159 +0xab
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExec()
      pkg/testkit/testkit.go:154 +0x128
  pkg/executor/test/analyzetest/analyzetest_test.TestKillAutoAnalyzeIndex()
      pkg/executor/test/analyzetest/analyze_test.go:1996 +0xa4b
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:365 +0x23e
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:144 +0x944
  github.com/pingcap/tidb/pkg/domain.(*Domain).NotifyUpdateSysVarCache()
      pkg/domain/domain.go:2777 +0x27c
  github.com/pingcap/tidb/pkg/session.(*session).replaceGlobalVariablesTableValue()
      pkg/session/session.go:1280 +0x244
  github.com/pingcap/tidb/pkg/session.(*session).SetGlobalSysVar()
      pkg/session/session.go:1342 +0x2f0
  github.com/pingcap/tidb/pkg/executor.(*SetExecutor).setSysVariable()
      pkg/executor/set.go:155 +0x74d
  github.com/pingcap/tidb/pkg/executor.(*SetExecutor).Next()
      pkg/executor/set.go:105 +0xee6
  github.com/pingcap/tidb/pkg/executor/internal/exec.Next()
      pkg/executor/internal/exec/executor.go:451 +0x418
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).next()
      pkg/executor/adapter.go:1252 +0x84
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelayExecutor()
      pkg/executor/adapter.go:1001 +0x5b1
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelay()
      pkg/executor/adapter.go:834 +0x3d5
  github.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec()
      pkg/executor/adapter.go:598 +0x1344
  github.com/pingcap/tidb/pkg/session.runStmt()
      pkg/session/session.go:2284 +0x5ce
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2145 +0x1ac4
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).ExecWithContext()
      pkg/testkit/testkit.go:423 +0xe29
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExecWithContext()
      pkg/testkit/testkit.go:159 +0xab
  github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExec()
      pkg/testkit/testkit.go:154 +0x128
  pkg/executor/test/analyzetest/analyzetest_test.TestKillAutoAnalyzeIndex()
      pkg/executor/test/analyzetest/analyze_test.go:1995 +0xa2b
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:144 +0x944
  fmt.Sscanf()
      GOROOT/src/fmt/scan.go:114 +0x18e
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseByteSize()
      pkg/sessionctx/variable/varsutil.go:406 +0x1d
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func252()
      pkg/sessionctx/variable/sysvar.go:1371 +0x34
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:145 +0x9b4
  fmt.Sscanf()
      GOROOT/src/fmt/scan.go:114 +0x18e
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseByteSize()
      pkg/sessionctx/variable/varsutil.go:406 +0x1d
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func250()
      pkg/sessionctx/variable/sysvar.go:1356 +0x34
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:145 +0x9b4
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseSchemaCacheSize()
      pkg/sessionctx/variable/varsutil.go:628 +0x17c
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func604()
      pkg/sessionctx/variable/sysvar.go:3195 +0x64
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:145 +0x9b4
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func603()
      pkg/sessionctx/variable/sysvar.go:3187 +0x58
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:365 +0x23e
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:144 +0x944
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadSysVarCacheLoop()
      pkg/domain/domain.go:1857 +0x93
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3519 +0x884
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func252()
      pkg/sessionctx/variable/sysvar.go:1371 +0x34
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:145 +0x9b4
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseMemoryLimit()
      pkg/sessionctx/variable/varsutil.go:375 +0x18b
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func209()
      pkg/sessionctx/variable/sysvar.go:1106 +0x50
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:145 +0x9b4
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func208()
      pkg/sessionctx/variable/sysvar.go:1099 +0x58
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:365 +0x23e
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:144 +0x944
  fmt.Sscanf()
      GOROOT/src/fmt/scan.go:114 +0x18e
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseByteSize()
      pkg/sessionctx/variable/varsutil.go:406 +0x1d
  github.com/pingcap/tidb/pkg/sessionctx/variable.glob..func250()
      pkg/sessionctx/variable/sysvar.go:1356 +0x34
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:145 +0x9b4
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCacheIfNeeded()
      pkg/domain/sysvar_cache.go:50 +0x1b5
  github.com/pingcap/tidb/pkg/domain.(*Domain).GetSessionCache()
      pkg/domain/sysvar_cache.go:61 +0x50
  github.com/pingcap/tidb/pkg/session.(*session).loadCommonGlobalVariablesIfNeeded()
      pkg/session/session.go:3896 +0x2bb
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2007 +0x184
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1518 +0x3b9
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadPrivilegeLoop()
      pkg/domain/domain.go:1800 +0x108
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3512 +0x827
  github.com/pingcap/tidb/pkg/session.BootstrapSession()
      pkg/session/session.go:3389 +0xad
  github.com/pingcap/tidb/pkg/testkit.bootstrap()
      pkg/testkit/mockstore.go:254 +0x94
  github.com/pingcap/tidb/pkg/testkit.CreateMockStoreAndDomain()
      pkg/testkit/mockstore.go:225 +0xd2
  pkg/executor/test/analyzetest/analyzetest_test.TestKillAutoAnalyzeIndex()
      pkg/executor/test/analyzetest/analyze_test.go:1970 +0x4c
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44
Previous read at 0x00c0060a39e0 by goroutine 12743:
  github.com/pingcap/tidb/pkg/executor.(*AnalyzeExec).handleResultsErrorWithConcurrency.func1()
      pkg/executor/analyze.go:440 +0x84
  github.com/pingcap/tidb/pkg/util.(*WaitGroupPool).Run.func1()
      pkg/util/wait_group_wrapper.go:213 +0x86
  github.com/tiancaiamao/gp.workerLoop()
      external/com_github_tiancaiamao_gp/gp.go:72 +0x199
  github.com/tiancaiamao/gp.worker()
      external/com_github_tiancaiamao_gp/gp.go:51 +0x104
  github.com/tiancaiamao/gp.(*Pool).Go.func1()
      external/com_github_tiancaiamao_gp/gp.go:32 +0x44
Goroutine 65 (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/executor/test/analyzetest/analyzetest_test.TestMain()
      pkg/executor/test/analyzetest/main_test.go:34 +0x424
  main.main()
      bazel-out/k8-fastbuild/bin/pkg/executor/test/analyzetest/analyzetest_test_/testmain.go:225 +0x6dc
      pkg/executor/analyze.go:420 +0x684
  github.com/pingcap/tidb/pkg/executor.(*AnalyzeExec).Next.func2()
      pkg/executor/analyze.go:121 +0x9c
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      external/org_golang_x_sync/errgroup/errgroup.go:78 +0x97
================== 

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

Successfully merging a pull request may close this issue.

3 participants