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 planner/core.(*PlanBuilder).rewriteExprNode #44919

Closed
hawkingrei opened this issue Jun 25, 2023 · 2 comments · Fixed by #48888
Closed

DATA RACE planner/core.(*PlanBuilder).rewriteExprNode #44919

hawkingrei opened this issue Jun 25, 2023 · 2 comments · Fixed by #48888
Labels
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
Read at 0x00c0195ec858 by goroutine 103186:
  github.com/pingcap/tidb/parser/ast.(*BinaryOperationExpr).Accept()
      parser/ast/expressions.go:217 +0x178
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteExprNode()
      planner/core/expression_rewriter.go:201 +0x1ad
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteWithPreprocess()
      planner/core/expression_rewriter.go:146 +0x2ee
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewrite()
      planner/core/expression_rewriter.go:114 +0xe4
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildDataSource()
      planner/core/logical_plan_builder.go:5053 +0x4db3
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildResultSetNode()
      planner/core/logical_plan_builder.go:504 +0x44d
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildJoin()
      planner/core/logical_plan_builder.go:947 +0x1374
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildResultSetNode()
      planner/core/logical_plan_builder.go:491 +0x11e
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildTableRefs()
      planner/core/logical_plan_builder.go:483 +0x144
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildSelect()
      planner/core/logical_plan_builder.go:4239 +0xe2d
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).Build()
      planner/core/planbuilder.go:826 +0xdca
  github.com/pingcap/tidb/planner.buildLogicalPlan()
      planner/optimize.go:558 +0x2ca
  github.com/pingcap/tidb/planner.optimize()
      planner/optimize.go:479 +0x639
  github.com/pingcap/tidb/planner.Optimize()
      planner/optimize.go:337 +0x159d
  github.com/pingcap/tidb/executor.(*Compiler).Compile()
      executor/compiler.go:98 +0x864
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2222 +0xd28
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1666 +0x365
  github.com/pingcap/tidb/executor.getCheckSum()
      executor/executor.go:2415 +0x131
  github.com/pingcap/tidb/executor.(*checkIndexWorker).HandleTask()
      executor/executor.go:2567 +0x23d3
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.(*WorkerPool[...]).handleTaskWithRecover()
      resourcemanager/pool/workerpool/workerpool.go:104 +0x12e
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.(*WorkerPool[...]).runAWorker.func1()
      resourcemanager/pool/workerpool/workerpool.go:116 +0xb1
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x87
Previous write at 0x00c0195ec858 by goroutine 103187:
  github.com/pingcap/tidb/parser/ast.(*BinaryOperationExpr).Accept()
      parser/ast/expressions.go:221 +0x1e4
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteExprNode()
      planner/core/expression_rewriter.go:201 +0x1ad
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteWithPreprocess()
      planner/core/expression_rewriter.go:146 +0x2ee
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewrite()
      planner/core/expression_rewriter.go:114 +0xe4
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildDataSource()
      planner/core/logical_plan_builder.go:5053 +0x4db3
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildResultSetNode()
      planner/core/logical_plan_builder.go:504 +0x44d
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildJoin()
      planner/core/logical_plan_builder.go:947 +0x1374
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildResultSetNode()
      planner/core/logical_plan_builder.go:491 +0x11e
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildTableRefs()
      planner/core/logical_plan_builder.go:483 +0x144
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildSelect()
      planner/core/logical_plan_builder.go:4239 +0xe2d
  github.com/pingcap/tidb/planner/core.(*PlanBuilder).Build()
      planner/core/planbuilder.go:826 +0xdca
  github.com/pingcap/tidb/planner.buildLogicalPlan()
      planner/optimize.go:558 +0x2ca
  github.com/pingcap/tidb/planner.optimize()
      planner/optimize.go:479 +0x639
  github.com/pingcap/tidb/planner.Optimize()
      planner/optimize.go:337 +0x159d
  github.com/pingcap/tidb/executor.(*Compiler).Compile()
      executor/compiler.go:98 +0x864
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2222 +0xd28
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1666 +0x365
  github.com/pingcap/tidb/executor.getCheckSum()
      executor/executor.go:2415 +0x131
  github.com/pingcap/tidb/executor.(*checkIndexWorker).HandleTask()
      executor/executor.go:2567 +0x23d3
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.(*WorkerPool[...]).handleTaskWithRecover()
      resourcemanager/pool/workerpool/workerpool.go:104 +0x12e
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.(*WorkerPool[...]).runAWorker.func1()
      resourcemanager/pool/workerpool/workerpool.go:116 +0xb1
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x87
Goroutine 103186 (running) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:152 +0xf6
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.(*WorkerPool[...]).runAWorker()
      resourcemanager/pool/workerpool/workerpool.go:112 +0x177
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.NewWorkerPool[...]()
      resourcemanager/pool/workerpool/workerpool.go:91 +0x48d
  github.com/pingcap/tidb/executor.(*FastCheckTableExec).Next()
      executor/executor.go:2798 +0x2e6
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:342 +0x3a6
  github.com/pingcap/tidb/executor.(*ExecStmt).next()
      executor/adapter.go:1218 +0x9d
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor()
      executor/adapter.go:963 +0x57c
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay()
      executor/adapter.go:789 +0x42e
  github.com/pingcap/tidb/executor.(*ExecStmt).Exec()
      executor/adapter.go:570 +0x12d7
  github.com/pingcap/tidb/session.runStmt()
      session/session.go:2422 +0x701
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2272 +0x1767
  github.com/pingcap/tidb/testkit.(*TestKit).ExecWithContext()
      testkit/testkit.go:324 +0x791
  github.com/pingcap/tidb/testkit.(*TestKit).MustExecWithContext()
      testkit/testkit.go:132 +0xb7
  github.com/pingcap/tidb/testkit.(*TestKit).MustExec()
      testkit/testkit.go:127 +0x138
  github.com/pingcap/tidb/ddl/ingest_test.TestAddIndexIngestGeneratedColumns.func1()
      ddl/ingest/integration_test.go:64 +0x75
  github.com/pingcap/tidb/ddl/ingest_test.TestAddIndexIngestGeneratedColumns()
      ddl/ingest/integration_test.go:81 +0x2c9
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3379 +0x7cc
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x71
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3743 +0x11e
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2152 +0x16b
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1666 +0x365
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1832 +0x143
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3372 +0x76c
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3293 +0x4e
  github.com/pingcap/tidb/testkit.bootstrap()
      testkit/mockstore.go:227 +0x84
  github.com/pingcap/tidb/testkit.CreateMockStoreAndDomain()
      testkit/mockstore.go:200 +0xd0
  github.com/pingcap/tidb/testkit.CreateMockStore()
      testkit/mockstore.go:68 +0x3b2
  github.com/pingcap/tidb/ddl/ingest_test.TestAddIndexIngestGeneratedColumns()
      ddl/ingest/integration_test.go:58 +0x58
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
Goroutine 103187 (running) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:152 +0xf6
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.(*WorkerPool[...]).runAWorker()
      resourcemanager/pool/workerpool/workerpool.go:112 +0x177
  github.com/pingcap/tidb/resourcemanager/pool/workerpool.NewWorkerPool[...]()
      resourcemanager/pool/workerpool/workerpool.go:91 +0x48d
  github.com/pingcap/tidb/executor.(*FastCheckTableExec).Next()
      executor/executor.go:2798 +0x2e6
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:342 +0x3a6
  github.com/pingcap/tidb/executor.(*ExecStmt).next()
      executor/adapter.go:1218 +0x9d
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor()
      executor/adapter.go:963 +0x57c
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay()
      executor/adapter.go:789 +0x42e
  github.com/pingcap/tidb/executor.(*ExecStmt).Exec()
      executor/adapter.go:570 +0x12d7
  github.com/pingcap/tidb/session.runStmt()
      session/session.go:2422 +0x701
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2272 +0x1767
  github.com/pingcap/tidb/testkit.(*TestKit).ExecWithContext()
      testkit/testkit.go:324 +0x791
  github.com/pingcap/tidb/testkit.(*TestKit).MustExecWithContext()
      testkit/testkit.go:132 +0xb7
  github.com/pingcap/tidb/testkit.(*TestKit).MustExec()
      testkit/testkit.go:127 +0x138
  github.com/pingcap/tidb/ddl/ingest_test.TestAddIndexIngestGeneratedColumns.func1()
      ddl/ingest/integration_test.go:64 +0x75
  github.com/pingcap/tidb/ddl/ingest_test.TestAddIndexIngestGeneratedColumns()
      ddl/ingest/integration_test.go:81 +0x2c9
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3379 +0x7cc
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x71
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3743 +0x11e
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2152 +0x16b
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1666 +0x365
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1832 +0x143
  github.com/pingcap/tidb/session.bootstrapSessionImpl()
      session/session.go:3372 +0x76c
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3293 +0x4e
  github.com/pingcap/tidb/testkit.bootstrap()
      testkit/mockstore.go:227 +0x84
  github.com/pingcap/tidb/testkit.CreateMockStoreAndDomain()
      testkit/mockstore.go:200 +0xd0
  github.com/pingcap/tidb/testkit.CreateMockStore()
      testkit/mockstore.go:68 +0x3b2
  github.com/pingcap/tidb/ddl/ingest_test.TestAddIndexIngestGeneratedColumns()
      ddl/ingest/integration_test.go:58 +0x58
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
================== 

4. What is your TiDB version? (Required)

@hawkingrei hawkingrei added the type/bug The issue is confirmed as a bug. label Jun 25, 2023
@wuhuizuo
Copy link
Contributor

wuhuizuo commented Nov 2, 2023

local run failed in a debug container with 1 core CPU + 4GB memory(commit reversion: d4b81de):

image

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