tikv / pd

Placement driver for TiKV
Apache License 2.0
1.03k stars 714 forks source link

storelimit: fix datarace from `getOrCreateStoreLimit` (#8254) #8258

Closed ti-chi-bot closed 3 weeks ago

ti-chi-bot commented 4 weeks ago

This is an automated cherry-pick of #8254

What problem does this PR solve?

Issue Number: Close #8253

What is changed and how does it work?

Check List

Tests

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

Previous read at 0x00c0005ae480 by goroutine 221: github.com/tikv/pd/pkg/core/storelimit.(limit).Available() /home/lhy1024/pd/pkg/core/storelimit/store_limit.go:162 +0xb2 github.com/tikv/pd/pkg/core/storelimit.(StoreRateLimit).Available() /home/lhy1024/pd/pkg/core/storelimit/store_limit.go:101 +0x3a github.com/tikv/pd/pkg/schedule/operator.(Controller).ExceedStoreLimit() /home/lhy1024/pd/pkg/schedule/operator/operator_controller.go:970 +0x4e5 github.com/tikv/pd/pkg/schedule/operator.(Controller).AddOperator() /home/lhy1024/pd/pkg/schedule/operator/operator_controller.go:355 +0x6b github.com/tikv/pd/pkg/schedule/operator.TestConcurrentAddOperatorAndSetStoreLimit.func1() /home/lhy1024/pd/pkg/schedule/operator/operator_controller_test.go:987 +0x2fb github.com/tikv/pd/pkg/schedule/operator.TestConcurrentAddOperatorAndSetStoreLimit.gowrap1() /home/lhy1024/pd/pkg/schedule/operator/operator_controller_test.go:994 +0x41

- run test `TestConcurrentAddOperatorAndSetStoreLimit` with this PR

ok github.com/tikv/pd/pkg/schedule/operator 1.473s

### 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.
ti-chi-bot[bot] commented 4 weeks ago

[REVIEW NOTIFICATION]

This pull request has been approved by:

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment. After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review. Reviewer can cancel approval by submitting a request changes review.
nolouch commented 3 weeks ago

/merge

ti-chi-bot[bot] commented 3 weeks ago

@nolouch: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available [here](https://prow.tidb.net/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.
ti-chi-bot[bot] commented 3 weeks ago

This pull request has been accepted and is ready to merge.

Commit hash: 4bb12de492cf7b6acb5d20bc4fdc26dd1e925441