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) #8578

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #8264

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.

@ti-chi-bot ti-chi-bot added dco-signoff: yes Indicates the PR's author has signed the dco. 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-7.1 This PR is cherry-picked to release-7.1 from a source PR. labels Aug 27, 2024
Signed-off-by: husharp <ihusharp@gmail.com>
@HuSharp HuSharp force-pushed the cherry-pick-8264-to-release-7.1 branch from dc5daf2 to 7b750ff Compare August 27, 2024 08:52
@HuSharp
Copy link
Member

HuSharp commented Aug 27, 2024

In release 7.1, run test will meet data race only for variable time.

go clean -testcache 
go test -timeout 120s -run ^TestOperatorCheckConcurrently$ github.com/tikv/pd/server/schedule/operator -race
pingcap@MacBook-Pro-2 ~/CS/PingCAP/pd
cherry-pick-8264-to-release-6.5* $ go test -timeout 120s -run ^TestOperatorCheckConcurrently$ github.com/tikv/pd/server/schedule/operator -race                                                                                                               ==================
WARNING: DATA RACE
Read at 0x00c0005aa228 by goroutine 167:
  github.com/tikv/pd/pkg/schedule/operator.(*Operator).Check()
      /Users/pingcap/CS/PingCAP/pd/pkg/schedule/operator/operator.go:317 +0x418
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently.func1()
      /Users/pingcap/CS/PingCAP/pd/pkg/schedule/operator/operator_test.go:553 +0x8c

Previous write at 0x00c0005aa228 by goroutine 166:
  ??()
      -:0 +0x1041769f4
  sync/atomic.CompareAndSwapInt64()
      <autogenerated>:1 +0x18
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently.func1()
      /Users/pingcap/CS/PingCAP/pd/pkg/schedule/operator/operator_test.go:553 +0x8c

Goroutine 167 (running) created at:
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently()
      /Users/pingcap/CS/PingCAP/pd/pkg/schedule/operator/operator_test.go:551 +0x368
  testing.tRunner()
      /opt/homebrew/opt/go/libexec/src/testing/testing.go:1595 +0x1b0
  testing.(*T).Run.func1()
      /opt/homebrew/opt/go/libexec/src/testing/testing.go:1648 +0x40

Goroutine 166 (running) created at:
  github.com/tikv/pd/pkg/schedule/operator.TestOperatorCheckConcurrently()
      /Users/pingcap/CS/PingCAP/pd/pkg/schedule/operator/operator_test.go:551 +0x368
  testing.tRunner()
      /opt/homebrew/opt/go/libexec/src/testing/testing.go:1595 +0x1b0
  testing.(*T).Run.func1()
      /opt/homebrew/opt/go/libexec/src/testing/testing.go:1648 +0x40
==================
--- FAIL: TestOperatorCheckConcurrently (0.00s)
    testing.go:1465: race detected during execution of test
FAIL
FAIL    github.com/tikv/pd/pkg/schedule/operator        0.574s
FAIL

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 27, 2024
Signed-off-by: husharp <ihusharp@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 27, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 6, 2024

@okJiang: adding LGTM is restricted to approvers and reviewers in OWNERS files.

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 kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added the lgtm label Sep 6, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 6, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: HuSharp, lhy1024, okJiang

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 bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 6, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 6, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-27 08:56:00.048173269 +0000 UTC m=+860555.182623391: ☑️ agreed by lhy1024.
  • 2024-09-06 06:02:23.141057935 +0000 UTC m=+597067.659110855: ☑️ agreed by HuSharp.

@ti-chi-bot ti-chi-bot bot merged commit 9fb2837 into tikv:release-7.1 Sep 10, 2024
18 checks passed
@HuSharp HuSharp deleted the cherry-pick-8264-to-release-7.1 branch September 10, 2024 08:31
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/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-7.1 This PR is cherry-picked to release-7.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants