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 ddl.addBatchDDLJobs2Table #42987

Closed
Tracked by #41316
hawkingrei opened this issue Apr 12, 2023 · 0 comments · Fixed by #43040
Closed
Tracked by #41316

DATA RACE in the ddl.addBatchDDLJobs2Table #42987

hawkingrei opened this issue Apr 12, 2023 · 0 comments · Fixed by #43040
Assignees
Labels
component/test type/enhancement The issue or PR belongs to an enhancement.

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 0x00c0181eed78 by goroutine 420807:
  github.com/pingcap/tidb/ddl.(*ddl).addBatchDDLJobs2Table()
      ddl/ddl_worker.go:373 +0x5a8
  github.com/pingcap/tidb/ddl.(*ddl).addBatchDDLJobs()
      ddl/ddl_worker.go:221 +0x104
  github.com/pingcap/tidb/ddl.(*ddl).limitDDLJobs()
      ddl/ddl_worker.go:207 +0xb8
  github.com/pingcap/tidb/ddl.(*ddl).limitDDLJobs-fm()
      <autogenerated>:1 +0x39
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:154 +0x73
Previous read at 0x00c0181eed78 by goroutine 394470:
  reflect.Value.Int()
      GOROOT/src/reflect/value.go:1459 +0xf7
  encoding/json.intEncoder()
      GOROOT/src/encoding/json/encode.go:550 +0x45
  encoding/json.structEncoder.encode()
      GOROOT/src/encoding/json/encode.go:759 +0x2ba
  encoding/json.structEncoder.encode-fm()
      <autogenerated>:1 +0xdb
  encoding/json.ptrEncoder.encode()
      GOROOT/src/encoding/json/encode.go:943 +0x382
  encoding/json.ptrEncoder.encode-fm()
      <autogenerated>:1 +0x90
  encoding/json.(*encodeState).reflectValue()
      GOROOT/src/encoding/json/encode.go:358 +0x88
  encoding/json.(*encodeState).marshal()
      GOROOT/src/encoding/json/encode.go:330 +0x224
  encoding/json.Marshal()
      GOROOT/src/encoding/json/encode.go:161 +0xf9
  github.com/pingcap/tidb/parser/model.(*Job).Encode()
      parser/model/ddl.go:557 +0x2c8
  github.com/pingcap/tidb/parser/model.(*Job).Clone()
      parser/model/ddl.go:471 +0x4c
  github.com/pingcap/tidb/ddl.(*ddl).DoDDLJob()
      ddl/ddl.go:1051 +0x407
  github.com/pingcap/tidb/ddl.(*ddl).MultiSchemaChange()
      ddl/multi_schema_change.go:59 +0x9cd
  github.com/pingcap/tidb/ddl.(*ddl).AlterTable()
      ddl/ddl_api.go:3557 +0x2dc7
  github.com/pingcap/tidb/executor.(*DDLExec).executeAlterTable()
      executor/ddl.go:384 +0x294
  github.com/pingcap/tidb/executor.(*DDLExec).Next()
      executor/ddl.go:148 +0x37c
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:326 +0x326
  github.com/pingcap/tidb/executor.(*ExecStmt).next()
      executor/adapter.go:1194 +0x89
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor()
      executor/adapter.go:939 +0x4f9
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay()
      executor/adapter.go:764 +0x34a
  github.com/pingcap/tidb/executor.(*ExecStmt).Exec()
      executor/adapter.go:564 +0xf87
  github.com/pingcap/tidb/session.runStmt()
      session/session.go:2344 +0x62f
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2201 +0x1116
  github.com/pingcap/tidb/testkit.(*TestKit).ExecWithContext()
      testkit/testkit.go:325 +0x8ae
  github.com/pingcap/tidb/testkit.(*TestKit).MustExecWithContext()
      testkit/testkit.go:133 +0xb7
  github.com/pingcap/tidb/testkit.(*TestKit).MustExec()
      testkit/testkit.go:128 +0x138
  github.com/pingcap/tidb/ddl_test.TestMultiSchemaChangeAddColumnsParallel.func1()
      ddl/multi_schema_change_test.go:166 +0x47
  github.com/pingcap/tidb/ddl_test.putTheSameDDLJobTwice()
      ddl/multi_schema_change_test.go:1311 +0x79
  github.com/pingcap/failpoint.parseTerm()
      external/com_github_pingcap_failpoint/terms.go:149 +0x389
  github.com/pingcap/failpoint.parse()
      external/com_github_pingcap_failpoint/terms.go:126 +0xad
  github.com/pingcap/failpoint.newTerms()
      external/com_github_pingcap_failpoint/terms.go:98 +0x50
  github.com/pingcap/failpoint.(*Failpoint).Enable()
      external/com_github_pingcap_failpoint/failpoint.go:54 +0x44
  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 +0x50
  github.com/pingcap/tidb/ddl_test.putTheSameDDLJobTwice()
      ddl/multi_schema_change_test.go:1309 +0x2c
  github.com/pingcap/tidb/ddl_test.TestMultiSchemaChangeAddColumnsParallel()
      ddl/multi_schema_change_test.go:165 +0xd7
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1580 +0xa8
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3325 +0x6d3
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x5c
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3672 +0x104
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2103 +0x145
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1638 +0x31b
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1524 +0x130
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3318 +0x684
  github.com/pingcap/tidb/testkit.bootstrap()
      testkit/mockstore.go:85 +0xac
  github.com/pingcap/tidb/testkit.CreateMockStoreAndDomain()
      testkit/mockstore.go:70 +0xe9
  github.com/pingcap/tidb/testkit.CreateMockStore()
      testkit/mockstore.go:62 +0x3b1
  github.com/pingcap/tidb/ddl_test.TestMultiSchemaChangeAddColumnsParallel()
      ddl/multi_schema_change_test.go:160 +0x3e
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
Goroutine 420807 (running) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:152 +0xe4
  github.com/pingcap/tidb/ddl.(*ddl).Start()
      ddl/ddl.go:769 +0x354
  github.com/pingcap/tidb/domain.(*Domain).Init()
      domain/domain.go:1167 +0x14bc
  github.com/pingcap/tidb/session.(*domainMap).Get.func1()
      session/tidb.go:93 +0x676
  github.com/pingcap/tidb/util.RunWithRetry()
      util/misc.go:69 +0x93
  github.com/pingcap/tidb/session.(*domainMap).Get()
      session/tidb.go:79 +0x2d2
  github.com/pingcap/tidb/session.createSessionWithOpt()
      session/session.go:3529 +0x75
  github.com/pingcap/tidb/session.createSession()
      session/session.go:3525 +0x84
  github.com/pingcap/tidb/session.createSessions()
      session/session.go:3510 +0x6e
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3285 +0x3db
  github.com/pingcap/tidb/testkit.bootstrap()
      testkit/mockstore.go:85 +0xac
  github.com/pingcap/tidb/testkit.CreateMockStoreAndDomain()
      testkit/mockstore.go:70 +0xe9
  github.com/pingcap/tidb/testkit.CreateMockStore()
      testkit/mockstore.go:62 +0x3b1
  github.com/pingcap/tidb/ddl_test.TestMultiSchemaChangeAddColumnsParallel()
      ddl/multi_schema_change_test.go:160 +0x3e
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
Goroutine 394470 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1629 +0x805
  testing.runTests.func1()
      GOROOT/src/testing/testing.go:2036 +0x8d
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.runTests()
      GOROOT/src/testing/testing.go:2034 +0x87c
  testing.(*M).Run()
      GOROOT/src/testing/testing.go:1906 +0xb44
  go.uber.org/goleak.VerifyTestMain()
      external/org_uber_go_goleak/testmain.go:53 +0x70
  github.com/pingcap/tidb/ddl_test.TestMain()
      ddl/main_test.go:74 +0x9bd
  main.main()
      bazel-out/k8-fastbuild/bin/ddl/ddl_test_/testmain.go:1368 +0x5e8
==================
================== 

https://prow.hawkingrei.com/view/gs/prowpingcap/logs/tidb_race/1645947116700307456

4. What is your TiDB version? (Required)

@hawkingrei hawkingrei added the type/bug The issue is confirmed as a bug. label Apr 12, 2023
@tangenta tangenta added component/test type/enhancement The issue or PR belongs to an enhancement. and removed type/bug The issue is confirmed as a bug. labels Apr 13, 2023
@tangenta tangenta self-assigned this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/test type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants