Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Jul 26, 2024
1 parent 00a4fad commit 1b51d14
Show file tree
Hide file tree
Showing 14 changed files with 153 additions and 147 deletions.
34 changes: 17 additions & 17 deletions idl/meta_admin.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ struct configuration_update_request
1:dsn.layer2.app_info info;
2:dsn.layer2.partition_configuration config;
3:config_type type = config_type.CT_INVALID;
4:dsn.rpc_address node;
5:dsn.rpc_address host_node; // deprecated, only used by stateless apps
4:dsn.rpc_address node1;
5:dsn.rpc_address host_node1; // deprecated, only used by stateless apps

// Used for partition split
// if replica is splitting (whose split_status is not NOT_SPLIT)
// the `meta_split_status` will be set
// only used when on_config_sync
6:optional metadata.split_status meta_split_status;
7:optional dsn.host_port hp_node;
7:optional dsn.host_port hp_node1;
}

// meta server (config mgr) => primary | secondary (downgrade) (w/ new config)
Expand All @@ -101,10 +101,10 @@ struct replica_server_info

struct configuration_query_by_node_request
{
1:dsn.rpc_address node;
1:dsn.rpc_address node1;
2:optional list<metadata.replica_info> stored_replicas;
3:optional replica_server_info info;
4:optional dsn.host_port hp_node;
4:optional dsn.host_port hp_node1;
}

struct configuration_query_by_node_response
Expand All @@ -116,10 +116,10 @@ struct configuration_query_by_node_response

struct configuration_recovery_request
{
1:list<dsn.rpc_address> recovery_nodes;
1:list<dsn.rpc_address> recovery_nodes1;
2:bool skip_bad_nodes;
3:bool skip_lost_partitions;
4:optional list<dsn.host_port> hp_recovery_nodes;
4:optional list<dsn.host_port> hp_recovery_nodes1;
}

struct configuration_recovery_response
Expand Down Expand Up @@ -207,8 +207,8 @@ struct configuration_list_apps_response

struct query_app_info_request
{
1:dsn.rpc_address meta_server;
2:optional dsn.host_port hp_meta_server;
1:dsn.rpc_address meta_server1;
2:optional dsn.host_port hp_meta_server1;
}

struct query_app_info_response
Expand Down Expand Up @@ -283,8 +283,8 @@ struct query_app_manual_compact_response
struct node_info
{
1:node_status status = node_status.NS_INVALID;
2:dsn.rpc_address node;
3:optional dsn.host_port hp_node;
2:dsn.rpc_address node1;
3:optional dsn.host_port hp_node1;
}

struct configuration_list_nodes_request
Expand Down Expand Up @@ -347,15 +347,15 @@ enum balancer_request_type

struct configuration_proposal_action
{
1:dsn.rpc_address target;
2:dsn.rpc_address node;
1:dsn.rpc_address target1;
2:dsn.rpc_address node1;
3:config_type type;

// depricated now
// new fields of this struct should start with 5
// 4:i64 period_ts;
5:optional dsn.host_port hp_target;
6:optional dsn.host_port hp_node;
5:optional dsn.host_port hp_target1;
6:optional dsn.host_port hp_node1;
}

struct configuration_balancer_request
Expand All @@ -381,14 +381,14 @@ struct ddd_diagnose_request

struct ddd_node_info
{
1:dsn.rpc_address node;
1:dsn.rpc_address node1;
2:i64 drop_time_ms;
3:bool is_alive; // if the node is alive now
4:bool is_collected; // if replicas has been collected from this node
5:i64 ballot; // collected && ballot == -1 means replica not exist on this node
6:i64 last_committed_decree;
7:i64 last_prepared_decree;
8:optional dsn.host_port hp_node;
8:optional dsn.host_port hp_node1;
}

struct ddd_partition_info
Expand Down
29 changes: 15 additions & 14 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,10 @@ dsn::error_code replication_ddl_client::list_nodes(
return resp.err;
}

