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 infoschemaV2's allocator #57877

Closed
hawkingrei opened this issue Dec 2, 2024 · 1 comment · Fixed by #57976
Closed

DATA RACE in the infoschemaV2's allocator #57877

hawkingrei opened this issue Dec 2, 2024 · 1 comment · Fixed by #57976
Assignees
Labels
affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/minor sig/sql-infra SIG: SQL Infra 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
Read at 0x00000d444d78 by goroutine 12774:
  github.com/pingcap/tidb/pkg/meta/autoid.NewAllocator()
      pkg/meta/autoid/autoid.go:630 +0x1a4
  github.com/pingcap/tidb/pkg/meta/autoid.NewAllocatorsFromTblInfo()
      pkg/meta/autoid/autoid.go:681 +0x466
  github.com/pingcap/tidb/pkg/infoschema.(*infoschemaV2).loadTableInfo.func1()
      pkg/infoschema/infoschema_v2.go:1136 +0x1c6
  golang.org/x/sync/singleflight.(*Group).doCall.func2()
      external/org_golang_x_sync/singleflight/singleflight.go:198 +0xb4
  golang.org/x/sync/singleflight.(*Group).doCall()
      external/org_golang_x_sync/singleflight/singleflight.go:200 +0x135
  golang.org/x/sync/singleflight.(*Group).Do()
      external/org_golang_x_sync/singleflight/singleflight.go:113 +0x204
  github.com/pingcap/tidb/pkg/infoschema.(*infoschemaV2).loadTableInfo()
      pkg/infoschema/infoschema_v2.go:1105 +0x3a8
  github.com/pingcap/tidb/pkg/infoschema.(*infoschemaV2).TableByName()
      pkg/infoschema/infoschema_v2.go:793 +0x817
  github.com/pingcap/tidb/pkg/infoschema.(*SessionExtendedInfoSchema).TableByName()
      pkg/infoschema/infoschema.go:818 +0x302
  github.com/pingcap/tidb/pkg/planner/core.(*preprocessor).tableByName()
      pkg/planner/core/preprocess.go:507 +0x44b
  github.com/pingcap/tidb/pkg/planner/core.(*preprocessor).handleTableName()
      pkg/planner/core/preprocess.go:1616 +0x2de
  github.com/pingcap/tidb/pkg/planner/core.(*preprocessor).Leave()
      pkg/planner/core/preprocess.go:614 +0x1432
  github.com/pingcap/tidb/pkg/parser/ast.(*TableName).Accept()
      pkg/parser/ast/dml.go:454 +0x1dc
  github.com/pingcap/tidb/pkg/parser/ast.(*TableSource).Accept()
      pkg/parser/ast/dml.go:606 +0x90
  github.com/pingcap/tidb/pkg/parser/ast.(*Join).Accept()
      pkg/parser/ast/dml.go:244 +0xaf
  github.com/pingcap/tidb/pkg/parser/ast.(*TableRefsClause).Accept()
      pkg/parser/ast/dml.go:829 +0x8b
  github.com/pingcap/tidb/pkg/parser/ast.(*SelectStmt).Accept()
      pkg/parser/ast/dml.go:1501 +0x505
  github.com/pingcap/tidb/pkg/parser/ast.(*TableSource).Accept()
      pkg/parser/ast/dml.go:606 +0x90
  github.com/pingcap/tidb/pkg/parser/ast.(*Join).Accept()
      pkg/parser/ast/dml.go:244 +0xaf
  github.com/pingcap/tidb/pkg/parser/ast.(*TableRefsClause).Accept()
      pkg/parser/ast/dml.go:829 +0x8b
  github.com/pingcap/tidb/pkg/parser/ast.(*SelectStmt).Accept()
      pkg/parser/ast/dml.go:1501 +0x505
  github.com/pingcap/tidb/pkg/planner/core.Preprocess()
      pkg/planner/core/preprocess.go:144 +0x514
  github.com/pingcap/tidb/pkg/executor.(*Compiler).Compile()
      pkg/executor/compiler.go:69 +0x664
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2099 +0xfd3
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1524 +0x3af
  github.com/pingcap/tidb/pkg/ttl/session.(*session).ExecuteSQL()
      pkg/ttl/session/session.go:96 +0x157
  github.com/pingcap/tidb/pkg/ttl/ttlworker.GetDelayMetricRecords()
      pkg/ttl/ttlworker/job_manager.go:1085 +0xa4
  github.com/pingcap/tidb/pkg/ttl/ttlworker.(*JobManager).reportMetrics()
      pkg/ttl/ttlworker/job_manager.go:512 +0x32e
  github.com/pingcap/tidb/pkg/ttl/ttlworker.(*JobManager).jobLoop()
      pkg/ttl/ttlworker/job_manager.go:200 +0xbdd
  github.com/pingcap/tidb/pkg/ttl/ttlworker.(*JobManager).jobLoop-fm()
      <autogenerated>:1 +0x33
  github.com/pingcap/tidb/pkg/ttl/ttlworker.(*baseWorker).loop()
      pkg/ttl/ttlworker/worker.go:134 +0xb2
  github.com/pingcap/tidb/pkg/ttl/ttlworker.(*baseWorker).loop-fm()
      <autogenerated>:1 +0x33
  github.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).Run.func1()
      pkg/util/wait_group_wrapper.go:157 +0x86
