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: fix data race in IsRegionHot (#8336) #8341

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #8336

What problem does this PR solve?

Issue Number: Close #8335

Before #8164 it is

// 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

None.

@ti-chi-bot ti-chi-bot added approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-8.2 labels Jun 27, 2024
@ti-chi-bot ti-chi-bot bot removed the approved label Jun 27, 2024
@ti-chi-bot ti-chi-bot bot added the approved label Jun 27, 2024
Copy link
Contributor

ti-chi-bot bot commented Jun 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: HuSharp, rleungx

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 27, 2024
@ti-chi-bot ti-chi-bot bot merged commit 6f2f9ed into tikv:release-8.2 Jun 27, 2024
15 checks passed
@HuSharp HuSharp deleted the cherry-pick-8336-to-release-8.2 branch June 27, 2024 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-8.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants