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

schedule: fix datarace in operator.check #8264

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Jun 6, 2024

What problem does this PR solve?

Issue Number: Close #8263

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)
    go test -timeout 120s -run ^TestOperatorCheckConcurrently$ github.com/tikv/pd/pkg/schedule/operator -race
  • in master
==================
WARNING: DATA RACE
Read at 0x00c0004dc240 by goroutine 212:
  github.com/tikv/pd/pkg/schedule/operator.(*Operator).Check()
      /home/lhy1024/pd/pkg/schedule/operator/operator.go:382 +0x5c4
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently.func1()
      /home/lhy1024/pd/pkg/schedule/operator/operator_test.go:593 +0xbe

Previous write at 0x00c0004dc240 by goroutine 215:
  sync/atomic.CompareAndSwapInt64()
      /usr/lib/go/src/runtime/race_amd64.s:316 +0xb
  sync/atomic.CompareAndSwapInt64()
      <autogenerated>:1 +0x1a
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently.func1()
      /home/lhy1024/pd/pkg/schedule/operator/operator_test.go:593 +0xbe

Goroutine 212 (running) created at:
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently()
      /home/lhy1024/pd/pkg/schedule/operator/operator_test.go:591 +0x487
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /usr/lib/go/src/testing/testing.go:1742 +0x44

Goroutine 215 (running) created at:
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently()
      /home/lhy1024/pd/pkg/schedule/operator/operator_test.go:591 +0x487
  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: TestOperatorCheckConcurrently (0.00s)
    testing.go:1398: race detected during execution of test
FAIL
FAIL    github.com/tikv/pd/pkg/schedule/operator        0.103s
FAIL
  • with this pr
ok      github.com/tikv/pd/pkg/schedule/operator        1.098s

Release note

None.

Copy link
Contributor

ti-chi-bot bot commented Jun 6, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HuSharp
  • rleungx

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.

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed dco-signoff: yes Indicates the PR's author has signed the dco. labels Jun 6, 2024
@ti-chi-bot ti-chi-bot bot requested review from HuSharp and rleungx June 6, 2024 06:33
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 6, 2024
Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 77.50%. Comparing base (f69d600) to head (1665065).
Report is 138 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8264      +/-   ##
==========================================
+ Coverage   77.32%   77.50%   +0.18%     
==========================================
  Files         471      471              
  Lines       61380    61381       +1     
==========================================
+ Hits        47463    47575     +112     
+ Misses      10365    10258     -107     
+ Partials     3552     3548       -4     
Flag Coverage Δ
unittests 77.50% <75.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

startTime, _ := o.getCurrentTimeAndStep()
operatorStepDuration.WithLabelValues(reflect.TypeOf(o.steps[int(step)]).Name()).
Observe(time.Unix(0, o.stepsTime[step]).Sub(startTime).Seconds())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is stepsTime useless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the code goes into this branch, it means that o.stepsTime[step]) is now time.Now()

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 6, 2024
Copy link
Contributor

ti-chi-bot bot commented Jun 7, 2024

@okJiang: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 7, 2024
@HuSharp
Copy link
Member

HuSharp commented Jun 7, 2024

please add affect label

@lhy1024
Copy link
Contributor Author

lhy1024 commented Jun 7, 2024

/merge

Copy link
Contributor

ti-chi-bot bot commented Jun 7, 2024

@lhy1024: 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. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Copy link
Contributor

ti-chi-bot bot commented Jun 7, 2024

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

Commit hash: 849163a

@ti-chi-bot ti-chi-bot bot added status/can-merge Indicates a PR has been approved by a committer. and removed do-not-merge/needs-triage-completed labels Jun 7, 2024
@ti-chi-bot ti-chi-bot bot merged commit e767c01 into tikv:master Jun 7, 2024
16 checks passed
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Jul 16, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #8401.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Jul 16, 2024
@ti-chi-bot ti-chi-bot removed the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Jul 19, 2024
lhy1024 added a commit to ti-chi-bot/pd that referenced this pull request Jul 19, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Jul 19, 2024
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Jul 31, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #8469.

ti-chi-bot bot added a commit that referenced this pull request Aug 1, 2024
close #8263

Signed-off-by: lhy1024 <[email protected]>

Co-authored-by: lhy1024 <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
@HuSharp HuSharp added needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Aug 27, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #8578.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Aug 27, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #8579.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Aug 27, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Aug 27, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #8580.

ti-chi-bot bot pushed a commit that referenced this pull request Sep 4, 2024
close #8263

Signed-off-by: husharp <[email protected]>

Co-authored-by: husharp <[email protected]>
Co-authored-by: Hu# <[email protected]>
ti-chi-bot bot added a commit that referenced this pull request Sep 10, 2024
close #8263

Signed-off-by: husharp <[email protected]>

Co-authored-by: husharp <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has signed the dco. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. 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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

schedule: operator.check will meet datarace
5 participants