Previous write at 0x00000d444d78 by goroutine 65:
  github.com/pingcap/tidb/pkg/meta/autoid.SetStep()
      pkg/meta/autoid/autoid.go:284 +0xa9
  pkg/executor/test/ddl/ddl_test.TestRenameWithSmallAutoIDStep()
      pkg/executor/test/ddl/ddl_test.go:948 +0x9d
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func217()
      pkg/sessionctx/variable/sysvar.go:1148 +0x52
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:377 +0x242
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:142 +0xa24
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseSchemaCacheSize()
      pkg/sessionctx/variable/varsutil.go:638 +0x17c
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func620()
      pkg/sessionctx/variable/sysvar.go:3318 +0x67
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func619()
      pkg/sessionctx/variable/sysvar.go:3310 +0x52
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:377 +0x242
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:142 +0xa24
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadSysVarCacheLoop()
      pkg/domain/domain.go:1908 +0x93
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3537 +0x864
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func218()
      pkg/sessionctx/variable/sysvar.go:1155 +0x56
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func217()
      pkg/sessionctx/variable/sysvar.go:1148 +0x52
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:377 +0x242
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:142 +0xa24
  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.init.func261()
      pkg/sessionctx/variable/sysvar.go:1419 +0x44
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCacheIfNeeded()
      pkg/domain/sysvar_cache.go:50 +0x1bb
  github.com/pingcap/tidb/pkg/domain.(*Domain).GetSessionCache()
      pkg/domain/sysvar_cache.go:61 +0x4a
  github.com/pingcap/tidb/pkg/session.(*session).loadCommonGlobalVariablesIfNeeded()
      pkg/session/session.go:3945 +0x2ae
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2013 +0x17a
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1524 +0x3af
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadPrivilegeLoop()
      pkg/domain/domain.go:1848 +0x102
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3530 +0x807
  github.com/pingcap/tidb/pkg/session.BootstrapSession()
      pkg/session/session.go:3406 +0xac
  github.com/pingcap/tidb/pkg/testkit.bootstrap()
      pkg/testkit/mockstore.go:251 +0x85
  github.com/pingcap/tidb/pkg/testkit.CreateMockStoreAndDomain()
      pkg/testkit/mockstore.go:222 +0xce
  github.com/pingcap/tidb/pkg/testkit.CreateMockStore()
      pkg/testkit/mockstore.go:77 +0x21d
  pkg/executor/test/ddl/ddl_test.TestRenameWithSmallAutoIDStep()
      pkg/executor/test/ddl/ddl_test.go:945 +0x7a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1690 +0x226
  testing.(*T).Run.gowrap1()
      GOROOT/src/testing/testing.go:1743 +0x44
