mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-11 23:45:05 -05:00
chore(exex): emit warn log when WAL grows beyond a certain number of blocks (#12634)
This commit is contained in:
@@ -10,7 +10,7 @@ use reth_chainspec::Head;
|
||||
use reth_metrics::{metrics::Counter, Metrics};
|
||||
use reth_primitives::SealedHeader;
|
||||
use reth_provider::HeaderProvider;
|
||||
use reth_tracing::tracing::debug;
|
||||
use reth_tracing::tracing::{debug, warn};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
fmt::Debug,
|
||||
@@ -35,6 +35,12 @@ use tokio_util::sync::{PollSendError, PollSender, ReusableBoxFuture};
|
||||
/// or 17 minutes of 1-second blocks.
|
||||
pub const DEFAULT_EXEX_MANAGER_CAPACITY: usize = 1024;
|
||||
|
||||
/// The maximum number of blocks allowed in the WAL before emitting a warning.
|
||||
///
|
||||
/// This constant defines the threshold for the Write-Ahead Log (WAL) size. If the number of blocks
|
||||
/// in the WAL exceeds this limit, a warning is logged to indicate potential issues.
|
||||
pub const WAL_BLOCKS_WARNING: usize = 128;
|
||||
|
||||
/// The source of the notification.
|
||||
///
|
||||
/// This distinguishment is needed to not commit any pipeline notificatations to [WAL](`Wal`),
|
||||
@@ -377,6 +383,13 @@ where
|
||||
.unwrap();
|
||||
|
||||
self.wal.finalize(lowest_finished_height)?;
|
||||
if self.wal.num_blocks() > WAL_BLOCKS_WARNING {
|
||||
warn!(
|
||||
target: "exex::manager",
|
||||
blocks = ?self.wal.num_blocks(),
|
||||
"WAL contains too many blocks and is not getting cleared. That will lead to increased disk space usage. Check that you emit the FinishedHeight event from your ExExes."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let unfinalized_exexes = exex_finished_heights
|
||||
.into_iter()
|
||||
|
||||
@@ -35,6 +35,11 @@ impl BlockCache {
|
||||
self.notification_max_blocks.is_empty()
|
||||
}
|
||||
|
||||
/// Returns the number of blocks in the cache.
|
||||
pub(super) fn num_blocks(&self) -> usize {
|
||||
self.committed_blocks.len()
|
||||
}
|
||||
|
||||
/// Removes all files from the cache that has notifications with a tip block less than or equal
|
||||
/// to the given block number.
|
||||
///
|
||||
|
||||
@@ -66,6 +66,11 @@ impl Wal {
|
||||
) -> eyre::Result<Box<dyn Iterator<Item = eyre::Result<ExExNotification>> + '_>> {
|
||||
self.inner.iter_notifications()
|
||||
}
|
||||
|
||||
/// Returns the number of blocks in the WAL.
|
||||
pub fn num_blocks(&self) -> usize {
|
||||
self.inner.block_cache().num_blocks()
|
||||
}
|
||||
}
|
||||
|
||||
/// Inner type for the WAL.
|
||||
|
||||
Reference in New Issue
Block a user