Fix subtraction overflow in metrics (#14290)
This commit is contained in:
parent
7b49c85aa7
commit
c693ffaa08
|
@ -347,7 +347,7 @@ fn update_peer_stats(
|
|||
) {
|
||||
let now = timestamp();
|
||||
let last = last_datapoint_submit.load(Ordering::Relaxed);
|
||||
if now - last > 1000
|
||||
if now.saturating_sub(last) > 1000
|
||||
&& last_datapoint_submit.compare_and_swap(last, now, Ordering::Relaxed) == last
|
||||
{
|
||||
datapoint_info!(
|
||||
|
|
|
@ -117,7 +117,9 @@ fn update_retransmit_stats(
|
|||
|
||||
let now = timestamp();
|
||||
let last = stats.last_ts.load(Ordering::Relaxed);
|
||||
if now - last > 2000 && stats.last_ts.compare_and_swap(last, now, Ordering::Relaxed) == last {
|
||||
if now.saturating_sub(last) > 2000
|
||||
&& stats.last_ts.compare_and_swap(last, now, Ordering::Relaxed) == last
|
||||
{
|
||||
datapoint_info!("retransmit-num_nodes", ("count", peers_len, i64));
|
||||
datapoint_info!(
|
||||
"retransmit-stage",
|
||||
|
@ -288,7 +290,8 @@ fn retransmit(
|
|||
|
||||
let now = timestamp();
|
||||
let last = last_peer_update.load(Ordering::Relaxed);
|
||||
if now - last > 1000 && last_peer_update.compare_and_swap(last, now, Ordering::Relaxed) == last
|
||||
if now.saturating_sub(last) > 1000
|
||||
&& last_peer_update.compare_and_swap(last, now, Ordering::Relaxed) == last
|
||||
{
|
||||
drop(r_epoch_stakes_cache);
|
||||
let mut w_epoch_stakes_cache = epoch_stakes_cache.write().unwrap();
|
||||
|
|
|
@ -2723,7 +2723,7 @@ impl AccountsDB {
|
|||
fn report_store_timings(&self) {
|
||||
let last = self.stats.last_store_report.load(Ordering::Relaxed);
|
||||
let now = solana_sdk::timing::timestamp();
|
||||
if now - last > 1000
|
||||
if now.saturating_sub(last) > 1000
|
||||
&& self
|
||||
.stats
|
||||
.last_store_report
|
||||
|
|
Loading…
Reference in New Issue