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 scheduler removes region leader #1462

Merged
merged 2 commits into from
Mar 20, 2019
Merged

Conversation

disksing
Copy link
Contributor

What problem does this PR solve?

Normally, PD avoids removing leader directly when scheduling. When the leader needs to be removed, the PD inserts a transfer leader step. However, when the number of replica is set to 1, this scheme does not attempt to transfer the leader to the peer that will be created, resulting in the direct remove of the leader.

What is changed and how it works?

Constructs a list based on the current peers and the peer to be added, then looks for the target of the transferLeader in the list. If target is not found, it returns an error to cancel the schedule process.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release notes

Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
@disksing disksing added type/bug The issue is confirmed as a bug. needs-cherry-pick-release-2.0 The PR needs to cherry pick to release-2.0 branch. needs-cherry-pick-release-2.1 The PR needs to cherry pick to release-2.1 branch. labels Mar 18, 2019
@disksing disksing requested review from nolouch and rleungx March 18, 2019 11:33
@codecov-io
Copy link

Codecov Report

Merging #1462 into master will decrease coverage by 0.4%.
The diff coverage is 39.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1462      +/-   ##
==========================================
- Coverage    67.8%   67.39%   -0.41%     
==========================================
  Files         158      158              
  Lines       15262    15322      +60     
==========================================
- Hits        10348    10327      -21     
- Misses       4003     4060      +57     
- Partials      911      935      +24
Impacted Files Coverage Δ
server/schedulers/hot_region.go 77.44% <20%> (-2.02%) ⬇️
server/schedulers/shuffle_region.go 71.92% <25%> (-4%) ⬇️
server/schedulers/adjacent_region.go 73.29% <25%> (-1.28%) ⬇️
server/schedule/region_scatterer.go 84.09% <33.33%> (-1.96%) ⬇️
server/handler.go 54.56% <33.33%> (-0.58%) ⬇️
server/schedule/replica_checker.go 80.6% <33.33%> (-7.76%) ⬇️
server/schedule/namespace_checker.go 75% <40%> (-3.34%) ⬇️
server/schedulers/balance_region.go 81.3% <40%> (-2.19%) ⬇️
server/schedule/operator.go 86.91% <61.9%> (-2.22%) ⬇️
pkg/tempurl/tempurl.go 57.14% <0%> (-14.29%) ⬇️
... and 9 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 59968e1...eddcacd. Read the comment docs.

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

LGTM

@nolouch
Copy link
Contributor

nolouch commented Mar 20, 2019

/rebuild

@nolouch nolouch merged commit 8a22295 into tikv:master Mar 20, 2019
@disksing disksing deleted the rp branch March 20, 2019 06:10
disksing added a commit to oh-my-tidb/pd that referenced this pull request Mar 20, 2019
* schedule: fix scheduler removes region leader

Signed-off-by: disksing <i@disksing.com>
disksing added a commit to oh-my-tidb/pd that referenced this pull request Mar 20, 2019
Signed-off-by: disksing <i@disksing.com>
disksing added a commit that referenced this pull request Mar 20, 2019
* schedule: fix scheduler removes region leader

Signed-off-by: disksing <i@disksing.com>
disksing added a commit that referenced this pull request Mar 20, 2019
Signed-off-by: disksing <i@disksing.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-2.0 The PR needs to cherry pick to release-2.0 branch. needs-cherry-pick-release-2.1 The PR needs to cherry pick to release-2.1 branch. type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants