From 4bd0845fce71fe6b6a4a014f76917eb2590c59a8 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Tue, 13 Dec 2022 13:03:47 +0200 Subject: [PATCH] gossiper: make send_gossip_echo cancellable Currently send_gossip_echo has a 22 seconds timeout during which _abort_source is ignored. Mark the verb as cancellable so it can be canceled on shutdown / abort. Signed-off-by: Benny Halevy --- gms/gossiper.cc | 2 +- idl/gossip.idl.hh | 2 +- test/manual/message.cc | 16 +++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index ae1b43d9de..babc63d9c9 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -955,7 +955,7 @@ future> gossiper::get_unreachable_members_synchronized() } future<> gossiper::send_echo(locator::host_id host_id, std::chrono::milliseconds timeout_ms, int64_t generation_number, bool notify_up) { - return ser::gossip_rpc_verbs::send_gossip_echo(&_messaging, host_id, netw::messaging_service::clock_type::now() + timeout_ms, generation_number, notify_up); + return ser::gossip_rpc_verbs::send_gossip_echo(&_messaging, host_id, netw::messaging_service::clock_type::now() + timeout_ms, _abort_source, generation_number, notify_up); } future<> gossiper::failure_detector_loop_for_node(locator::host_id host_id, generation_type gossip_generation, uint64_t live_endpoints_version) { diff --git a/idl/gossip.idl.hh b/idl/gossip.idl.hh index 77b43792e8..714a11bbe2 100644 --- a/idl/gossip.idl.hh +++ b/idl/gossip.idl.hh @@ -9,7 +9,7 @@ #include "gms/gossip_digest_syn.hh" namespace gms { -verb [[with_client_info, with_timeout]] gossip_echo (int64_t generation_number [[version 4.6.0]], bool notify_up [[version 6.1.0]]) +verb [[with_client_info, with_timeout, cancellable]] gossip_echo (int64_t generation_number [[version 4.6.0]], bool notify_up [[version 6.1.0]]) verb [[with_client_info, one_way]] gossip_shutdown (gms::inet_address from, int64_t generation_number [[version 4.6.0]]) verb [[with_client_info, one_way, ip]] gossip_digest_syn (gms::gossip_digest_syn syn) verb [[with_client_info, one_way]] gossip_digest_ack (gms::gossip_digest_ack ask) diff --git a/test/manual/message.cc b/test/manual/message.cc index fd7e3d8ad9..50f463e8a3 100644 --- a/test/manual/message.cc +++ b/test/manual/message.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include "db/config.hh" @@ -157,15 +158,12 @@ public: future<> test_echo() { test_logger.info("=== {} ===", __func__); int64_t gen = 0x1; - return ser::gossip_rpc_verbs::send_gossip_echo(&ms, _server_id, netw::messaging_service::clock_type::now() + std::chrono::seconds(10), gen, false).then_wrapped([] (auto&& f) { - try { - f.get(); - return make_ready_future<>(); - } catch (std::runtime_error& e) { - test_logger.error("test_echo: {}", e.what()); - } - return make_ready_future<>(); - }); + abort_source as; + try { + co_await ser::gossip_rpc_verbs::send_gossip_echo(&ms, _server_id, netw::messaging_service::clock_type::now() + std::chrono::seconds(10), as, gen, false); + } catch (...) { + test_logger.error("test_echo: {}", std::current_exception()); + } } };