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 at the StatementStatsMap #43100

Open
Tracked by #41316
hawkingrei opened this issue Apr 17, 2023 · 1 comment
Open
Tracked by #41316

DATA RACE at the StatementStatsMap #43100

hawkingrei opened this issue Apr 17, 2023 · 1 comment

Comments

@hawkingrei
Copy link
Member

hawkingrei commented Apr 17, 2023

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 0x00c01d78bb30 by goroutine 58814:
  runtime.mapassign()
      GOROOT/src/runtime/map.go:578 +0x0
  github.com/pingcap/tidb/util/topsql/stmtstats.StatementStatsMap.Merge()
      util/topsql/stmtstats/stmtstats.go:162 +0x3a9
  github.com/pingcap/tidb/server.setupForTestTopSQLStatementStats.func1()
      server/tidb_test.go:2033 +0xa4
  github.com/pingcap/tidb/server.(*mockCollector).CollectStmtStatsMap()
      server/tidb_test.go:1729 +0x45
  github.com/pingcap/tidb/util/topsql/stmtstats.(*aggregator).aggregate.func2()
      util/topsql/stmtstats/aggregator.go:91 +0x56
  sync.(*Map).Range()
      GOROOT/src/sync/map.go:476 +0x1db
  github.com/pingcap/tidb/util/topsql/stmtstats.(*aggregator).aggregate()
      util/topsql/stmtstats/aggregator.go:90 +0xde
  github.com/pingcap/tidb/util/topsql/stmtstats.(*aggregator).run()
      util/topsql/stmtstats/aggregator.go:71 +0xd1
  github.com/pingcap/tidb/util/topsql/stmtstats.(*aggregator).start.func1()
      util/topsql/stmtstats/aggregator.go:56 +0x39
Previous read at 0x00c01d78bb30 by goroutine 58813:
  runtime.mapiternext()
      GOROOT/src/runtime/map.go:866 +0x0
  github.com/pingcap/tidb/server.TestTopSQLStatementStats3()
      server/tidb_test.go:2261 +0x67d
  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 +0x8f
  github.com/pingcap/tidb/server.TestTopSQLStatementStats3()
      server/tidb_test.go:2224 +0x6b
  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 +0x468
  github.com/pingcap/tidb/server.setupForTestTopSQLStatementStats()
      server/tidb_test.go:2051 +0x469
  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 +0x41e
  github.com/pingcap/tidb/server.setupForTestTopSQLStatementStats()
      server/tidb_test.go:2050 +0x41f
  github.com/pingcap/tidb/domain.(*Domain).rebuildSysVarCache()
      domain/sysvar_cache.go:146 +0x8c4
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1581 +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:1525 +0x130
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3318 +0x684
  github.com/pingcap/tidb/server.createTidbTestSuiteWithCfg()
      server/tidb_test.go:102 +0x1b6
  github.com/pingcap/tidb/server.createTidbTestSuite()
      server/tidb_test.go:91 +0x21a
  github.com/pingcap/tidb/server.setupForTestTopSQLStatementStats()
      server/tidb_test.go:2041 +0x2a4
  github.com/pingcap/tidb/server.TestTopSQLStatementStats3()
      server/tidb_test.go:2222 +0x4a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
Goroutine 58814 (running) created at:
  github.com/pingcap/tidb/util/topsql/stmtstats.(*aggregator).start()
      util/topsql/stmtstats/aggregator.go:56 +0x19a
  github.com/pingcap/tidb/util/topsql/stmtstats.SetupAggregator()
      util/topsql/stmtstats/aggregator.go:146 +0x86
  github.com/pingcap/tidb/server.setupForTestTopSQLStatementStats()
      server/tidb_test.go:2024 +0x6e
  github.com/pingcap/tidb/server.TestTopSQLStatementStats3()
      server/tidb_test.go:2222 +0x4a
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
Goroutine 58813 (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/server.TestMain()
      server/main_test.go:74 +0xe76
  main.main()
      bazel-out/k8-fastbuild/bin/server/server_test_/testmain.go:410 +0x5e8
================== 

4. What is your TiDB version? (Required)

master

HEAD is now at 4878ed3 ddl: Coalesce partition (#42476)

@hawkingrei hawkingrei added the type/bug The issue is confirmed as a bug. label Apr 17, 2023
@ti-chi-bot ti-chi-bot added may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Apr 18, 2023
@seiya-annie seiya-annie removed may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Apr 18, 2023
@crazycs520
Copy link
Contributor

race in test, doesn't affect correctness, change severity from major to minor.

@crazycs520 crazycs520 removed the type/bug The issue is confirmed as a bug. label Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants