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 util/topsql/stmtstats.StatementStatsMap #50876

Open
Tracked by #41316
hawkingrei opened this issue Feb 1, 2024 · 0 comments
Open
Tracked by #41316

DATA RACE in the util/topsql/stmtstats.StatementStatsMap #50876

hawkingrei opened this issue Feb 1, 2024 · 0 comments
Labels
component/test severity/moderate sig/diagnosis SIG: Diagnosis 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 0x00c00ddaf980 by goroutine 41122:
  runtime.mapassign()
      GOROOT/src/runtime/map.go:579 +0x0
  github.com/pingcap/tidb/pkg/util/topsql/stmtstats.StatementStatsMap.Merge()
      pkg/util/topsql/stmtstats/stmtstats.go:162 +0x390
  pkg/server/tests/tests_test.setupForTestTopSQLStatementStats.func1()
      pkg/server/tests/tidb_test.go:2032 +0xb2
  pkg/server/tests/tests_test.(*mockCollector).CollectStmtStatsMap()
      pkg/server/tests/tidb_test.go:1728 +0x42
  github.com/pingcap/tidb/pkg/util/topsql/stmtstats.(*aggregator).aggregate.func2()
      pkg/util/topsql/stmtstats/aggregator.go:91 +0x54
  sync.(*Map).Range()
      GOROOT/src/sync/map.go:476 +0x1db
  github.com/pingcap/tidb/pkg/util/topsql/stmtstats.(*aggregator).aggregate()
      pkg/util/topsql/stmtstats/aggregator.go:90 +0x124
  github.com/pingcap/tidb/pkg/util/topsql/stmtstats.(*aggregator).run()
      pkg/util/topsql/stmtstats/aggregator.go:71 +0xf1
  github.com/pingcap/tidb/pkg/util/topsql/stmtstats.(*aggregator).start.func1()
      pkg/util/topsql/stmtstats/aggregator.go:56 +0x33
Previous read at 0x00c00ddaf980 by goroutine 41121:
  runtime.mapiternext()
      GOROOT/src/runtime/map.go:867 +0x0
  pkg/server/tests/tests_test.TestTopSQLStatementStats3()
      pkg/server/tests/tidb_test.go:2260 +0x6e4
  github.com/pingcap/failpoint.(*Failpoint).Enable()
      external/com_github_pingcap_failpoint/failpoint.go:54 +0x3e
  github.com/pingcap/failpoint.(*Failpoints).Enable()
      external/com_github_pingcap_failpoint/failpoints.go:105 +0x296
  github.com/pingcap/failpoint.Enable()
      external/com_github_pingcap_failpoint/failpoints.go:222 +0x84
  pkg/server/tests/tests_test.TestTopSQLStatementStats3()
      pkg/server/tests/tidb_test.go:2223 +0x5f
  github.com/pingcap/failpoint.parse()
      external/com_github_pingcap_failpoint/terms.go:126 +0xa5
  github.com/pingcap/failpoint.newTerms()
      external/com_github_pingcap_failpoint/terms.go:98 +0x3e
  github.com/pingcap/failpoint.(*Failpoint).Enable()
      external/com_github_pingcap_failpoint/failpoint.go:54 +0x3e
  github.com/pingcap/failpoint.(*Failpoints).Enable()
      external/com_github_pingcap_failpoint/failpoints.go:105 +0x296
  github.com/pingcap/failpoint.Enable()
      external/com_github_pingcap_failpoint/failpoints.go:222 +0x48a
  pkg/server/tests/tests_test.setupForTestTopSQLStatementStats()
      pkg/server/tests/tidb_test.go:2050 +0x48b
  github.com/pingcap/failpoint.parseTerm()
      external/com_github_pingcap_failpoint/terms.go:149 +0x364
  github.com/pingcap/failpoint.parse()
      external/com_github_pingcap_failpoint/terms.go:126 +0xa5
  github.com/pingcap/failpoint.newTerms()
      external/com_github_pingcap_failpoint/terms.go:98 +0x3e
  github.com/pingcap/failpoint.(*Failpoint).Enable()
      external/com_github_pingcap_failpoint/failpoint.go:54 +0x3e
  github.com/pingcap/failpoint.(*Failpoints).Enable()
      external/com_github_pingcap_failpoint/failpoints.go:105 +0x296
  github.com/pingcap/failpoint.Enable()
      external/com_github_pingcap_failpoint/failpoints.go:222 +0x444
  pkg/server/tests/tests_test.setupForTestTopSQLStatementStats()
      pkg/server/tests/tidb_test.go:2049 +0x445
  github.com/pingcap/tidb/pkg/domain.(*Domain).rebuildSysVarCache()
      pkg/domain/sysvar_cache.go:146 +0x904
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadSysVarCacheLoop()
      pkg/domain/domain.go:1722 +0x93
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3346 +0x724
  github.com/pingcap/tidb/pkg/domain.(*Domain).GetSessionCache()
      pkg/domain/sysvar_cache.go:62 +0x50
  github.com/pingcap/tidb/pkg/session.(*session).loadCommonGlobalVariablesIfNeeded()
      pkg/session/session.go:3723 +0x2ce
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt()
      pkg/session/session.go:2094 +0x184
  github.com/pingcap/tidb/pkg/session.(*session).ExecuteInternal()
      pkg/session/session.go:1608 +0x3b9
  github.com/pingcap/tidb/pkg/domain.(*Domain).LoadPrivilegeLoop()
      pkg/domain/domain.go:1665 +0x108
  github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl()
      pkg/session/session.go:3339 +0x6ca
  github.com/pingcap/tidb/pkg/session.BootstrapSession()
      pkg/session/session.go:3260 +0x22a
  pkg/server/tests/tests_test.createTidbTestSuiteWithCfg()
      pkg/server/tests/tidb_test.go:104 +0x1b5
  pkg/server/tests/tests_test.createTidbTestSuite()
      pkg/server/tests/tidb_test.go:93 +0x204
  pkg/server/tests/tests_test.setupForTestTopSQLStatementStats()
      pkg/server/tests/tidb_test.go:2040 +0x296
  pkg/server/tests/tests_test.TestTopSQLStatementStats3()
      pkg/server/tests/tidb_test.go:2221 +0x3e
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44
Goroutine 41122 (running) created at:
  github.com/pingcap/tidb/pkg/util/topsql/stmtstats.(*aggregator).start()
      pkg/util/topsql/stmtstats/aggregator.go:56 +0x1a4
  github.com/pingcap/tidb/pkg/util/topsql/stmtstats.SetupAggregator()
      pkg/util/topsql/stmtstats/aggregator.go:146 +0x7a
  pkg/server/tests/tests_test.setupForTestTopSQLStatementStats()
      pkg/server/tests/tidb_test.go:2023 +0x62
  pkg/server/tests/tests_test.TestTopSQLStatementStats3()
      pkg/server/tests/tidb_test.go:2221 +0x3e
  testing.tRunner()
      GOROOT/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1648 +0x44
Goroutine 41121 (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/server/tests/tests_test.TestMain()
      pkg/server/tests/main_test.go:73 +0xfcf
  main.main()
      bazel-out/k8-fastbuild/bin/pkg/server/tests/tests_test_/testmain.go:259 +0x5d1
================== 

4. What is your TiDB version? (Required)

@hawkingrei hawkingrei added type/bug The issue is confirmed as a bug. component/test labels Feb 1, 2024
@jebter jebter added the sig/diagnosis SIG: Diagnosis label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/test severity/moderate sig/diagnosis SIG: Diagnosis type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants