mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
fix(stages): clear ETL collectors on HeaderStage error paths (#21258)
This commit is contained in:
@@ -86,6 +86,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear all ETL state. Called on error paths to prevent buffer pollution on retry.
|
||||
fn clear_etl_state(&mut self) {
|
||||
self.sync_gap = None;
|
||||
self.hash_collector.clear();
|
||||
self.header_collector.clear();
|
||||
self.is_etl_ready = false;
|
||||
}
|
||||
|
||||
/// Write downloaded headers to storage from ETL.
|
||||
///
|
||||
/// Writes to static files ( `Header | HeaderTD | HeaderHash` ) and [`tables::HeaderNumbers`]
|
||||
@@ -258,7 +266,7 @@ where
|
||||
}
|
||||
Some(Err(HeadersDownloaderError::DetachedHead { local_head, header, error })) => {
|
||||
error!(target: "sync::stages::headers", %error, "Cannot attach header to head");
|
||||
self.sync_gap = None;
|
||||
self.clear_etl_state();
|
||||
return Poll::Ready(Err(StageError::DetachedHead {
|
||||
local_head: Box::new(local_head.block_with_parent()),
|
||||
header: Box::new(header.block_with_parent()),
|
||||
@@ -266,7 +274,7 @@ where
|
||||
}))
|
||||
}
|
||||
None => {
|
||||
self.sync_gap = None;
|
||||
self.clear_etl_state();
|
||||
return Poll::Ready(Err(StageError::ChannelClosed))
|
||||
}
|
||||
}
|
||||
@@ -324,7 +332,7 @@ where
|
||||
provider: &Provider,
|
||||
input: UnwindInput,
|
||||
) -> Result<UnwindOutput, StageError> {
|
||||
self.sync_gap.take();
|
||||
self.clear_etl_state();
|
||||
|
||||
// First unwind the db tables, until the unwind_to block number. use the walker to unwind
|
||||
// HeaderNumbers based on the index in CanonicalHeaders
|
||||
|
||||
Reference in New Issue
Block a user