Skip to content

DATA RACE in the MockInfoCacheAndLoadInfoSchema #39801

Closed
@hawkingrei

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

==================
WARNING: DATA RACE
Write at 0x00c01c3cde10 by goroutine 15040:
  github.com/pingcap/tidb/domain.(*Domain).MockInfoCacheAndLoadInfoSchema()
      domain/test_helper.go:29 +0x124
  github.com/pingcap/tidb/br/pkg/restore_test.TestGetExistedUserDBs()
      br/pkg/restore/db_test.go:398 +0x9a4
  github.com/pingcap/tidb/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      sessionctx/variable/variable.go:361 +0x213
  github.com/pingcap/tidb/domain.(*Domain).rebuildSysVarCache()
      domain/sysvar_cache.go:146 +0x73c
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1361 +0xb9
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3313 +0x78c
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x6a
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3582 +0x11e
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2126 +0x2fb
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1674 +0x4eb
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1303 +0x143
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3306 +0x72c
  github.com/pingcap/tidb/br/pkg/mock.NewCluster()
      br/pkg/mock/mock_cluster.go:75 +0x244
  github.com/pingcap/tidb/br/pkg/restore_test.TestGetExistedUserDBs()
      br/pkg/restore/db_test.go:371 +0x44
  testing.tRunner()
      GOROOT/src/testing/testing.go:1446 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1493 +0x47

Previous read at 0x00c01c3cde10 by goroutine 36089:
  github.com/pingcap/tidb/domain.(*Domain).InfoSchema()
      domain/domain.go:373 +0x48
  github.com/pingcap/tidb/session.(*session).GetDomainInfoSchema()
      session/session.go:3901 +0x4d
  github.com/pingcap/tidb/sessiontxn/isolation.(*baseTxnContextProvider).OnInitialize()
      sessiontxn/isolation/base.go:110 +0x57c
  github.com/pingcap/tidb/sessiontxn/isolation.(*OptimisticTxnContextProvider).OnInitialize()
      <autogenerated>:1 +0x64
  github.com/pingcap/tidb/session.(*txnManager).EnterNewTxn()
      session/txnmanager.go:147 +0xa7
  github.com/pingcap/tidb/session.(*session).PrepareTxnCtx()
      session/session.go:3627 +0x81b
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2122 +0x2d4
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1674 +0x4eb
  github.com/pingcap/tidb/ddl.(*session).execute()
      ddl/ddl.go:1789 +0x20e
  github.com/pingcap/tidb/ddl.(*ddl).getJob()
      ddl/job_table.go:98 +0x1f9
  github.com/pingcap/tidb/ddl.(*ddl).getGeneralJob()
      ddl/job_table.go:128 +0x77
  github.com/pingcap/tidb/ddl.(*ddl).getGeneralJob-fm()
      <autogenerated>:1 +0x44
  github.com/pingcap/tidb/ddl.(*ddl).loadDDLJobAndRun()
      ddl/job_table.go:210 +0x3e4
  github.com/pingcap/tidb/ddl.(*ddl).startDispatchLoop()
      ddl/job_table.go:194 +0x92d
  github.com/pingcap/tidb/ddl.(*ddl).startDispatchLoop-fm()
      <autogenerated>:1 +0x39
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run.func1()
      util/wait_group_wrapper.go:33 +0x87

Goroutine 15040 (running) created at:
  testing.(*T).Run()
      GOROOT/src/testing/testing.go:1493 +0x75d
  testing.runTests.func1()
      GOROOT/src/testing/testing.go:1846 +0x99
  testing.tRunner()
      GOROOT/src/testing/testing.go:1446 +0x216
  testing.runTests()
      GOROOT/src/testing/testing.go:1844 +0x7ec
  testing.(*M).Run()
      GOROOT/src/testing/testing.go:1726 +0xa84
  github.com/pingcap/tidb/br/pkg/restore_test.TestMain()
      br/pkg/restore/main_test.go:46 +0x5fd
  github.com/pingcap/tidb/sessionctx/variable.(*SysVar).ValidateWithRelaxedValidation()
      sessionctx/variable/variable.go:361 +0x213
  github.com/pingcap/tidb/domain.(*Domain).rebuildSysVarCache()
      domain/sysvar_cache.go:146 +0x73c
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1361 +0xb9
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3313 +0x78c
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x6a
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3582 +0x11e
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2126 +0x2fb
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1674 +0x4eb
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1303 +0x143
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3306 +0x72c
  github.com/pingcap/tidb/br/pkg/mock.NewCluster()
      br/pkg/mock/mock_cluster.go:75 +0x244
  github.com/pingcap/tidb/br/pkg/restore_test.TestMain()
      br/pkg/restore/main_test.go:38 +0x56c
  main.main()
      bazel-out/k8-fastbuild/bin/br/pkg/restore/restore_test_/testmain.go:300 +0x7c9

Goroutine 36089 (running) created at:
  github.com/pingcap/tidb/util.(*WaitGroupWrapper).Run()
      util/wait_group_wrapper.go:31 +0xf6
  github.com/pingcap/tidb/ddl.(*ddl).prepareWorkers4ConcurrencyDDL()
      ddl/ddl.go:679 +0x366
  github.com/pingcap/tidb/ddl.(*ddl).Start()
      ddl/ddl.go:715 +0x5e9
  github.com/pingcap/tidb/domain.(*Domain).Init()
      domain/domain.go:1032 +0x1492
  github.com/pingcap/tidb/session.(*domainMap).Get.func1()
      session/tidb.go:93 +0x76d
  github.com/pingcap/tidb/util.RunWithRetry()
      util/misc.go:69 +0xbe
  github.com/pingcap/tidb/session.(*domainMap).Get()
      session/tidb.go:76 +0x290
  github.com/pingcap/tidb/session.createSessionWithOpt()
      session/session.go:3459 +0x86
  github.com/pingcap/tidb/session.createSession()
      session/session.go:3455 +0x49
  github.com/pingcap/tidb/session.createSessions()
      session/session.go:3440 +0x9a
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3273 +0x415
  github.com/pingcap/tidb/br/pkg/mock.NewCluster()
      br/pkg/mock/mock_cluster.go:75 +0x244
  github.com/pingcap/tidb/br/pkg/restore_test.TestGetExistedUserDBs()
      br/pkg/restore/db_test.go:371 +0x44
  testing.tRunner()
      GOROOT/src/testing/testing.go:1446 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1493 +0x47
==================

2. What did you expect to see? (Required)

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions