From c53d84e15bade1e6ac60b98e03fc697e3b9c7126 Mon Sep 17 00:00:00 2001 From: HeYuchen <377710264@qq.com> Date: Tue, 2 Mar 2021 14:31:27 +0800 Subject: [PATCH] feat(split): ignore splitting partition during load balance (#763) --- src/meta/greedy_load_balancer.cpp | 4 ++-- src/meta/server_load_balancer.cpp | 3 +++ src/meta/server_state.cpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/meta/greedy_load_balancer.cpp b/src/meta/greedy_load_balancer.cpp index 61042f1741..b68ddaefc8 100644 --- a/src/meta/greedy_load_balancer.cpp +++ b/src/meta/greedy_load_balancer.cpp @@ -833,7 +833,7 @@ void greedy_load_balancer::greedy_balancer(const bool balance_checker) ddebug_f("skip to do primary balance for the ignored app[{}]", app->get_logname()); continue; } - if (app->status != app_status::AS_AVAILABLE || app->is_bulk_loading) + if (app->status != app_status::AS_AVAILABLE || app->is_bulk_loading || app->splitting()) continue; bool enough_information = primary_balancer_per_app(app); @@ -880,7 +880,7 @@ void greedy_load_balancer::greedy_balancer(const bool balance_checker) continue; } - if (app->status != app_status::AS_AVAILABLE || app->is_bulk_loading) + if (app->status != app_status::AS_AVAILABLE || app->is_bulk_loading || app->splitting()) continue; bool enough_information = copy_secondary_per_app(app); diff --git a/src/meta/server_load_balancer.cpp b/src/meta/server_load_balancer.cpp index a2dca46c9f..3e235e2fd0 100644 --- a/src/meta/server_load_balancer.cpp +++ b/src/meta/server_load_balancer.cpp @@ -978,6 +978,9 @@ bool simple_load_balancer::collect_replica(meta_view view, const replica_info &info) { partition_configuration &pc = *get_config(*view.apps, info.pid); + // current partition is during partition split + if (pc.ballot == invalid_ballot) + return false; config_context &cc = *get_config_context(*view.apps, info.pid); if (is_member(pc, node)) { cc.collect_serving_replica(node, info); diff --git a/src/meta/server_state.cpp b/src/meta/server_state.cpp index 588932f326..c35a138ec6 100644 --- a/src/meta/server_state.cpp +++ b/src/meta/server_state.cpp @@ -2364,8 +2364,8 @@ bool server_state::check_all_partitions() for (unsigned int i = 0; i != app->partition_count; ++i) { partition_configuration &pc = app->partitions[i]; config_context &cc = app->helpers->contexts[i]; - - if (cc.stage != config_status::pending_remote_sync) { + // partition is under re-configuration or is child partition + if (cc.stage != config_status::pending_remote_sync && pc.ballot != invalid_ballot) { configuration_proposal_action action; pc_status s = _meta_svc->get_balancer()->cure({&_all_apps, &_nodes}, pc.pid, action);