Goroutine 12774 (running) created at:
  github.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).Run()
      pkg/util/wait_group_wrapper.go:155 +0xe4
  github.com/pingcap/tidb/pkg/ttl/ttlworker.(*baseWorker).Start()
      pkg/ttl/ttlworker/worker.go:71 +0x124
  github.com/pingcap/tidb/pkg/domain.(*Domain).StartTTLJobManager()
      pkg/domain/domain.go:3203 +0x1d9
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3647 +0x1ca5
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseMemoryLimit()
      pkg/sessionctx/variable/varsutil.go:375 +0x18b
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func218()
      pkg/sessionctx/variable/sysvar.go:1155 +0x56
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func217()
      pkg/sessionctx/variable/sysvar.go:1148 +0x52
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:377 +0x242
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:142 +0xa24
  github.com/pingcap/tidb/pkg/sessionctx/variable.parseSchemaCacheSize()
      pkg/sessionctx/variable/varsutil.go:638 +0x17c
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func620()
      pkg/sessionctx/variable/sysvar.go:3318 +0x67
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func619()
      pkg/sessionctx/variable/sysvar.go:3310 +0x52
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:377 +0x242
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:142 +0xa24
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadSysVarCacheLoop()
      pkg/domain/domain.go:1908 +0x93
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3537 +0x864
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func218()
      pkg/sessionctx/variable/sysvar.go:1155 +0x56
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/sessionctx/variable.init.func217()
      pkg/sessionctx/variable/sysvar.go:1148 +0x52
  github.com/pingcap/tidb/pkg/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      pkg/sessionctx/variable/variable.go:377 +0x242
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:142 +0xa24
  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.init.func261()
      pkg/sessionctx/variable/sysvar.go:1419 +0x44
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:143 +0xa94
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCacheIfNeeded()
      pkg/domain/sysvar_cache.go:50 +0x1bb
  github.com/pingcap/tidb/pkg/domain.(*Domain).GetSessionCache()
      pkg/domain/sysvar_cache.go:61 +0x4a
  github.com/pingcap/tidb/pkg/session.(*session).loadCommonGlobalVariablesIfNeeded()
      pkg/session/session.go:3945 +0x2ae
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2013 +0x17a
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1524 +0x3af
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadPrivilegeLoop()
      pkg/domain/domain.go:1848 +0x102
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3530 +0x807
  github.com/pingcap/tidb/pkg/session.BootstrapSession()
      pkg/session/session.go:3406 +0xac
  github.com/pingcap/tidb/pkg/testkit.bootstrap()
      pkg/testkit/mockstore.go:251 +0x85
  github.com/pingcap/tidb/pkg/testkit.CreateMockStoreAndDomain()
      pkg/testkit/mockstore.go:222 +0xce
  github.com/pingcap/tidb/pkg/testkit.CreateMockStore()
      pkg/testkit/mockstore.go:77 +0x21d
  pkg/executor/test/ddl/ddl_test.TestRenameWithSmallAutoIDStep()
      pkg/executor/test/ddl/ddl_test.go:945 +0x7a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1690 +0x226
  testing.(*T).Run.gowrap1()
      GOROOT/src/testing/testing.go:1743 +0x44
Goroutine 65 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1743 +0x825
  testing.runTests.func1()
      GOROOT/src/testing/testing.go:2168 +0x85
  testing.tRunner()
      GOROOT/src/testing/testing.go:1690 +0x226
  testing.runTests()
      GOROOT/src/testing/testing.go:2166 +0x8be
  testing.(*M).Run()
      GOROOT/src/testing/testing.go:2034 +0xf17
  go.uber.org/goleak.VerifyTestMain()
      external/org_uber_go_goleak/testmain.go:53 +0x64
  pkg/executor/test/ddl/ddl_test.TestMain()
      pkg/executor/test/ddl/main_test.go:44 +0x644
  main.main()
      bazel-out/k8-fastbuild/bin/pkg/executor/test/ddl/ddl_test_/testmain.go:169 +0x593
================== 

https://tiprow.hawkingrei.com/view/gs/pingcapprow/logs/tidb_data_race/1863452190752903168#1:build-log.txt%3A56971

4. What is your TiDB version? (Required)

@tiancaiamao
Copy link
Contributor

Only affects test

@ti-chi-bot ti-chi-bot bot closed this as completed in b4c719a Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/minor sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants