Adding panic handler for the rayon merge thread pool

This commit is contained in:
Paul Masurel
2025-02-19 17:19:28 +09:00
parent 71cf19870b
commit 82b510b88b

View File

@@ -287,6 +287,17 @@ impl SegmentUpdater {
let merge_thread_pool = ThreadPoolBuilder::new()
.thread_name(|i| format!("merge_thread_{i}"))
.num_threads(num_merge_threads)
.panic_handler(move |panic| {
let message = if let Some(msg) = panic.downcast_ref::<&str>() {
*msg
} else if let Some(msg) = panic.downcast_ref::<String>() {
msg.as_str()
} else {
"UNKNOWN"
};
eprintln!("merge thread panicked with: {message}")
})
.build()
.map_err(|_| {
crate::TantivyError::SystemError(