From c91508ddf0529ba0243f454c8b205b3bfad4db73 Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Wed, 12 Aug 2026 08:56:08 -0700 Subject: [PATCH 1/3] fix(cloudfetch): bump twox-hash to 2.1.3 and surface panicking download tasks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The nightly large-result CloudFetch tests hung until the 2h CI cap because twox-hash 2.1.2's xxhash32 finalization uses a non-wrapping `+` that overflows and PANICS under debug `overflow-checks`, while lz4_flex 0.14 verifies the LZ4 block checksum during chunk decompression (data-dependent, so a random chunk trips it). The panic happened inside a fire-and-forget download task, so tokio swallowed it — the chunk stayed `Downloading` forever and the whole stream wedged. Release builds wrap correctly, so this was debug/CI-only. - Bump twox-hash 2.1.2 -> 2.1.3 (fixes the overflow). - Await the download task's JoinHandle from a supervisor task so a panic becomes a JoinError we surface as a failed chunk, instead of a silent hang. PECOBLR-4026 Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- Cargo.lock | 4 ++-- src/reader/cloudfetch/streaming_provider.rs | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db2145b8..e3eb7560 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2436,9 +2436,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "twox-hash" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" +checksum = "8464ec13c3691491391d9fce00f6416c9a48e46972f72d7865688be2080192c9" [[package]] name = "typenum" diff --git a/src/reader/cloudfetch/streaming_provider.rs b/src/reader/cloudfetch/streaming_provider.rs index 5f32cb03..133dcc81 100644 --- a/src/reader/cloudfetch/streaming_provider.rs +++ b/src/reader/cloudfetch/streaming_provider.rs @@ -539,8 +539,26 @@ impl StreamingCloudFetchProvider { let chunks = self.chunks.clone(); let batch_merge_target_rows = self.config.batch_merge_target_rows; + // Run the download on its own task and AWAIT its JoinHandle here. + // tokio turns a panic inside a spawned task into a `JoinError` — but + // only if the handle is awaited. The prior fire-and-forget spawn dropped + // the handle, so a panic in the download/decompress path (e.g. the + // twox-hash overflow in LZ4 block-checksum verification — PECOBLR-4026) + // was silently swallowed, leaving the chunk stuck in `Downloading` + // forever and wedging the whole stream. Surfacing the panic as a + // download error lets the reader fail cleanly instead of hanging. + let rt = self.runtime_handle.clone(); self.runtime_handle.spawn(async move { - let result = Self::download_chunk_with_retry(chunk_index, &ctx).await; + let download = + rt.spawn(async move { Self::download_chunk_with_retry(chunk_index, &ctx).await }); + let result = match download.await { + Ok(r) => r, + Err(join_err) => { + error!("Download task for chunk {} panicked: {}", chunk_index, join_err); + Err(Error::io() + .message(format!("download task panicked: {}", join_err))) + } + }; match result { Ok(batches) => { From adcbb4ef275ade00a2b7abec5ddd5b0b0c862af0 Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Wed, 12 Aug 2026 09:47:50 -0700 Subject: [PATCH 2/3] test(cloudfetch): regression test for download-task panic surfacing Extract the spawn-and-join logic into `join_download_task` and add a unit test asserting that a panicking download task surfaces as an error (not a swallowed panic that leaves the chunk stuck `Downloading` and wedges the stream). Locks in the PECOBLR-4026 defensive fix so a future regression is caught in CI. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- src/reader/cloudfetch/streaming_provider.rs | 56 +++++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/src/reader/cloudfetch/streaming_provider.rs b/src/reader/cloudfetch/streaming_provider.rs index 133dcc81..6298eb3e 100644 --- a/src/reader/cloudfetch/streaming_provider.rs +++ b/src/reader/cloudfetch/streaming_provider.rs @@ -216,6 +216,30 @@ impl std::fmt::Debug for StreamingCloudFetchProvider { } } +/// Spawn a download future on `runtime_handle` and await its `JoinHandle`, +/// converting a task panic (`JoinError`) into an ordinary error. +/// +/// tokio turns a panic inside a spawned task into a `JoinError`, but only if the +/// handle is awaited. A detached (fire-and-forget) download task that panics is +/// silently swallowed — its chunk then stays `Downloading` forever and the whole +/// stream wedges (PECOBLR-4026). Routing every chunk download through this helper +/// guarantees a panic surfaces as a failed chunk instead of an indefinite hang. +async fn join_download_task( + runtime_handle: &tokio::runtime::Handle, + fut: F, +) -> Result> +where + F: std::future::Future>> + Send + 'static, +{ + match runtime_handle.spawn(fut).await { + Ok(result) => result, + Err(join_err) => { + error!("CloudFetch download task panicked: {}", join_err); + Err(Error::io().message(format!("download task panicked: {}", join_err))) + } + } +} + impl StreamingCloudFetchProvider { /// Create a new provider. /// @@ -549,16 +573,10 @@ impl StreamingCloudFetchProvider { // download error lets the reader fail cleanly instead of hanging. let rt = self.runtime_handle.clone(); self.runtime_handle.spawn(async move { - let download = - rt.spawn(async move { Self::download_chunk_with_retry(chunk_index, &ctx).await }); - let result = match download.await { - Ok(r) => r, - Err(join_err) => { - error!("Download task for chunk {} panicked: {}", chunk_index, join_err); - Err(Error::io() - .message(format!("download task panicked: {}", join_err))) - } - }; + let result = join_download_task(&rt, async move { + Self::download_chunk_with_retry(chunk_index, &ctx).await + }) + .await; match result { Ok(batches) => { @@ -1374,6 +1392,24 @@ mod tests { } } + /// Regression (PECOBLR-4026): a panicking download task must surface as an + /// error rather than being silently swallowed — a swallowed panic leaves the + /// chunk stuck `Downloading` and wedges the stream forever. Verifies + /// `join_download_task` converts a task panic into an error. + #[tokio::test] + async fn panicking_download_task_surfaces_as_error() { + let handle = tokio::runtime::Handle::current(); + let result = join_download_task(&handle, async { + panic!("simulated download-task panic"); + }) + .await; + let err = result.expect_err("a panicking download task must yield an error, not Ok"); + assert!( + err.to_string().contains("download task panicked"), + "error should identify a panicked download task, got: {err}" + ); + } + #[tokio::test] async fn persistent_download_failure_is_bounded_when_links_expire_in_flight() { use crate::client::retry::{build_retry_configs, RetryConfig}; From bbf4c7a074620812dad0a2dfd79685cef13b6fd9 Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" Date: Wed, 12 Aug 2026 20:04:30 +0000 Subject: [PATCH 3/3] ai: apply changes for #243 (1 review thread) Addresses: - #3769905194 at src/reader/cloudfetch/streaming_provider.rs:574 Signed-off-by: peco-engineer-bot[bot] --- src/reader/cloudfetch/streaming_provider.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/reader/cloudfetch/streaming_provider.rs b/src/reader/cloudfetch/streaming_provider.rs index 6298eb3e..4de607eb 100644 --- a/src/reader/cloudfetch/streaming_provider.rs +++ b/src/reader/cloudfetch/streaming_provider.rs @@ -224,6 +224,14 @@ impl std::fmt::Debug for StreamingCloudFetchProvider { /// silently swallowed — its chunk then stays `Downloading` forever and the whole /// stream wedges (PECOBLR-4026). Routing every chunk download through this helper /// guarantees a panic surfaces as a failed chunk instead of an indefinite hang. +/// +/// Note: this spawns a second (inner) task and awaits its handle, so each chunk +/// download uses two tasks — the outer scheduling task and this inner one. That +/// decouples the download from the outer task: if the outer task were aborted +/// mid-`await`, the inner download would keep running detached. This is not a leak +/// today because nothing `abort()`s these tasks — cancellation is cooperative via +/// `cancel_token`, checked inside `download_chunk_with_retry`. The extra task is +/// the price of capturing a `JoinError`; keep this invariant if adding `abort()`. async fn join_download_task( runtime_handle: &tokio::runtime::Handle, fut: F,