Skip to content

fix(cloudfetch): stop nested retry budgets from multiplying on persistent download failures - #228

Merged
vikrantpuppala merged 1 commit into
mainfrom
fix/226-cloudfetch-nested-retry-budget
Aug 10, 2026
Merged

vikrantpuppala merged 1 commit into
mainfrom
fix/226-cloudfetch-nested-retry-budget

Conversation

@vikrantpuppala

@vikrantpuppala vikrantpuppala commented Aug 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A permanently-failing CloudFetch chunk download could block the consumer well past three minutes instead of surfacing a bounded terminal error. The ODBC driver's SQLFetch drain was observed hanging 186s, over the 180s conformance bound (databricks-odbc#144 / databricks-odbc#226).

Why

#206 bounded the CloudFetch provider retry loop (CloudFetchConfig::max_retries, default 5). But each provider attempt calls the chunk downloader, which goes through the HTTP client's own retry layer — and that layer inherited the global RetryConfig (default 5 retries, 1s→60s exponential backoff, 900s overall_timeout) with no CloudFetch override in production (the only RequestCategory::CloudFetch override in-tree was a #[cfg(test)] helper).

The two budgets multiply: a permanently-broken chunk is attempted ~30 times with escalating backoff, and the HTTP layer's 900s wall-clock cap alone can dominate — well past any reasonable drain bound. #206's regression test doesn't catch this because it builds its downloader with an HTTP config of max_retries: 0, neutralizing the inner layer.

The same non-termination was reported for the Node.js and Python SEA backends on the shared conformance spec ("nested HTTP × provider retry budgets"); all three share this root cause.

Fix

Add a fixed RetryConfigOverrides for RequestCategory::CloudFetch in build_retry_configs_for_session — zero HTTP-level retries and a 20s wall-clock bound — mirroring the pre-existing Auth fast-fail override right above it. This makes the provider loop the single retry authority for a chunk download; the inner HTTP client no longer stacks a second budget on top. Like Auth, it is fixed and not user-overridable (a generous global retry_max_retries must not re-inflate it).

One-shot transient recovery (a single 500/503/connection-reset that then succeeds) still works: the provider loop refreshes the link and retries the whole download.

Test plan

  • New unit test cloudfetch_override_stays_fixed_regardless_of_user_knobs; updated http_retry_knobs_flow_into_global_config (CloudFetch no longer inherits the user-tuned global config).
  • cargo test --lib retry_config_tests: 14 passed.
  • cargo test --lib cloudfetch: 81 passed, incl. fix(cloudfetch): bound persistent download failures #206's persistent_download_failure_is_bounded_when_links_expire_in_flight.
  • cargo fmt --check, cargo clippy --lib — clean.
  • Live end-to-end via the databricks-driver-test ODBC proxy harness (mitmproxy injecting a persistent HTTP 500 on samples.tpch.lineitem CloudFetch downloads, against a real warehouse):
    • Before: the drain hung 186.2s and never terminated.
    • After: a terminal error surfaces in ~14s.
    • The CloudFetch recovery cases (Http500/Http503/ConnectionReset/NormalCloudFetchSuccess) all still pass.

Closes #218.

Follow-ups (separate repos)

  • The databricks-driver-test tripwire (CloudFetchTest.PersistentDownloadFailureSurfacesTerminalError) needs a small harness fix: with this change the terminal error now surfaces at SQLExecDirect (the kernel drains chunk 0 during the schema peek) rather than during SQLFetch, so the test's repeat_drain step is skipped. Once fixed, flip it from DISABLED_ → enabled and set cloudfetch.yaml odbc.sea bug → implemented.
  • After this merges, bump the databricks-odbc KERNEL_REPO_TAG pin to pick up the fix; databricks-odbc#226 stays open until then.

…tent download failures

