Skip to content

fix(cloudfetch): bound persistent download failures - #206

Merged
vikrantpuppala merged 1 commit into
mainfrom
fix/144-bound-cloudfetch-retries
Jul 31, 2026
Merged

vikrantpuppala merged 1 commit into
mainfrom
fix/144-bound-cloudfetch-retries

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

Summary

Fix persistent CloudFetch download failures that can leave consumers blocked indefinitely.

When a request fails after its presigned URL crosses the expiry safety boundary, the provider previously skipped attempt accounting and retried with a refreshed URL. The expired-link path also retained a DashMap read guard while the refresh routine accessed the same map, which can deadlock the awaited chunk while sibling tasks continue logging retries.

This change releases the map guard before refresh and charges every completed download failure against the provider attempt budget. Transient stale-link recovery still refreshes immediately without an extra delay, but persistent failures now become terminal.

Tracks https://github.com/databricks/databricks-odbc/issues/144.

Test plan

  • Added a wiremock regression test with persistent HTTP 500 responses whose delay crosses each link expiry boundary; it asserts terminal failure after exactly two configured provider attempts.
  • cargo +stable fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • CloudFetch provider tests: 23 passed
  • cargo test: 717 passed, including doc tests

Related-pattern audit

Reviewed every production DashMap access and retry-budget bypass in the CloudFetch provider. No additional guards cross an await, and no other download failure path bypasses the hard attempt budget.

Release the chunk-map guard before refreshing expired links, and count stale-link failures against the provider attempt budget so persistent failures surface instead of hanging.

Refs databricks/databricks-odbc#144

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 — the fix is correct and well-tested. Releasing the DashMap guard via .clone() before refresh (line 612) and cloning cached_url (759-762) both avoid holding a guard across an await, and charging every download failure against the budget (729-731) correctly bounds persistent failures to exactly max_retries attempts (validated by the new wiremock test). One low-severity note inline about a last-attempt behavioral subtlety worth confirming.

// Every completed download failure consumes the hard attempt
// budget, even when its link became stale while in flight.
attempts += 1;
if attempts >= ctx.max_retries {

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 — Moving the budget check ahead of the stale-recovery continue also changes behavior for the transient concurrent-refresh case, not just persistent failures. On the final allowed attempt (attempts >= ctx.max_retries), a download whose link was legitimately refreshed by a sibling task (was_refreshed_concurrently) now returns Err(e) immediately instead of getting one retry against the fresh URL. Previously that path would continue and retry with the updated link. With a small max_retries (e.g. 2) and short-lived presigned links relative to download time, a healthy server could surface a terminal error even though a fresh URL was already available in the cache.

This appears to be an intentional consequence of "charge every completed download failure," and is arguably the correct bound — flagging only to confirm the last-attempt stale-recovery drop is deliberate rather than an unintended side effect of the reorder.

@vikrantpuppala
vikrantpuppala added this pull request to the merge queue Jul 31, 2026
Merged via the queue into main with commit 2bff8db Jul 31, 2026
19 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — b6dc6773 Deployed Jul 31, 2026 by oss-reviewer-bot[bot] via followup #216
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.

1 participant