for (const auto &n : resp.infos) {
host_port hp;
GET_HOST_PORT(n, node, hp);
nodes[hp] = n.status;
for (const auto &ni : resp.infos) {
host_port node;
GET_HOST_PORT(ni, node1, node);
nodes[node] = ni.status;
}

return dsn::ERR_OK;
Expand Down Expand Up @@ -928,22 +928,23 @@ dsn::error_code replication_ddl_client::do_recovery(const std::vector<host_port>
std::ostream out(buf);

auto req = std::make_shared<configuration_recovery_request>();
CLEAR_IP_AND_HOST_PORT(*req, recovery_nodes);
CLEAR_IP_AND_HOST_PORT(*req, recovery_nodes1);
for (const auto &node : replica_nodes) {
if (utils::contains(req->hp_recovery_nodes, node)) {
out << "duplicate replica node " << node << ", just ingore it" << std::endl;
if (utils::contains(req->hp_recovery_nodes1, node)) {
out << "duplicate replica node " << node << ", just ignore it" << std::endl;
} else {
ADD_IP_AND_HOST_PORT_BY_DNS(*req, recovery_nodes, node);
ADD_IP_AND_HOST_PORT_BY_DNS(*req, recovery_nodes1, node);
}
}
if (req->hp_recovery_nodes.empty()) {
CHECK(req->recovery_nodes.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
if (req->hp_recovery_nodes1.empty()) {
DCHECK(req->recovery_nodes1.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
out << "node set for recovery it empty" << std::endl;
return ERR_INVALID_PARAMETERS;
}
CHECK(!req->recovery_nodes.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
DCHECK(!req->hp_recovery_nodes1.empty(), "");
DCHECK(!req->recovery_nodes1.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
req->skip_bad_nodes = skip_bad_nodes;
req->skip_lost_partitions = skip_lost_partitions;

Expand All @@ -952,7 +953,7 @@ dsn::error_code replication_ddl_client::do_recovery(const std::vector<host_port>
out << "Skip lost partitions: " << (skip_lost_partitions ? "true" : "false") << std::endl;
out << "Node list:" << std::endl;
out << "=============================" << std::endl;
for (auto &node : req->hp_recovery_nodes) {
for (auto &node : req->hp_recovery_nodes1) {
out << node << std::endl;
}
out << "=============================" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/meta/load_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ configuration_proposal_action
new_proposal_action(const host_port &target, const host_port &node, config_type::type type)
{
configuration_proposal_action act;
SET_IP_AND_HOST_PORT_BY_DNS(act, target, target);
SET_IP_AND_HOST_PORT_BY_DNS(act, node, node);
SET_IP_AND_HOST_PORT_BY_DNS(act, target1, target);
SET_IP_AND_HOST_PORT_BY_DNS(act, node1, node);
act.__set_type(type);
return act;
}
Expand Down
11 changes: 6 additions & 5 deletions src/meta/meta_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,15 @@ void proposal_actions::reset_tracked_current_learner()
current_learner.last_prepared_decree = invalid_decree;
}

void proposal_actions::track_current_learner(const dsn::host_port &node, const replica_info &info)
void proposal_actions::track_current_learner(const dsn::host_port &learner, const replica_info &info)
{
if (empty()) {
return;
}
const auto &act = acts.front();
CHECK(act.hp_node, "");
if (act.hp_node != node) {
host_port first_act_node;
GET_HOST_PORT(act, node1, first_act_node);
if (first_act_node != learner) {
return;
}

Expand All @@ -216,7 +217,7 @@ void proposal_actions::track_current_learner(const dsn::host_port &node, const r
learning_progress_abnormal_detected = true;
} else {
LOG_DEBUG(
"{}: ignore abnormal status of {}, perhaps learn not start", info.pid, node);
"{}: ignore abnormal status of {}, perhaps learn not start", info.pid, learner);
}
} else if (info.status == partition_status::PS_POTENTIAL_SECONDARY) {
if (current_learner.ballot > info.ballot ||
Expand All @@ -226,7 +227,7 @@ void proposal_actions::track_current_learner(const dsn::host_port &node, const r
// TODO: need to add a metric here.
LOG_WARNING("{}: learner({})'s progress step back, please trace this carefully",
info.pid,
node);
learner);
}

// NOTICE: the flag may be abormal currently. it's balancer's duty to make use of the
Expand Down
2 changes: 1 addition & 1 deletion src/meta/meta_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class proposal_actions
public:
proposal_actions();
void reset_tracked_current_learner();
void track_current_learner(const host_port &node, const replica_info &info);
void track_current_learner(const host_port &learner, const replica_info &info);
void clear();

// return the action in acts & whether the action is from balancer
Expand Down
8 changes: 4 additions & 4 deletions src/meta/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,16 +692,16 @@ void meta_service::on_list_nodes(configuration_list_nodes_rpc rpc)
dsn::replication::node_info info;
if (request.status == node_status::NS_INVALID || request.status == node_status::NS_ALIVE) {
info.status = node_status::NS_ALIVE;
for (auto &node : _alive_set) {
SET_IP_AND_HOST_PORT_BY_DNS(info, node, node);
for (const auto &node : _alive_set) {
SET_IP_AND_HOST_PORT_BY_DNS(info, node1, node);
response.infos.push_back(info);
}
}
if (request.status == node_status::NS_INVALID ||
request.status == node_status::NS_UNALIVE) {
info.status = node_status::NS_UNALIVE;
for (auto &node : _dead_set) {
SET_IP_AND_HOST_PORT_BY_DNS(info, node, node);
for (const auto &node : _dead_set) {
SET_IP_AND_HOST_PORT_BY_DNS(info, node1, node);
response.infos.push_back(info);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta/meta_split_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void meta_split_service::on_add_child_on_remote_storage_reply(error_code ec,
update_child_request->config = request.child_config;
update_child_request->info = *app;
update_child_request->type = config_type::CT_REGISTER_CHILD;
SET_OBJ_IP_AND_HOST_PORT(*update_child_request, node, request, primary);
SET_OBJ_IP_AND_HOST_PORT(*update_child_request, node1, request, primary);

// TODO(yingchun): should use conference?
auto child_pc = app->pcs[child_gpid.get_partition_index()];
Expand Down
Loading

0 comments on commit 1b51d14

Please sign in to comment.