fix(tasks): add panic handler to proof worker rayon pools

Without a panic handler, a panic on the dedicated proof-acct or
proof-strg rayon pools aborts the process. Install a handler that logs
the panic instead, matching the behavior of the global pool.

Co-Authored-By: Arsenii Kulikov <62447812+klkvr@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019cdfbe-823d-735d-a7f9-a0e9750e22a7
This commit is contained in:
Derek Cofausper
2026-03-12 02:01:36 +00:00
parent bef3d7b4d1
commit 37f5b3a110

View File

@@ -816,6 +816,17 @@ impl RuntimeBuilder {
let (task_manager, on_shutdown, task_events_tx, graceful_tasks) =
TaskManager::new_parts(handle.clone());
#[cfg(feature = "rayon")]
#[allow(clippy::needless_pass_by_value)]
fn rayon_panic_handler(payload: Box<dyn std::any::Any + Send>) {
let msg = payload
.downcast_ref::<&str>()
.copied()
.or_else(|| payload.downcast_ref::<String>().map(|s| s.as_str()))
.unwrap_or("(no message)");
error!(target: "reth::tasks", %msg, "panic in worker pool thread");
}
#[cfg(feature = "rayon")]
let (
cpu_pool,
@@ -853,6 +864,7 @@ impl RuntimeBuilder {
let proof_storage_worker_pool = rayon::ThreadPoolBuilder::new()
.num_threads(proof_storage_worker_threads)
.thread_name(|i| format!("proof-strg-{i:02}"))
.panic_handler(rayon_panic_handler)
.build()?;
let proof_account_worker_threads =
@@ -860,6 +872,7 @@ impl RuntimeBuilder {
let proof_account_worker_pool = rayon::ThreadPoolBuilder::new()
.num_threads(proof_account_worker_threads)
.thread_name(|i| format!("proof-acct-{i:02}"))
.panic_handler(rayon_panic_handler)
.build()?;
debug!(