api: gossiper: fix alive nodes

Fix API call to wait for all shards to reach the current shard 0
gossiper version. Throws when timeout is reached.

Signed-off-by: Alejo Sanchez <alejo.sanchez@scylladb.com>
This commit is contained in:
Alejo Sanchez
2023-01-12 13:35:44 +01:00
parent 6c04476561
commit e35762241a
3 changed files with 14 additions and 3 deletions

View File

@@ -19,9 +19,11 @@ void set_gossiper(http_context& ctx, routes& r, gms::gossiper& g) {
return container_to_vec(res);
});
httpd::gossiper_json::get_live_endpoint.set(r, [&g] (const_req req) {
auto res = g.get_live_members();
return container_to_vec(res);
httpd::gossiper_json::get_live_endpoint.set(r, [&g] (std::unique_ptr<request> req) {
return g.get_live_members_synchronized().then([] (auto res) {
return make_ready_future<json::json_return_type>(container_to_vec(res));
});
});
httpd::gossiper_json::get_endpoint_downtime.set(r, [&g] (const_req req) {

View File

@@ -757,6 +757,12 @@ future<> gossiper::update_live_endpoints_version() {
});
}
future<std::set<inet_address>> gossiper::get_live_members_synchronized() {
auto live_members = gossiper::get_live_members();
co_await replicate_live_endpoints_on_change();
co_return live_members;
}
future<> gossiper::failure_detector_loop_for_node(gms::inet_address node, int64_t gossip_generation, uint64_t live_endpoints_version) {
auto last = gossiper::clk::now();
auto diff = gossiper::clk::duration(0);

View File

@@ -440,6 +440,9 @@ public:
// Wait for nodes to be alive on all shards
future<> wait_alive(std::vector<gms::inet_address> nodes, std::chrono::milliseconds timeout);
// Get live members synchronized to all shards
future<std::set<inet_address>> get_live_members_synchronized();
future<> apply_state_locally(std::map<inet_address, endpoint_state> map);
private: