From d8293abc6450c33bd62edc5a3c1663511c3c3daa Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Tue, 29 Jun 2021 19:39:46 +0000 Subject: [PATCH] debug logs when crds table trim failed (#18307) reports of this error being possibly spammy: https://discord.com/channels/428295358100013066/689412830075551748/859441080054710293 The commit changes the log level to debug. Additionally adding a new metric to understand the frequency of this error. (cherry picked from commit 9d983a34a0be4626521edec05e51ce17645867ff) --- core/src/cluster_info.rs | 5 ++++- core/src/cluster_info_metrics.rs | 2 ++ core/src/crds.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/cluster_info.rs b/core/src/cluster_info.rs index 5c3b278576..40ca6ebb96 100644 --- a/core/src/cluster_info.rs +++ b/core/src/cluster_info.rs @@ -1758,11 +1758,14 @@ impl ClusterInfo { .map(|k| k.id) .chain(std::iter::once(self.id)) .collect(); + self.stats.trim_crds_table.add_relaxed(1); let mut gossip = self.gossip.write().unwrap(); match gossip.crds.trim(cap, &keep, stakes, timestamp()) { Err(err) => { self.stats.trim_crds_table_failed.add_relaxed(1); - error!("crds table trim failed: {:?}", err); + // TODO: Stakes are comming from the root-bank. Debug why/when + // they are empty/zero. + debug!("crds table trim failed: {:?}", err); } Ok(num_purged) => { self.stats diff --git a/core/src/cluster_info_metrics.rs b/core/src/cluster_info_metrics.rs index 6a1b5b0b04..5391b5956e 100644 --- a/core/src/cluster_info_metrics.rs +++ b/core/src/cluster_info_metrics.rs @@ -113,6 +113,7 @@ pub(crate) struct GossipStats { pub(crate) skip_pull_response_shred_version: Counter, pub(crate) skip_pull_shred_version: Counter, pub(crate) skip_push_message_shred_version: Counter, + pub(crate) trim_crds_table: Counter, pub(crate) trim_crds_table_failed: Counter, pub(crate) trim_crds_table_purged_values_count: Counter, pub(crate) tvu_peers: Counter, @@ -396,6 +397,7 @@ pub(crate) fn submit_gossip_stats( stats.require_stake_for_gossip_unknown_stakes.clear(), i64 ), + ("trim_crds_table", stats.trim_crds_table.clear(), i64), ( "trim_crds_table_failed", stats.trim_crds_table_failed.clear(), diff --git a/core/src/crds.rs b/core/src/crds.rs index b7b106fd8e..91ce7632a0 100644 --- a/core/src/crds.rs +++ b/core/src/crds.rs @@ -509,7 +509,7 @@ impl Crds { stakes: &HashMap, now: u64, ) -> Result { - if stakes.is_empty() { + if stakes.values().all(|&stake| stake == 0) { return Err(CrdsError::UnknownStakes); } let mut keys: Vec<_> = self