-
Notifications
You must be signed in to change notification settings - Fork 59
feat(split): add splitting_replicas while on_config_sync #653
Conversation
src/replica/replica_stub.cpp
Outdated
@@ -1331,11 +1334,20 @@ void replica_stub::on_node_query_reply(error_code err, | |||
} | |||
|
|||
for (auto it = resp.partitions.begin(); it != resp.partitions.end(); ++it) { | |||
auto meta_split_status = split_status::NOT_SPLIT; |
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.
maybe you can calculate meta_split_status
in meta server. So we don't need to calculate it in each replica server
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.
If an app is not splitting, splitting_replicas
in configuration_query_by_node_response
won't be set. The config_sync rpc will happen every 30 seconds for all replica servers, and partition split is not a frequent action, for most cases it will reduce the network cost.
src/replica/replica_stub.cpp
Outdated
{ | ||
replica_ptr replica = get_replica(req.config.pid); | ||
if (replica != nullptr) { | ||
replica->on_config_sync(req.info, req.config); | ||
replica->on_config_sync(req.info, req.config, meta_split_status); |
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.
It's ugly to particularly add an argument for one requirement. It makes the function responsibility obscure. I'd prefer adding meta_split_status
to configuration_update_request
, even it's ugly too.
Think about it, dozens of parameters in a function, if we keep doing that. And I admit this code is shit, so we can't make it worse.
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.
Done
Simple partition split process
More partition split discussion in issue #69 and partition split design doc
This pr solves the part of second step of partition split, which is bold in process description.
What this pr solve
Replica server will send on_config_sync rpc to meta server periodically to get the newest configuration from meta server, we use it to transfer the split status from meta to replica.
on_config_sync
in server_state.cpp )on_node_query_reply
in replica_stub.cpp ), then do possible split actions ( functionon_config_sync
in replica_config.cpp and functioncontrol_split
in replica_split_manager.cpp ). This pr only add primary start split, the more split action will be added in further pull request.This pr also adds related unit tests.