Repository navigation
fix(cloudfetch): stop nested retry budgets from multiplying on persistent download failures - #228
Conversation
…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>
There was a problem hiding this comment.
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.
| // 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( |
There was a problem hiding this comment.
🔵 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.
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
SQLFetchdrain 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 globalRetryConfig(default 5 retries, 1s→60s exponential backoff, 900soverall_timeout) with no CloudFetch override in production (the onlyRequestCategory::CloudFetchoverride 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
RetryConfigOverridesforRequestCategory::CloudFetchinbuild_retry_configs_for_session— zero HTTP-level retries and a 20s wall-clock bound — mirroring the pre-existingAuthfast-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. LikeAuth, it is fixed and not user-overridable (a generous globalretry_max_retriesmust 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
cloudfetch_override_stays_fixed_regardless_of_user_knobs; updatedhttp_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'spersistent_download_failure_is_bounded_when_links_expire_in_flight.cargo fmt --check,cargo clippy --lib— clean.samples.tpch.lineitemCloudFetch downloads, against a real warehouse):Http500/Http503/ConnectionReset/NormalCloudFetchSuccess) all still pass.Closes #218.
Follow-ups (separate repos)
CloudFetchTest.PersistentDownloadFailureSurfacesTerminalError) needs a small harness fix: with this change the terminal error now surfaces atSQLExecDirect(the kernel drains chunk 0 during the schema peek) rather than duringSQLFetch, so the test'srepeat_drainstep is skipped. Once fixed, flip it fromDISABLED_→ enabled and setcloudfetch.yamlodbc.seabug→implemented.KERNEL_REPO_TAGpin to pick up the fix; databricks-odbc#226 stays open until then.