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

Fix panic of adjacent-region-scheduler after pd transfer leader #1250

Merged
merged 2 commits into from
Sep 20, 2018

Conversation

nanne007
Copy link
Contributor

What problem does this PR solve?

If adjacent-region scheduler is enabled, after pd transfers leader and the new leader is prepared,
there is a gap that heartbeats of some regions are not received, and leaders are not updated.

store id of a nil peer is 0, see https://github.com/pingcap/pd/blob/fa5f08c252a4c5025cdef5bf0f2bdab78d7c0a36/vendor/github.com/pingcap/kvproto/pkg/metapb/metapb.pb.go#L256, so this line https://github.com/pingcap/pd/blob/fa5f08c252a4c5025cdef5bf0f2bdab78d7c0a36/server/schedulers/adjacent_region.go#L223 return a nil store, which causes panic.

What is changed and how it works?

This change makes sure that region's leader is not nil, and leader's store is not nil, and also fix metric value of adjacent-count.

Another solution is skip holes of not heartbeat-ed regions when calculating adjacent-regions, which prevents the issue at front.

Check List

Tests

make test

No side effects

@sre-bot
Copy link
Contributor

sre-bot commented Sep 19, 2018

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@disksing
Copy link
Contributor

/ok-to-test

@disksing
Copy link
Contributor

PTAL @nolouch

@disksing
Copy link
Contributor

LGTM.

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 nolouch merged commit de4e6d5 into tikv:master Sep 20, 2018
@nanne007 nanne007 deleted the fix/adjacent-region-panic branch September 20, 2018 02:12
nanne007 added a commit to nanne007/pd that referenced this pull request Jan 2, 2019
@sre-bot sre-bot added the contribution This PR is from a community contributor. label Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants