Skip to content

Commit

Permalink
[State Sync] Clean up logs for SSv2.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLind authored and aptos-bot committed Apr 26, 2022
1 parent 85aecaf commit 4d47cac
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
18 changes: 11 additions & 7 deletions state-sync/aptos-data-client/src/aptosnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ mod state;
mod tests;

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

/// An [`AptosDataClient`] that fulfills requests from remote peers' Storage Service
/// over AptosNet.
Expand Down Expand Up @@ -140,7 +141,7 @@ impl AptosNetDataClient {
.copied()
.ok_or_else(|| {
Error::DataIsUnavailable(
"No connected peers are advertising that they can serve this data!".to_owned(),
format!("No connected peers are advertising that they can serve this data! Request: {:?}",request),
)
})
}
Expand Down Expand Up @@ -203,10 +204,10 @@ impl AptosNetDataClient {
E: Into<Error>,
{
let peer = self.choose_peer_for_request(&request).map_err(|error| {
error!(
debug!(
(LogSchema::new(LogEntry::StorageServiceRequest)
.event(LogEvent::PeerSelectionError)
.message("Unable to select next peer")
.message("Unable to select peer")
.error(&error))
);
error
Expand Down Expand Up @@ -556,15 +557,18 @@ impl DataSummaryPoller {
// Log the new global data summary and update the metrics
sample!(
SampleRate::Duration(Duration::from_secs(GLOBAL_DATA_LOG_FREQ_SECS)),
debug!(
info!(
(LogSchema::new(LogEntry::PeerStates)
.event(LogEvent::AggregateSummary)
.message(&format!(
"Global data summary: {:?}",
self.data_client.get_global_data_summary()
)))
);
let global_data_summary = self.data_client.global_summary_cache.read().clone();
);
sample!(
SampleRate::Duration(Duration::from_secs(GLOBAL_DATA_METRIC_FREQ_SECS)),
let global_data_summary = self.data_client.get_global_data_summary();
update_advertised_data_metrics(global_data_summary);
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ impl<T: AptosDataClient + Send + Clone + 'static> DataStream<T> {
Error::IntegerOverflow("Number of entries to remove has overflown!".into())
})?;

info!(
debug!(
(LogSchema::new(LogEntry::StreamNotification)
.stream_id(self.data_stream_id)
.event(LogEvent::Success)
Expand Down
27 changes: 18 additions & 9 deletions state-sync/state-sync-v2/state-sync-driver/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use crate::{
storage_synchronizer::StorageSynchronizerInterface,
utils,
};
use ::aptos_logger::*;
use aptos_config::config::{RoleType, StateSyncDriverConfig};
use aptos_data_client::AptosDataClient;
use aptos_infallible::Mutex;
use aptos_logger::prelude::*;
use aptos_types::waypoint::Waypoint;
use consensus_notifications::{
ConsensusCommitNotification, ConsensusNotification, ConsensusSyncNotification,
Expand All @@ -33,6 +33,9 @@ use storage_interface::DbReader;
use tokio::time::{interval, Duration};
use tokio_stream::wrappers::IntervalStream;

// Useful constants for the driver
const DRIVER_ERROR_LOG_FREQ_SECS: u64 = 1;

/// The configuration of the state sync driver
#[derive(Clone)]
pub struct DriverConfiguration {
Expand Down Expand Up @@ -239,7 +242,7 @@ impl<
&mut self,
consensus_commit_notification: ConsensusCommitNotification,
) -> Result<(), Error> {
debug!(
info!(
LogSchema::new(LogEntry::ConsensusNotification).message(&format!(
"Received a consensus commit notification! Total transactions: {:?}, events: {:?}",
consensus_commit_notification.transactions.len(),
Expand Down Expand Up @@ -303,7 +306,7 @@ impl<
sync_notification: ConsensusSyncNotification,
) -> Result<(), Error> {
let latest_synced_version = utils::fetch_latest_synced_version(self.storage.clone())?;
debug!(
info!(
LogSchema::new(LogEntry::ConsensusNotification).message(&format!(
"Received a consensus sync notification! Target version: {:?}. Latest synced version: {:?}",
sync_notification.target, latest_synced_version,
Expand Down Expand Up @@ -523,15 +526,21 @@ impl<
.drive_progress(consensus_sync_request)
.await
{
error!(LogSchema::new(LogEntry::Driver)
.error(&error)
.message("Error found when driving progress of the continuous syncer!"));
sample!(
SampleRate::Duration(Duration::from_secs(DRIVER_ERROR_LOG_FREQ_SECS)),
error!(LogSchema::new(LogEntry::Driver)
.error(&error)
.message("Error found when driving progress of the continuous syncer!"));
);
metrics::increment_counter(&metrics::CONTINUOUS_SYNCER_ERRORS, error.get_label());
}
} else if let Err(error) = self.bootstrapper.drive_progress(&global_data_summary).await {
error!(LogSchema::new(LogEntry::Driver)
.error(&error)
.message("Error found when checking the bootstrapper progress!"));
sample!(
SampleRate::Duration(Duration::from_secs(DRIVER_ERROR_LOG_FREQ_SECS)),
error!(LogSchema::new(LogEntry::Driver)
.error(&error)
.message("Error found when checking the bootstrapper progress!"));
);
metrics::increment_counter(&metrics::BOOTSTRAPPER_ERRORS, error.get_label());
};
}
Expand Down

0 comments on commit 4d47cac

Please sign in to comment.