[PATCH v1 4/4] gossiper: send newest entry in a digest message

3 views
Skip to first unread message

Gleb Natapov

<gleb@scylladb.com>
unread,
Apr 7, 2025, 3:41:11 AMApr 7
to scylladb-dev@googlegroups.com
In cases where two entries have the same ip address send information
only for the newest one. Now we send both which make the receiver use
one of them at random and it may be outdated one (though it should only
cause more data than needed to be requested).
---
gms/gossiper.cc | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gms/gossiper.cc b/gms/gossiper.cc
index 94e582466fd..9d62d88df76 100644
--- a/gms/gossiper.cc
+++ b/gms/gossiper.cc
@@ -1287,7 +1287,7 @@ void gossiper::quarantine_endpoint(locator::host_id id, clk::time_point quaranti
}

utils::chunked_vector<gossip_digest> gossiper::make_random_gossip_digest() const {
- utils::chunked_vector<gossip_digest> g_digests;
+ std::unordered_map<inet_address, gossip_digest> g_digests;
generation_type generation;
version_type max_version;

@@ -1304,9 +1304,14 @@ utils::chunked_vector<gossip_digest> gossiper::make_random_gossip_digest() const
generation = eps.get_heart_beat_state().get_generation();
max_version = get_max_endpoint_state_version(eps);
}
- g_digests.push_back(gossip_digest(es->get_ip(), generation, max_version));
+ gossip_digest d{es->get_ip(), generation, max_version};
+ auto [it, inserted] = g_digests.emplace(es->get_ip(), d);
+ if (!inserted && it->second.get_generation() < generation) {
+ // If there are multiple hosts with the same IP send out the one with newest generation
+ it->second = d;
+ }
}
- return g_digests;
+ return g_digests | std::views::values | std::ranges::to<utils::chunked_vector<gossip_digest>>();
}

future<> gossiper::replicate(endpoint_state es, permit_id pid) {
--
2.47.1

Reply all
Reply to author
Forward
0 new messages