A permanently-failing CloudFetch chunk download could block the consumer
well past three minutes instead of surfacing a bounded terminal error —
the SQLFetch drain of the ODBC driver was observed hanging 186s, over the
180s conformance bound (databricks-odbc#144 / #226).

## Why

#206 bounded the CloudFetch *provider* retry loop
(`CloudFetchConfig::max_retries`, default 5). But each provider attempt
calls the chunk downloader, which goes through the HTTP client's own
retry layer — and that layer inherited the global `RetryConfig` (default
5 retries, 1s→60s exponential backoff, 900s overall_timeout) with no
CloudFetch override in production. The two budgets multiply: a
permanently-broken chunk is attempted ~30 times with escalating backoff,
and the HTTP layer's 900s wall-clock cap alone can dominate. #206's
regression test does not catch this because it builds its downloader with
an HTTP config of `max_retries: 0`, neutralizing the inner layer.

The same non-termination was reported for the Node.js and Python SEA
backends on the shared conformance spec ("nested HTTP × provider retry
budgets"); all three share this root cause.

## Fix

Add a fixed `RetryConfigOverrides` for `RequestCategory::CloudFetch` in
`build_retry_configs_for_session` — zero HTTP-level retries and a 20s
wall-clock bound — mirroring the pre-existing `Auth` fast-fail override
right above it. This makes the provider loop the single retry authority
for a chunk download; the inner HTTP client no longer stacks a second
budget on top. Like `Auth`, it is fixed and not user-overridable (a
generous global `retry_max_retries` must not re-inflate it).

One-shot transient recovery (a single 500/503/connection-reset that then
succeeds) still works: the provider loop refreshes the link and retries
the whole download.

## Test plan

- New unit test `cloudfetch_override_stays_fixed_regardless_of_user_knobs`
  and updated `http_retry_knobs_flow_into_global_config` (CloudFetch no
  longer inherits the user-tuned global config).
- `cargo test --lib retry_config_tests`: 14 passed.
- `cargo test --lib cloudfetch`: 81 passed, incl. #206's
  `persistent_download_failure_is_bounded_when_links_expire_in_flight`.
- `cargo fmt --check`, `cargo clippy --lib` (clean).
- Live end-to-end via the databricks-driver-test ODBC proxy harness
  (mitmproxy persistent HTTP 500 on samples.tpch.lineitem CloudFetch
  downloads, real warehouse): before this change the drain hung 186.2s
  and never terminated; after it, a terminal error surfaces in ~14s. The
  CloudFetch recovery cases (Http500/Http503/ConnectionReset/Normal) all
  still pass.

Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.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 correct, well-scoped, well-tested fix. Making the CloudFetch category fixed at max_retries: 0 (mirroring Auth) removes the nested HTTP×provider retry multiplication; CloudFetchDownload is the only request type in this category, refresh RPCs stay on the SEA budget, and the provider loop preserves one-shot transient recovery. One low-severity note that the accompanying 20s overall_timeout is effectively inert with zero retries.

Comment thread src/session.rs
// chunk download (see the doc comment above): no HTTP-level retries, and
// a tight wall-clock bound so a stuck download can't inherit the global
// 900s `overall_timeout`.
overrides.insert(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — The overall_timeout: Some(Duration::from_secs(20)) here is effectively inert given max_retries: Some(0). In the HTTP retry loop (src/client/http.rs:775-950), overall_timeout is only consulted before scheduling a retry wait (guarded by attempts < max_attempts). With max_retries = 0, max_attempts = 1, so the loop never enters the retry branch and never reads overall_timeout. The wall-clock bound on a single stuck/hanging CloudFetch attempt is therefore HttpConfig::read_timeout (60s default, src/client/http.rs:298) — not 20s.

So the doc comment's framing ("a tight wall-clock bound so a stuck download can't inherit the global 900s overall_timeout") is slightly misleading: it is max_retries = 0 that eliminates the 900s inheritance, not the 20s cap. For the reported bug (fast HTTP 500s) this is fine — termination is bounded by the provider's max_retries loop. But a download that hangs (no response) is still bounded per-attempt by read_timeout (up to 60s), times the provider's attempts, which the 20s number implies but does not enforce.

Not a correctness bug — the 20s is harmless defense-in-depth should the max_retries value ever change. Worth either a clarifying comment (the real bound is max_retries=0) or dropping the value to avoid implying a guarantee it doesn't provide.

@vikrantpuppala
vikrantpuppala added this pull request to the merge queue Aug 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 10, 2026
@vikrantpuppala
vikrantpuppala added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 54ff10a Aug 10, 2026
19 checks passed

This branch was previously deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[coverage] Conformance findings: CLOUDFETCH-017

1 participant