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

leadership: avoid potential data race #6636

Merged
merged 1 commit into from
Jun 20, 2023
Merged

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Jun 19, 2023

What problem does this PR solve?

Issue Number: Close #6635

What is changed and how does it work?

Check List

Tests

  • Unit test

Release note

None.

Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 19, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • 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 size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 19, 2023
Copy link
Member

@JmPotato JmPotato left a comment

Choose a reason for hiding this comment

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

LGTM. Though It would be better if it could be changed to RWLock.

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

lhy1024 commented Jun 19, 2023

LGTM. Though It would be better if it could be changed to RWLock.

It also write, from #6635

Write at 0x00c0120fc100 by goroutine 925857:
  sync/atomic.CompareAndSwapInt32()
      /usr/lib/go/src/runtime/race_amd64.s:310 +0xb
  sync/atomic.CompareAndSwapInt32()
      <autogenerated>:1 +0x1e
  context.(*cancelCtx).cancel()
      /usr/lib/go/src/context/context.go:460 +0xbd
  context.WithCancel.func1()
      /usr/lib/go/src/context/context.go:240 +0x54
  github.com/tikv/pd/pkg/election.(*Leadership).Reset()
      /home/lhy1024/pd/pkg/election/leadership.go:234 +0xb2
  github.com/tikv/pd/pkg/member.(*EmbeddedEtcdMember).ResetLeader()
      /home/lhy1024/pd/pkg/member/member.go:262 +0x3d
  github.com/tikv/pd/tests.(*TestServer).ResignLeader()
      /home/lhy1024/pd/tests/cluster.go:190 +0xee
  github.com/tikv/pd/tests/integrations/tso.TestMixedTSODeployment.func2()
      /home/lhy1024/pd/tests/integrations/tso/client_test.go:446 +0x127

@codecov
Copy link

codecov bot commented Jun 19, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.08 🎉

Comparison is base (0934e64) 74.52% compared to head (600369e) 74.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6636      +/-   ##
==========================================
+ Coverage   74.52%   74.60%   +0.08%     
==========================================
  Files         417      417              
  Lines       43056    43060       +4     
==========================================
+ Hits        32086    32124      +38     
+ Misses       8113     8087      -26     
+ Partials     2857     2849       -8     
Flag Coverage Δ
unittests 74.60% <100.00%> (+0.08%) ⬆️

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

Impacted Files Coverage Δ
pkg/election/leadership.go 88.11% <100.00%> (+2.55%) ⬆️

... and 27 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

Do we need to cherry pick?

@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 20, 2023
@lhy1024
Copy link
Contributor Author

lhy1024 commented Jun 20, 2023

Do we need to cherry pick?

Yes.

For LTS 6.5, we only use Reset in member.ResetLeader and allocatorGroup.leadership, Reset of the former is not called anywhere, the latter is not called Keep.

So only need to pick 7.1 and 7.2

@lhy1024
Copy link
Contributor Author

lhy1024 commented Jun 20, 2023

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 20, 2023

@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.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 20, 2023

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

Commit hash: 600369e

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 20, 2023
@ti-chi-bot ti-chi-bot bot merged commit 3bdfef1 into tikv:master Jun 20, 2023
19 checks passed
@ti-chi-bot
Copy link
Member

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

@ti-chi-bot
Copy link
Member

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

ti-chi-bot bot pushed a commit that referenced this pull request Jun 20, 2023
close #6635, ref #6636

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: lhy1024 <admin@liudos.us>
@rleungx
Copy link
Member

rleungx commented Jun 28, 2023

Do we need to cherry pick?

Yes.

For LTS 6.5, we only use Reset in member.ResetLeader and allocatorGroup.leadership, Reset of the former is not called anywhere, the latter is not called Keep.

So only need to pick 7.1 and 7.2

Is #6668 related to this PR?

@lhy1024
Copy link
Contributor Author

lhy1024 commented Jun 28, 2023

Do we need to cherry pick?

Yes.
For LTS 6.5, we only use Reset in member.ResetLeader and allocatorGroup.leadership, Reset of the former is not called anywhere, the latter is not called Keep.
So only need to pick 7.1 and 7.2

Is #6668 related to this PR?

Yes, this is the same problem. Previously I used find reference in vscode and didn't find a call here as well, I will pick this pr to an older version. It is introduced by #4044

@ti-chi-bot
Copy link
Member

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

@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Jun 28, 2023
close tikv#6635

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@lhy1024 lhy1024 deleted the fix-data-race branch June 28, 2023 03:40
@lhy1024 lhy1024 added needs-cherry-pick-release-5.4 Type: Need cherry pick to release-5.4 needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 labels Jun 28, 2023
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Jun 28, 2023
close tikv#6635

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Jun 28, 2023
close tikv#6635

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request Jun 29, 2023
close #6635, ref #6636

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: lhy1024 <admin@liudos.us>
ti-chi-bot bot pushed a commit that referenced this pull request Jun 29, 2023
close #6635, ref #6636

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: lhy1024 <admin@liudos.us>
Co-authored-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request Jun 29, 2023
close #6635, ref #6636

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: lhy1024 <admin@liudos.us>
Co-authored-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request Jun 29, 2023
close #6635, ref #6636

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: lhy1024 <admin@liudos.us>
Co-authored-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
JmPotato added a commit to JmPotato/pd that referenced this pull request Sep 25, 2023
* leadership: avoid potential data race (tikv#6636)

close tikv#6635

Signed-off-by: lhy1024 <admin@liudos.us>

* client: fix the keyspace ID RW race inside tsoServiceDiscovery (tikv#6657)

ref tikv#5895

Fix the keyspace ID RW race inside `tsoServiceDiscovery`.

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>

* mcs: support pprof for microservices (tikv#6541)

ref tikv#5895

Signed-off-by: Ryan Leung <rleungx@gmail.com>

---------

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: JmPotato <ghzpotato@gmail.com>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Co-authored-by: Ryan Leung <rleungx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Type: Need cherry pick to release-5.4 needs-cherry-pick-release-6.1 needs-cherry-pick-release-6.5 needs-cherry-pick-release-7.1 needs-cherry-pick-release-7.2 release-note-none size/S Denotes a PR that changes 10-29 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.

Data race in TestMixedTSODeployment
4 participants