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
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/test 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)

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
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/test 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.

3 participants