This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
feat(split): supplement two cases after implementing cancel split #742
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hycdong
changed the title
feat(split): supplement two cases after implementing pause cancel split
feat(split): supplement two cases after implementing cancel split
Feb 1, 2021
levy5307
approved these changes
Feb 8, 2021
foreverneverer
approved these changes
Feb 9, 2021
neverchanje
reviewed
Feb 9, 2021
Comment on lines
836
to
+854
if (app == nullptr || rep.pid.get_partition_index() >= app->partition_count) { | ||
// app is not recognized or partition is not recognized | ||
dassert(false, | ||
"gpid(%d.%d) on node(%s) is not exist on meta server, administrator " | ||
"should check consistency of meta data", | ||
rep.pid.get_app_id(), | ||
rep.pid.get_partition_index(), | ||
request.node.to_string()); | ||
// This app has garbage partition after cancel split, the canceled child | ||
// partition should be gc | ||
if (app != nullptr && | ||
rep.pid.get_partition_index() < app->partition_count * 2 && | ||
rep.status == partition_status::PS_ERROR) { | ||
response.gc_replicas.push_back(rep); | ||
dwarn_f("notify node({}) to gc replica({}) because it is useless partition " | ||
"which is caused by cancel split", | ||
request.node.to_string(), | ||
rep.pid); | ||
} else { | ||
// app is not recognized or partition is not recognized | ||
dassert(false, | ||
"gpid({}) on node({}) is not exist on meta server, administrator " | ||
"should check consistency of meta data", | ||
rep.pid, | ||
request.node.to_string()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are too many embedded levels, you should have sensed a very bad smell in this code. Try to make this big if into a function.
// check_partition_index_validity returns false if the replica is should be GCed.
bool check_partition_index_validity(const shared_ptr<app_state>& app, gpid request_pid) {
bool should_assert=false;
if (app == nullptr) {
should_assert=true;
} else if (rep.status != partition_status::PS_ERROR && rep.pid.get_partition_index() >= app->partition_count * 2) {
should_assert=true;
}
if (should_assert) {
dassert(false);
}
}
if (!check_partition_index_validity( req.pid)) {
response.gc_replicas.push_back(rep);
}
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In pervious pull requests, cancel partition split is implemented, after adding those functions, we need to handle some cases specially.
register_child_on_meta
on_config_sync