-
Notifications
You must be signed in to change notification settings - Fork 59
feat(split): update group partition count #392
Conversation
@@ -754,6 +756,202 @@ void replica::child_partition_active(const partition_configuration &config) // o | |||
update_configuration(config); | |||
} | |||
|
|||
// ThreadPool: THREAD_POOL_REPLICATION | |||
void replica::update_group_partition_count(int32_t new_partition_count, |
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.
parent_update_group_partition_count
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.
update_group_partition_count
- primary parent send request to all replicas
on_update_group_partition_count
- all replicas update its partition_count
on_update_group_partition_count_reply
- primary parent callback
I think function names above are clearer, so I don't add parent
prefix for update_group_partition_count
.
@@ -754,6 +756,202 @@ void replica::child_partition_active(const partition_configuration &config) // o | |||
update_configuration(config); | |||
} | |||
|
|||
// ThreadPool: THREAD_POOL_REPLICATION | |||
void replica::update_group_partition_count(int32_t new_partition_count, | |||
bool is_update_child) // on primary parent |
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.
this function mixes up update-child and update-parent, making it more complex than it should be.
Consider this: split this function into parent_update_parent_group_partition_count
and parent_update_child_group_partition_count
, and makes them both use call_update_group_partition_count_rpc
.
void replica::call_update_group_partition_count_rpc(gpid) {
FAIL_POINT_INJECT_F(...);
std::unordered_set<dsn::rpc_address> not_replied_addresses;
// _primary_states.statuses is a map structure: rpc address -> partition_status
for (const auto &kv : _primary_states.statuses) {
not_replied_addresses.insert(kv.first);
}
for (auto &iter : _primary_states.statuses) {
rpc.call([](){ on_update_group_partition_count_reply(); })
}
}
void replica::parent_update_parent_group_partition_count(gpid) {
ddebug_replica("start to update parent group partition count, new partition count = {}, ",
new_partition_count);
call_update_group_partition_count_rpc(get_gpid());
}
void replica::parent_update_child_group_partition_count(gpid) {
if (_child_gpid.get_app_id() == 0 || _child_init_ballot != get_ballot()) {
dwarn_replica("can not update group partition count because current state is out-dated, "
"_child_gpid({}), _child_init_ballot = {}, local ballot = {}",
_child_gpid,
_child_init_ballot,
get_ballot());
_stub->split_replica_error_handler(
_child_gpid,
std::bind(&replica::child_handle_split_error,
std::placeholders::_1,
"update_group_partition_count because out-dated request"));
parent_cleanup_split_context();
return;
}
ddebug_replica("start to update child group partition count, new partition count = {}, ",
new_partition_count);
call_update_group_partition_count_rpc(get_gpid());
}
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.
I think the code logic is not too complex, the code logic is like:
step1: if update child partition_count, do some validation
step2: get structure not_replied_addresses
step3: send request to replica group
In your suggestion, call_update_group_partition_count_rpc
will implement step2 and step3. However, update_group_partition_count_request have difference between sending to parent or child, you can see L792 to L807.
Simple partition split process
More partition split discussion in issue #69 and partition split design doc
This pr solves the part of fifth step of partition split, which is bold in process description.
What this pr solved
update_group_partition_count
: primary parent send update_group_partition_count_request to all parent group or child groupon_update_group_partition_count
: all replica, not matter the replica is parent or child, primary or secondary, updateapp_info
in memory and on disk, updatepartition_version
. Besides, for parent replica, it should clean up split context, because split finishedon_update_group_partition_count_reply
: primary parent handle update_group_partition_count_response. If all child group finish update partition count, primary parent will register child partition on meta server.