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

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-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Aug 27, 2024
Signed-off-by: husharp <[email protected]>
@HuSharp HuSharp force-pushed the cherry-pick-8264-to-release-6.5 branch from 5675fe3 to c24f173 Compare August 27, 2024 08:35
@HuSharp
Copy link
Member

HuSharp commented Aug 27, 2024

In release 6.5, 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                                                                                                               [16:34:24]
==================
WARNING: DATA RACE
Read at 0x00c0000421c8 by goroutine 155:
  github.com/tikv/pd/server/schedule/operator.(*Operator).Check()
      /Users/pingcap/CS/PingCAP/pd/server/schedule/operator/operator.go:305 +0x418
  github.com/tikv/pd/server/schedule/operator.TestOperatorCheckConcurrently.func1()
      /Users/pingcap/CS/PingCAP/pd/server/schedule/operator/operator_test.go:511 +0x8c

Previous write at 0x00c0000421c8 by goroutine 163:
  ??()
      -:0 +0x10402a9f4
  sync/atomic.CompareAndSwapInt64()
      <autogenerated>:1 +0x18
  github.com/tikv/pd/server/schedule/operator.TestOperatorCheckConcurrently.func1()
      /Users/pingcap/CS/PingCAP/pd/server/schedule/operator/operator_test.go:511 +0x8c

Goroutine 155 (running) created at:
  github.com/tikv/pd/server/schedule/operator.TestOperatorCheckConcurrently()
      /Users/pingcap/CS/PingCAP/pd/server/schedule/operator/operator_test.go:509 +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 163 (running) created at:
  github.com/tikv/pd/server/schedule/operator.TestOperatorCheckConcurrently()
      /Users/pingcap/CS/PingCAP/pd/server/schedule/operator/operator_test.go:509 +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)

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Aug 27, 2024
@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 <[email protected]>
@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 4, 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.

Copy link
Contributor

ti-chi-bot bot commented Sep 4, 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 added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 4, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 4, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-27 08:55:40.168807959 +0000 UTC m=+860535.303258079: ☑️ agreed by lhy1024.
  • 2024-09-04 13:34:47.567645686 +0000 UTC m=+451412.085698613: ☑️ agreed by HuSharp.

@ti-chi-bot ti-chi-bot bot merged commit 1bbec47 into tikv:release-6.5 Sep 4, 2024
18 checks passed
@HuSharp HuSharp deleted the cherry-pick-8264-to-release-6.5 branch September 4, 2024 13:38
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-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants