// IsRegionHot checks if the region is hot.
func (w *HotCache) IsRegionHot(region *core.RegionInfo, minHotDegree int) bool {
checkRegionHotWriteTask := newCheckRegionHotTask(region, minHotDegree)
checkRegionHotReadTask := newCheckRegionHotTask(region, minHotDegree)
succ1 := w.CheckWriteAsync(checkRegionHotWriteTask)
succ2 := w.CheckReadAsync(checkRegionHotReadTask)
if succ1 && succ2 {
return checkRegionHotWriteTask.waitRet(w.ctx) || checkRegionHotReadTask.waitRet(w.ctx)
}
return false
}
What is changed and how does it work?
Check List
Tests
Unit test
Test1:
This test will meet data race in master and is normal in this PR.
for i in {1..50}; do
go clean -testcache
go test -timeout 120s -run ^TestSpecialUseHotRegion$ github.com/tikv/pd/pkg/schedule/schedulers -race
done
- Test2:
This test will be successful in this PR and be failed in master branches
--- FAIL: TestIsHot (0.00s)
/home/lhy1024/pd/pkg/statistics/hot_cache_test.go:34:
Error Trace: /home/lhy1024/pd/pkg/statistics/hot_cache_test.go:34
Error: Should be true
Test: TestIsHot
FAIL
### Release note
<!--
A bugfix or a new feature needs a release note. If there is no need to give a release note, just leave it with the `None`.
Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.
-->
```release-note
None.
Needs approval from an approver in each of these files:
- ~~[OWNERS](https://github.com/tikv/pd/blob/release-8.2/OWNERS)~~ [HuSharp,rleungx]
Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
This is an automated cherry-pick of #8336
What problem does this PR solve?
Issue Number: Close #8335
Before #8164 it is
What is changed and how does it work?
Check List
Tests
Unit test
Test1: This test will meet data race in master and is normal in this PR.
--- FAIL: TestIsHot (0.00s) /home/lhy1024/pd/pkg/statistics/hot_cache_test.go:34: Error Trace: /home/lhy1024/pd/pkg/statistics/hot_cache_test.go:34 Error: Should be true Test: TestIsHot FAIL