Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Apr 29, 2024
1 parent 3812baf commit e94bb84
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/meta/test/meta_partition_guardian_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 2 additions & 4 deletions src/meta/test/misc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions src/replica/replica_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand Down

0 comments on commit e94bb84

Please sign in to comment.