Skip to content

Commit

Permalink
[State Sync] Reduce the frequency of the error logs when missing peers.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLind authored and bors-libra committed Dec 22, 2021
1 parent 346301f commit 70a5189
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 10 additions & 5 deletions state-sync/diem-data-client/src/diemnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ mod state;
#[cfg(test)]
mod tests;

// Useful constants for the Diem Data Client
const GLOBAL_DATA_LOG_FREQ_SECS: u64 = 5;
const POLLER_ERROR_LOG_FREQ_SECS: u64 = 1;

/// A [`DiemDataClient`] that fulfills requests from remote peers' Storage Service
/// over DiemNet.
Expand Down Expand Up @@ -461,11 +463,14 @@ impl DataSummaryPoller {
{
Ok(peer) => peer,
Err(error) => {
error!(
(LogSchema::new(LogEntry::StorageSummaryRequest)
.event(LogEvent::NoPeersToPoll)
.message("Unable to select next peer")
.error(&error))
sample!(
SampleRate::Duration(Duration::from_secs(POLLER_ERROR_LOG_FREQ_SECS)),
error!(
(LogSchema::new(LogEntry::StorageSummaryRequest)
.event(LogEvent::NoPeersToPoll)
.message("Unable to select next peer")
.error(&error))
);
);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use std::{collections::HashMap, sync::Arc, time::Duration};
use tokio::time::interval;
use tokio_stream::wrappers::IntervalStream;

// Useful constants for the Data Streaming Service
const REFRESH_ERROR_LOG_FREQ_SECS: u64 = 1;

/// The data streaming service that responds to data stream requests.
pub struct DataStreamingService<T> {
// The configuration for this streaming service.
Expand Down Expand Up @@ -208,9 +211,12 @@ impl<T: DiemDataClient + Send + Clone + 'static> DataStreamingService<T> {
&metrics::GLOBAL_DATA_SUMMARY_ERROR,
error.get_label().into(),
);
error!(LogSchema::new(LogEntry::RefreshGlobalData)
.event(LogEvent::Error)
.error(&error));
sample!(
SampleRate::Duration(Duration::from_secs(REFRESH_ERROR_LOG_FREQ_SECS)),
error!(LogSchema::new(LogEntry::RefreshGlobalData)
.event(LogEvent::Error)
.error(&error))
);
}
}

Expand Down

0 comments on commit 70a5189

Please sign in to comment.