Skip to content

raftstore: handle the race between creating new peer and splitting correctly#8084

Merged
ti-srebot merged 44 commits intotikv:masterfrom
gengliqi:fix-merge-bug-4
Jul 29, 2020
Merged

raftstore: handle the race between creating new peer and splitting correctly#8084
ti-srebot merged 44 commits intotikv:masterfrom
gengliqi:fix-merge-bug-4

Conversation

@gengliqi
Copy link
Member

@gengliqi gengliqi commented Jun 11, 2020

Signed-off-by: Liqi Geng gengliqiii@gmail.com

What problem does this PR solve?

Problem Summary:

The new region which is created by splitting may has already created before in some sophisticated cases.

I tried to fix it by changing the split flow. close #7503
But it's too complicated and slower than before.
With @NingLin-P's help, this new method for this PR is to add a new pending_create_peers. It has lower performance loss than the previous fix PR.

What is changed and how it works?

What's Changed:
Add StoreMeta to ApplyContext to handle the race of creating peer and splitting.

The test will be added.

Related changes

  • Need to cherry-pick to the release branch

Tests

  • Integration test

Side effects

No.

Release note

  • Fix an issue that split may panic and corrupt the metadata if the split process is too slow and region merge is open.

gengliqi added 7 commits June 11, 2020 22:06
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Comment on lines +1952 to +1954
regions,
derived,
new_regions_map,
Copy link
Member

Choose a reason for hiding this comment

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

regions and new_regions_map looks duplicated, could we just remove all regions that don't need to split from regions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I consider it before. But the regions is also used in resp. I don't know what's its effect yet.

gengliqi added 2 commits June 17, 2020 09:23
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
@NingLin-P NingLin-P requested a review from BusyJay June 17, 2020 04:04
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
gengliqi added 2 commits June 17, 2020 16:11
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
@gengliqi gengliqi requested review from BusyJay and NingLin-P June 19, 2020 00:11
@gengliqi gengliqi requested a review from Connor1996 June 19, 2020 03:13
@gengliqi gengliqi removed needs-cherry-pick-release-3.0 Type: Need cherry pick to release 3.0 needs-cherry-pick-release-3.1 Type: Need cherry pick to release 3.1 needs-cherry-pick-release-4.0 Type: Need cherry pick to release 4.0 labels Jul 24, 2020
@gengliqi
Copy link
Member Author

/merge

@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 8299

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@gengliqi merge failed.

@gengliqi
Copy link
Member Author

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@gengliqi merge failed.

@gengliqi
Copy link
Member Author

/run-all-tests

@gengliqi
Copy link
Member Author

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 95d4411 into tikv:master Jul 29, 2020
@gengliqi gengliqi added the sig/raft Component: Raft, RaftStore, etc. label Aug 19, 2020
ti-chi-bot pushed a commit that referenced this pull request Jan 14, 2021
)

### What problem does this PR solve?

Issue Number: close #8783

Problem Summary:
#8783 (comment)
The bug is located in function `on_ready_split_region` which is introduced by #8084.
https://github.com/tikv/tikv/blob/7c9850040ba58d48f0f1a93345c0392dffb2fc5b/components/raftstore/src/store/fsm/peer.rs#L2084-L2112
Line 2111 `continue` means this region has already existed so it should be skipped.
But line 2087-2090 has already added this region to `region_ranges` which leads to metadata inconsistency.

### What is changed and how it works?

What's Changed:
Fix this bug and add 2 tests.

Run `test_split_not_to_split_existed_tombstone_region ` and `test_split_not_to_split_existed_different_uninitialied_peer` can panic in different place in previous code.

### Related changes

- Need to cherry-pick to the release branch

### Check List <!--REMOVE the items that are not applicable-->

Tests <!-- At least one of them must be included. -->

- Integration test

Side effects

- No

### Release note <!-- bugfixes or new feature need a release note -->
* No release note
gengliqi added a commit to gengliqi/tikv that referenced this pull request Jan 26, 2021
Signed-off-by: gengliqi <gengliqiii@gmail.com>
ti-chi-bot pushed a commit that referenced this pull request Jul 13, 2021
…rrectly (#9584)

* cherry pick #8084 #8454 #9495

Signed-off-by: gengliqi <gengliqiii@gmail.com>

* fix compile error

Signed-off-by: gengliqi <gengliqiii@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sig/raft Component: Raft, RaftStore, etc. 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.

6 participants