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

election: fix the data race of the leadership resetting #4102

Merged
merged 4 commits into from
Sep 13, 2021

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Sep 9, 2021

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

What problem does this PR solve?

Fix the data race of the leadership resetting.

image

ref: https://ci2.pingcap.net/blue/rest/organizations/jenkins/pipelines/pd_test/runs/2203/nodes/50/steps/94/log/?start=0

What is changed and how it works?

Make sure the leadership is not expired before resetting it.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@JmPotato JmPotato added the component/election Election related logic. label Sep 9, 2021
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 9, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • nolouch

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 added the release-note-none Denotes a PR that doesn't merit a release note. label Sep 9, 2021
@JmPotato JmPotato added require-LGT1 Indicates that the PR requires an LGTM. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Sep 9, 2021
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@JmPotato JmPotato removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 13, 2021
Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@rleungx
Copy link
Member

rleungx commented Sep 13, 2021

Do we need to cherry-pick this PR?

@codecov
Copy link

codecov bot commented Sep 13, 2021

Codecov Report

Merging #4102 (4daed02) into master (740fac1) will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4102      +/-   ##
==========================================
+ Coverage   74.40%   74.53%   +0.12%     
==========================================
  Files         258      258              
  Lines       26322    26323       +1     
==========================================
+ Hits        19585    19619      +34     
+ Misses       4986     4958      -28     
+ Partials     1751     1746       -5     
Flag Coverage Δ
unittests 74.53% <100.00%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
server/election/lease.go 85.71% <100.00%> (+1.58%) ⬆️
server/tso/allocator_manager.go 68.50% <100.00%> (+1.05%) ⬆️
server/tso/local_allocator.go 64.86% <0.00%> (-6.76%) ⬇️
pkg/dashboard/adapter/manager.go 78.72% <0.00%> (-4.26%) ⬇️
pkg/etcdutil/etcdutil.go 82.35% <0.00%> (-2.36%) ⬇️
server/election/leadership.go 82.41% <0.00%> (-2.20%) ⬇️
server/cluster/cluster.go 82.20% <0.00%> (-0.84%) ⬇️
server/core/storage.go 68.04% <0.00%> (-0.76%) ⬇️
server/grpc_service.go 46.93% <0.00%> (-0.35%) ⬇️
pkg/tempurl/tempurl.go 60.00% <0.00%> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 740fac1...4daed02. Read the comment docs.

@JmPotato
Copy link
Member Author

Do we need to cherry-pick this PR?

I think cherry-pick is needed since this data race may affect the normal leadership campaign, i.e, cancel the context immediately after it's set.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 13, 2021
@JmPotato JmPotato added the type/cherry-pick-for-release-5.2 The PR belongs to release-5.2 cherry pick. label Sep 13, 2021
@JmPotato
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

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

/run-all-tests

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
Member

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

Commit hash: c21137a

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 13, 2021
@JmPotato
Copy link
Member Author

/run-unit-test

@ti-chi-bot ti-chi-bot merged commit 3f53f1e into tikv:master Sep 13, 2021
@JmPotato JmPotato deleted the fix_leadership_data_race branch September 13, 2021 08:43
@JmPotato JmPotato added needs-cherry-pick-release-5.2 Type: Need cherry pick to release-5.2 and removed type/cherry-pick-for-release-5.2 The PR belongs to release-5.2 cherry pick. labels Sep 13, 2021
ti-chi-bot added a commit to ti-chi-bot/pd that referenced this pull request Sep 13, 2021
* Fix the data race of the leadership resetting

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

* Fix the test

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

* Add a comment

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

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #4108.

@nolouch nolouch mentioned this pull request Sep 26, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/election Election related logic. needs-cherry-pick-release-5.2 Type: Need cherry pick to release-5.2 release-note-none Denotes a PR that doesn't merit a release note. require-LGT1 Indicates that the PR requires an LGTM. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants