From e94bb84850e765285335fd354f76d13adb0873fe Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Mon, 29 Apr 2024 16:18:19 +0800 Subject: [PATCH] 1 --- src/meta/test/meta_partition_guardian_test.cpp | 1 - src/meta/test/misc/misc.cpp | 6 ++---- src/replica/replica_config.cpp | 12 +++++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/meta/test/meta_partition_guardian_test.cpp b/src/meta/test/meta_partition_guardian_test.cpp index 536eaaf4a8..52f7906c6f 100644 --- a/src/meta/test/meta_partition_guardian_test.cpp +++ b/src/meta/test/meta_partition_guardian_test.cpp @@ -81,7 +81,6 @@ static void apply_update_request(/*in-out*/ configuration_update_request &update case config_type::CT_ASSIGN_PRIMARY: case config_type::CT_UPGRADE_TO_PRIMARY: SET_OBJ_IP_AND_HOST_PORT(pc, primary, update_req, node); - // TODO(yingchun): optimize the following code REMOVE_IP_AND_HOST_PORT_BY_OBJ(pc, secondaries, update_req, node); break; diff --git a/src/meta/test/misc/misc.cpp b/src/meta/test/misc/misc.cpp index c48b192fe3..0a04746f5f 100644 --- a/src/meta/test/misc/misc.cpp +++ b/src/meta/test/misc/misc.cpp @@ -362,8 +362,7 @@ void proposal_action_check_and_apply(const configuration_proposal_action &act, CHECK(node != nodes.end(), ""); ns = &node->second; SET_IP_AND_HOST_PORT(pc, primary, act.node, hp_node); - bool ok = REMOVE_IP_AND_HOST_PORT_BY_OBJ(pc, secondaries, act, node); - CHECK(ok, ""); + CHECK(REMOVE_IP_AND_HOST_PORT_BY_OBJ(pc, secondaries, act, node), ""); ns->put_partition(pc.pid, true); break; } @@ -393,8 +392,7 @@ void proposal_action_check_and_apply(const configuration_proposal_action &act, CHECK_EQ(pc.primary, act.target); CHECK(is_secondary(pc, hp_node), ""); CHECK(is_secondary(pc, act.node), ""); - bool ok = REMOVE_IP_AND_HOST_PORT_BY_OBJ(pc, secondaries, act, node); - CHECK(ok, ""); + CHECK(REMOVE_IP_AND_HOST_PORT_BY_OBJ(pc, secondaries, act, node), ""); const auto node = nodes.find(hp_node); CHECK(node != nodes.end(), ""); ns = &node->second; diff --git a/src/replica/replica_config.cpp b/src/replica/replica_config.cpp index c7e9e36c87..28d56c1521 100644 --- a/src/replica/replica_config.cpp +++ b/src/replica/replica_config.cpp @@ -169,7 +169,7 @@ void replica::assign_primary(configuration_update_request &proposal) SET_IP_AND_HOST_PORT( proposal.config, primary, _stub->primary_address(), _stub->primary_host_port()); - bool ok = REMOVE_IP_AND_HOST_PORT( + REMOVE_IP_AND_HOST_PORT( proposal.config, secondaries, _stub->primary_address(), _stub->primary_host_port()); update_configuration_on_meta_server(proposal.type, node, proposal.config); @@ -293,8 +293,9 @@ void replica::downgrade_to_inactive_on_primary(configuration_update_request &pro RESET_IP_AND_HOST_PORT(proposal.config, primary); } else { CHECK_NE(proposal.node, proposal.config.primary); - bool ok = REMOVE_IP_AND_HOST_PORT_BY_OBJ(proposal.config, secondaries, proposal, node); - CHECK(ok, "remove node failed, node = {}", FMT_HOST_PORT_AND_IP(proposal, node)); + CHECK(REMOVE_IP_AND_HOST_PORT_BY_OBJ(proposal.config, secondaries, proposal, node), + "remove node failed, node = {}", + FMT_HOST_PORT_AND_IP(proposal, node)); } update_configuration_on_meta_server( @@ -321,8 +322,9 @@ void replica::remove(configuration_update_request &proposal) RESET_IP_AND_HOST_PORT(proposal.config, primary); break; case partition_status::PS_SECONDARY: { - bool ok = REMOVE_IP_AND_HOST_PORT_BY_OBJ(proposal.config, secondaries, proposal, node); - CHECK(ok, "remove node failed, node = {}", FMT_HOST_PORT_AND_IP(proposal, node)); + CHECK(REMOVE_IP_AND_HOST_PORT_BY_OBJ(proposal.config, secondaries, proposal, node), + "remove node failed, node = {}", + FMT_HOST_PORT_AND_IP(proposal, node)); } break; case partition_status::PS_POTENTIAL_SECONDARY: break;