Skip to content

fix(cloudfetch): bound chunk download with a per-chunk timeout (default 5m) (PECOBLR-4177) - #264

Closed
eric-wang-1990 wants to merge 4 commits into
mainfrom
eric-wang/cloudfetch-download-timeout
Closed

eric-wang-1990 wants to merge 4 commits into
mainfrom
eric-wang/cloudfetch-download-timeout

Conversation

@eric-wang-1990

@eric-wang-1990 eric-wang-1990 commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

What

Bound each CloudFetch chunk download (HTTP GET + body read) with a per-chunk deadline so a stalled cloud-storage response fails with a retriable timeout instead of hanging the result stream.

Why

The databricks-driver-test nightly Nightly Tests (Python · kernel · reyden) (run 32095064542) hung ~52 min with no output and was killed by the job's timeout-minutes: 60 — producing no error and no junit. The mitmproxy log shows it was not a connection hang: the session and query completed, then the harness's cloudfetch_timeout fault-injection scenario stalled a blob GET and the download never returned.

Root cause: ChunkDownloader::download() awaits response.bytes() with no bound. reqwest's client-level .timeout() only covers the header phase (execute()), not a separately-awaited body read — so a wedged blob read blocks indefinitely. The consumer's chunk-ready wait loop (streaming_provider.rs) treats its 30s timeout as "log and continue," so it can't rescue a stuck download either, and pytest-timeout (thread-based) can't interrupt the native call. Nothing below the 60-min CI cap ended it.

How

  • New CloudFetchConfig::download_timeout: Duration, default 5 minutes (DEFAULT_DOWNLOAD_TIMEOUT_SECS = 300), flowing through result_to_cloudfetch_config via ..Default::default().
  • ChunkDownloader takes it and wraps the GET + response.bytes() in tokio::time::timeout(download_timeout, …), returning a retriable Error::timeout() on expiry so the provider retry loop can react rather than hang.

Cross-driver parity

Driver Stall bound Type
Python (Thrift) 60s idle (between-bytes)
JDBC 900s idle (socket SO_TIMEOUT)
ADBC C# 5 min total per-download deadline (CancelAfter)
ADBC Rust none (shares this Rust CloudFetch code — same gap)
Kernel (before) none —

5 min matches the ADBC C# default. This is a total per-attempt deadline (not idle-based) for now; a public config knob and/or an idle-timeout refinement can follow. Note the shared Rust CloudFetch code in adbc-drivers/databricks has the same gap and would benefit from the same fix.

Testing (TDD)

  • Added download_times_out_when_response_stalls (wiremock: response delayed 10s, downloader timeout 200ms). RED: 10.0s hang → GREEN: ~0.2s, errors with a timeout message.
  • cargo test --lib: 804 passed. cargo clippy --all-targets clean. cargo fmt clean. cargo check --workspace clean.

Jira

Fixes PECOBLR-4177. Parent umbrella: PECOBLR-3727 (databricks-sql-kernel Reyden Support).

This pull request and its description were written by Isaac.

…lt 5m)

A stalled cloud-storage response wedged `response.bytes()` in the
CloudFetch chunk downloader indefinitely — reqwest's client-level timeout
only covers the header phase (execute()), not the separately-awaited body
read. The reyden nightly (kernel variant) hung ~52 min on a fault-injected
CloudFetch stall until the 60-min CI job cap killed it, producing no error
and no junit.

Wrap the HTTP GET + body read in tokio::time::timeout with a per-chunk
deadline (CloudFetchConfig::download_timeout, default 5 min via
DEFAULT_DOWNLOAD_TIMEOUT_SECS). On expiry it returns a retriable
Error::timeout() so the provider retry loop can react, instead of hanging.

5 min matches the ADBC C# driver's default download timeout; the Python
(Thrift) driver uses a 60s between-bytes read timeout for the same purpose.
This is a total per-attempt deadline (not idle-based) for now; a public
config knob / idle-timeout refinement can follow.

TDD: added a wiremock-backed test that a stalled response fails within the
configured timeout (RED: 10s hang -> GREEN: ~0.2s). 804 lib tests pass,
clippy --all-targets clean.

Co-authored-by: Isaac
Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
@eric-wang-1990 eric-wang-1990 changed the title fix(cloudfetch): bound chunk download with a per-chunk timeout (default 5m) fix(cloudfetch): bound chunk download with a per-chunk timeout (default 5m) (PECOBLR-4177) Aug 18, 2026

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — a minimal, well-scoped defensive fix. Bounding the GET + body read with tokio::time::timeout and returning a retriable Error::timeout() (retryable=true per kernel_error.rs:330, honored by the download_chunk_with_retry loop) is correct, the config threads through cleanly with a sensible 5-min default matching ADBC C#, and the change carries a regression test. One low-severity note on test fidelity below.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — a correct, well-scoped fix. Wrapping the GET + body read in tokio::time::timeout closes a real hang (reqwest's client timeout doesn't cover a separately-awaited response.bytes()), and I verified the three load-bearing claims: Error::timeout() is retriable (kernel_error.rs:330), the download retry loop retries on it (streaming_provider.rs:770-775), and download_timeout flows through via ..Default::default() (session.rs:1045) → reader/mod.rs:466. One low note on the regression test's fidelity to the body-read stall.

@eric-wang-1990 eric-wang-1990 added the engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up label Aug 18, 2026
Addresses:
  - #3807480172 at src/reader/cloudfetch/chunk_downloader.rs:273

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — a focused, correctly-tested CloudFetch download-timeout fix with no correctness concerns. Error::timeout() is retryable, the provider retry loop reacts to the returned error, the config threads through ..Default::default(), and tokio::time::timeout cancels the in-flight body read on expiry. One low note on the effective per-chunk bound interacting with the retry count.

Addresses:
  - #3808745445 at src/reader/cloudfetch/chunk_downloader.rs:118

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@vuanhphung

Copy link
Copy Markdown
Collaborator

https://docs.rs/reqwest/0.12.28/reqwest/struct.ClientBuilder.html#method.timeout
This says timeout() is total deadline, but the PR description says

Root cause: ChunkDownloader::download() awaits response.bytes() with no bound. reqwest's client-level .timeout() only covers the header phase (execute()), not a separately-awaited body read — so a wedged blob read blocks indefinitely

Am I missing anything?

@github-actions

Copy link
Copy Markdown

This PR has been marked as Stale because it has been open for 30 days with no activity. If you would like the PR to remain open, please remove the stale label or comment on the PR.

@github-actions github-actions Bot added the Stale label Sep 18, 2026
@github-actions

Copy link
Copy Markdown

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions Bot closed this Sep 25, 2026

This branch was previously deployed

1 inactive deployment
azure-prod — 9abe42e4 Deployed Aug 18, 2026 by oss-reviewer-bot[bot] via followup #509
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants