raft: transfer information about group0 liveness in direct_fd_ping
Add a new variant of the reply to the direct_fd_ping which specifies whether the local group0 is alive or not, and start actively using it. There is no need to introduce a cluster feature. Due to how our serialization framework works, nodes which do not recognize the new variant will treat it as the existing std::monostate. The std::monostate means "the node and group0 is alive"; nodes before the changes in this commit would send a std::monostate anyway, so this is completely transparent for the old nodes.
This commit is contained in:
@@ -121,8 +121,12 @@ struct wrong_destination {
|
||||
raft::server_id reached_id;
|
||||
};
|
||||
|
||||
struct group_liveness_info {
|
||||
bool group0_alive;
|
||||
};
|
||||
|
||||
struct direct_fd_ping_reply {
|
||||
std::variant<std::monostate, service::wrong_destination> result;
|
||||
std::variant<std::monostate, service::wrong_destination, service::group_liveness_info> result;
|
||||
};
|
||||
|
||||
verb [[with_client_info, cancellable]] direct_fd_ping (raft::server_id dst_id) -> service::direct_fd_ping_reply;
|
||||
|
||||
@@ -75,8 +75,12 @@ struct wrong_destination {
|
||||
raft::server_id reached_id;
|
||||
};
|
||||
|
||||
struct group_liveness_info {
|
||||
bool group0_alive;
|
||||
};
|
||||
|
||||
struct direct_fd_ping_reply {
|
||||
std::variant<std::monostate, wrong_destination> result;
|
||||
std::variant<std::monostate, wrong_destination, group_liveness_info> result;
|
||||
};
|
||||
|
||||
} // namespace service
|
||||
|
||||
@@ -297,15 +297,27 @@ void raft_group_registry::init_rpc_verbs() {
|
||||
// XXX: update address map here as well?
|
||||
|
||||
if (_my_id != dst) {
|
||||
co_return direct_fd_ping_reply {
|
||||
return make_ready_future<direct_fd_ping_reply>(direct_fd_ping_reply {
|
||||
.result = wrong_destination {
|
||||
.reached_id = _my_id,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
co_return direct_fd_ping_reply {
|
||||
.result = std::monostate{},
|
||||
};
|
||||
|
||||
return container().invoke_on(0, [] (raft_group_registry& me) -> future<direct_fd_ping_reply> {
|
||||
bool group0_alive = false;
|
||||
if (me._group0_id) {
|
||||
auto* group0_server = me.find_server(*me._group0_id);
|
||||
if (group0_server && group0_server->is_alive()) {
|
||||
group0_alive = true;
|
||||
}
|
||||
}
|
||||
co_return direct_fd_ping_reply {
|
||||
.result = service::group_liveness_info{
|
||||
.group0_alive = group0_alive,
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -513,6 +525,8 @@ future<bool> direct_fd_pinger::ping(direct_failure_detector::pinger::endpoint_id
|
||||
rslog.trace("ping(id = {}, ip_addr = {}): wrong destination (reached {})",
|
||||
dst_id, *addr, wrong_dst->reached_id);
|
||||
co_return false;
|
||||
} else if (auto* info = std::get_if<group_liveness_info>(&reply.result)) {
|
||||
co_return info->group0_alive;
|
||||
}
|
||||
} catch (seastar::rpc::closed_error&) {
|
||||
co_return false;
|
||||
|
||||
Reference in New Issue
Block a user