diff --git a/src/v/raft/heartbeat_manager.cc b/src/v/raft/heartbeat_manager.cc index ef53078f24e6a..d58289c19b17e 100644 --- a/src/v/raft/heartbeat_manager.cc +++ b/src/v/raft/heartbeat_manager.cc @@ -23,12 +23,14 @@ #include "rpc/types.h" #include "vlog.h" +#include #include #include #include #include #include +#include #include #include @@ -72,9 +74,9 @@ heartbeat_manager::follower_request_meta::~follower_request_meta() noexcept { static heartbeat_requests requests_for_range( const consensus_set& c, clock_type::duration heartbeat_interval) { - absl::btree_map< + absl::node_hash_map< model::node_id, - std::vector>> pending_beats; @@ -154,9 +156,10 @@ static heartbeat_requests requests_for_range( reqs.reserve(pending_beats.size()); for (auto& p : pending_beats) { std::vector requests; - absl:: - btree_map - meta_map; + absl::node_hash_map< + raft::group_id, + heartbeat_manager::follower_request_meta> + meta_map; requests.reserve(p.second.size()); for (auto& [hb, follower_meta] : p.second) { meta_map.emplace(hb.meta.group, std::move(follower_meta)); @@ -228,7 +231,7 @@ ss::future<> heartbeat_manager::do_self_heartbeat(node_heartbeat&& r) { .group = hb.meta.group, .result = append_entries_reply::status::success}; }); - process_reply(r.target, std::move(r.meta_map), std::move(reply)); + process_reply(r.target, r.meta_map, std::move(reply)); return ss::now(); } @@ -254,7 +257,7 @@ ss::future<> heartbeat_manager::do_heartbeat(node_heartbeat&& r) { this](result ret) mutable { // this will happen after RPC client will return and resume // sending heartbeats to follower - process_reply(node, std::move(groups), std::move(ret)); + process_reply(node, groups, std::move(ret)); }); // fail fast to make sure that not lagging nodes will be able to receive // hearteats @@ -272,7 +275,7 @@ ss::future<> heartbeat_manager::do_heartbeat(node_heartbeat&& r) { void heartbeat_manager::process_reply( model::node_id n, - absl::btree_map groups, + const absl::node_hash_map& groups, result r) { if (!r) { vlog( diff --git a/src/v/raft/heartbeat_manager.h b/src/v/raft/heartbeat_manager.h index 24abb988a1c7d..24a100b11c4b4 100644 --- a/src/v/raft/heartbeat_manager.h +++ b/src/v/raft/heartbeat_manager.h @@ -23,6 +23,7 @@ #include #include +#include #include namespace raft::details { @@ -108,7 +109,7 @@ class heartbeat_manager { node_heartbeat( model::node_id t, heartbeat_request req, - absl::btree_map seqs) + absl::node_hash_map seqs) : target(t) , request(std::move(req)) , meta_map(std::move(seqs)) {} @@ -117,7 +118,7 @@ class heartbeat_manager { heartbeat_request request; // each raft group has its own follower metadata hence we need map to // track a sequence per group - absl::btree_map meta_map; + absl::node_hash_map meta_map; }; heartbeat_manager( @@ -155,7 +156,7 @@ class heartbeat_manager { /// \param result if the node return successful heartbeats void process_reply( model::node_id n, - absl::btree_map groups, + const absl::node_hash_map& groups, result result); // private members