Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 66 additions & 12 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,20 @@ fn build_proxy_config(proxy: Option<&ProxyConfig>) -> HttpProxyConfig {
/// calls must not inherit a generous `overall_timeout` (e.g. 900s) or
/// they'd hang for many minutes on an unreachable IdP. This matches the
/// legacy ADBC behaviour and is intentionally not user-overridable.
///
/// The `CloudFetch` category is capped to **no HTTP-level retries** for
/// the same reason: chunk downloads already sit inside the CloudFetch
/// provider's own retry loop (`CloudFetchConfig::max_retries`, default 5).
/// If the inner HTTP client also inherited the global budget (default 5
/// retries / 900s `overall_timeout`) the two budgets would **multiply** —
/// a permanently-failing chunk gets attempted ~30 times with escalating
/// backoff and blocks the consumer well past three minutes instead of
/// surfacing a bounded terminal error (databricks-odbc#144 / #226: the
/// `SQLFetch` drain hung 186s, over the 180s conformance bound). Making
/// the provider loop the single retry authority keeps a persistent
/// failure terminal in bounded time; one-shot transient recovery
/// (CLOUDFETCH-010/011) still works via the provider loop. Fixed, like
/// `Auth` — and not user-overridable.
fn build_retry_configs_for_session(
config: &SessionConfig,
) -> std::collections::HashMap<RequestCategory, RetryConfig> {
Expand All @@ -885,6 +899,18 @@ fn build_retry_configs_for_session(
..Default::default()
},
);
// Let the CloudFetch provider loop be the single retry authority for a
// 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.

RequestCategory::CloudFetch,
RetryConfigOverrides {
overall_timeout: Some(Duration::from_secs(20)),
max_retries: Some(0),
..Default::default()
},
);
build_retry_configs(&global, &overrides)
}

Expand Down Expand Up @@ -1134,18 +1160,46 @@ mod retry_config_tests {
};
let configs = build_retry_configs_for_session(&config_with_http(http));

// SEA + CloudFetch inherit the user-tuned global config.
for cat in [RequestCategory::Sea, RequestCategory::CloudFetch] {
let c = &configs[&cat];
assert_eq!(c.min_wait, Duration::from_secs(3), "{cat:?} min_wait");
assert_eq!(c.max_wait, Duration::from_secs(90), "{cat:?} max_wait");
assert_eq!(c.max_retries, 7, "{cat:?} max_retries");
assert_eq!(
c.overall_timeout,
Duration::from_secs(600),
"{cat:?} overall_timeout"
);
}
// SEA inherits the user-tuned global config. (CloudFetch does NOT —
// it keeps a fixed no-HTTP-retry override; see
// `cloudfetch_override_stays_fixed_regardless_of_user_knobs`.)
let c = &configs[&RequestCategory::Sea];
assert_eq!(c.min_wait, Duration::from_secs(3), "Sea min_wait");
assert_eq!(c.max_wait, Duration::from_secs(90), "Sea max_wait");
assert_eq!(c.max_retries, 7, "Sea max_retries");
assert_eq!(
c.overall_timeout,
Duration::from_secs(600),
"Sea overall_timeout"
);
}

#[test]
fn cloudfetch_override_stays_fixed_regardless_of_user_knobs() {
// CloudFetch chunk downloads nest inside the provider's own retry loop
// (`CloudFetchConfig::max_retries`). The inner HTTP client must NOT add
// a second retry budget on top — otherwise the two multiply and a
// permanently-failing chunk blocks the consumer well past the
// conformance bound (databricks-odbc#144 / #226). So — like Auth — the
// CloudFetch category keeps a fixed override no matter how generous the
// user's global retry knobs are: zero HTTP-level retries, tight
// wall-clock bound.
let http = HttpConfig {
retry_max_retries: 99,
overall_timeout: Duration::from_secs(3600),
..HttpConfig::default()
};
let configs = build_retry_configs_for_session(&config_with_http(http));
let cf = &configs[&RequestCategory::CloudFetch];
assert_eq!(
cf.max_retries, 0,
"CloudFetch must not retry at the HTTP layer"
);
assert_eq!(
cf.overall_timeout,
Duration::from_secs(20),
"CloudFetch keeps its tight wall-clock bound"
);
}

#[test]
Expand Down
Loading