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

statistics: meet data race when check IsRegionHot #8335

Closed
lhy1024 opened this issue Jun 27, 2024 · 1 comment · Fixed by #8336
Closed

statistics: meet data race when check IsRegionHot #8335

lhy1024 opened this issue Jun 27, 2024 · 1 comment · Fixed by #8336
Labels
affects-8.2 severity/major type/bug The issue is confirmed as a bug.

Comments

@lhy1024
Copy link
Contributor

lhy1024 commented Jun 27, 2024

Bug Report

What did you do?

go test -timeout 120s -run ^TestSpecialUseHotRegion$ github.com/tikv/pd/pkg/schedule/schedulers -race

What did you expect to see?

no data race

What did you see instead?

==================
WARNING: DATA RACE
Write at 0x00c00003b2f0 by goroutine 210:
  runtime.mapassign_fast64()
      /usr/lib/go/src/runtime/map_fast64.go:93 +0x0
  github.com/tikv/pd/pkg/statistics.(*HotPeerCache).putItem()
      /home/lhy1024/pd/pkg/statistics/hot_peer_cache.go:521 +0x14e
  github.com/tikv/pd/pkg/statistics.(*HotPeerCache).UpdateStat()
      /home/lhy1024/pd/pkg/statistics/hot_peer_cache.go:111 +0x64
  github.com/tikv/pd/pkg/statistics.(*HotCache).Update()
      /home/lhy1024/pd/pkg/statistics/hot_cache.go:202 +0x8c
  github.com/tikv/pd/pkg/mock/mockcluster.(*Cluster).AddLeaderRegionWithWriteInfo()
      /home/lhy1024/pd/pkg/mock/mockcluster/mockcluster.go:552 +0x464
  github.com/tikv/pd/pkg/schedule/schedulers.TestSpecialUseHotRegion()
      /home/lhy1024/pd/pkg/schedule/schedulers/scheduler_test.go:350 +0xa3b
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /usr/lib/go/src/testing/testing.go:1742 +0x44

Previous read at 0x00c00003b2f0 by goroutine 214:
  runtime.mapaccess2_fast64()
      /usr/lib/go/src/runtime/map_fast64.go:53 +0x0
  github.com/tikv/pd/pkg/statistics.(*HotPeerCache).getHotPeerStat()
      /home/lhy1024/pd/pkg/statistics/hot_peer_cache.go:429 +0x57
  github.com/tikv/pd/pkg/statistics.(*HotPeerCache).isRegionHotWithPeer()
      /home/lhy1024/pd/pkg/statistics/hot_peer_cache.go:422 +0x9c
  github.com/tikv/pd/pkg/statistics.(*HotPeerCache).isRegionHotWithAnyPeers()
      /home/lhy1024/pd/pkg/statistics/hot_peer_cache.go:411 +0xd0
  github.com/tikv/pd/pkg/statistics.(*HotCache).IsRegionHot.func1()
      /home/lhy1024/pd/pkg/statistics/hot_cache.go:108 +0x4b
  github.com/tikv/pd/pkg/statistics.(*HotCache).runWriteTask()
      /home/lhy1024/pd/pkg/statistics/hot_cache.go:192 +0x5e
  github.com/tikv/pd/pkg/statistics.(*HotCache).runWriteTask-fm()
      <autogenerated>:1 +0x3d
  github.com/tikv/pd/pkg/statistics.(*HotCache).updateItems()
      /home/lhy1024/pd/pkg/statistics/hot_cache.go:176 +0x87
  github.com/tikv/pd/pkg/statistics.NewHotCache.gowrap2()
      /home/lhy1024/pd/pkg/statistics/hot_cache.go:49 +0x4f

Goroutine 210 (running) created at:
  testing.(*T).Run()
      /usr/lib/go/src/testing/testing.go:1742 +0x825
  testing.runTests.func1()
      /usr/lib/go/src/testing/testing.go:2161 +0x85
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1689 +0x21e
  testing.runTests()
      /usr/lib/go/src/testing/testing.go:2159 +0x8be
  testing.(*M).Run()
      /usr/lib/go/src/testing/testing.go:2027 +0xf17
  main.main()
      _testmain.go:227 +0x2bd

Goroutine 214 (running) created at:
  github.com/tikv/pd/pkg/statistics.NewHotCache()
      /home/lhy1024/pd/pkg/statistics/hot_cache.go:49 +0x444
  github.com/tikv/pd/pkg/statistics.NewHotStat()
      /home/lhy1024/pd/pkg/statistics/hot_stat.go:33 +0x34
  github.com/tikv/pd/pkg/mock/mockcluster.NewCluster()
      /home/lhy1024/pd/pkg/mock/mockcluster/mockcluster.go:70 +0x1a8
  github.com/tikv/pd/pkg/schedule/schedulers.prepareSchedulersTest()
      /home/lhy1024/pd/pkg/schedule/schedulers/scheduler_test.go:42 +0x91
  github.com/tikv/pd/pkg/schedule/schedulers.TestSpecialUseHotRegion()
      /home/lhy1024/pd/pkg/schedule/schedulers/scheduler_test.go:313 +0x73
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /usr/lib/go/src/testing/testing.go:1742 +0x44
==================
--- FAIL: TestSpecialUseHotRegion (0.01s)
    testing.go:1398: race detected during execution of test
FAIL

What version of PD are you using (pd-server -V)?

@lhy1024 lhy1024 added the type/bug The issue is confirmed as a bug. label Jun 27, 2024
@lhy1024
Copy link
Contributor Author

lhy1024 commented Jun 27, 2024

it is introduced by #8164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.2 severity/major type/bug The issue is confirmed as a bug.
Projects
Development

Successfully merging a pull request may close this issue.

1 participant