Skip to content

fix(cloudfetch): keep link prefetch ahead of downloads - #466

Merged
aakash-saravanan-db merged 9 commits into
mainfrom
aakash-saravanan_data/fix/cloudfetch-link-prefetch-20261114
Nov 17, 2026
Merged

aakash-saravanan-db merged 9 commits into
mainfrom
aakash-saravanan_data/fix/cloudfetch-link-prefetch-20261114

Conversation

@aakash-saravanan-db

@aakash-saravanan-db aakash-saravanan-db commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Feature or gap

CloudFetch link prefetch could stop advancing while cached links were being downloaded, leaving later downloads waiting at page boundaries. Cache misses could duplicate an in-flight page request, and concurrent final-page completion could report end-of-stream before returning the cached tail, ending results early.

What this PR addresses

Advance bounded link prefetch when downloads are scheduled and preserve scheduling notifications as prefetch catches up. Share each in-flight page's success or error with readers waiting for that page, and let provider cancellation interrupt initial and refill link waits. Reject nonempty, nonterminal pages that do not advance pagination, and return the complete cached tail before reporting end-of-stream. Background failures do not immediately retry; later requests or scheduling can restart progress.

Dependencies

None. Drivers receive the fix through a kernel release that includes it.

Tests and validation

cargo test --locked --release passes (1,315 tests, including 104 CloudFetch tests), along with formatting and Clippy. Rebuilt Python, async Node.js and Go pass multi-page live workloads with a one-chunk window, complete ordered results, no duplicate page requests, and reuse/close.

Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@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 overall, with one low-severity concern: a lost-wakeup race at the end of the prefetch loop. When it hits, the new note_scheduled signal is dropped; results stay correct but the reader can wait at a page boundary. Locking a page per loop iteration lets a waiting reader reuse a page that was just fetched (the Tokio mutex is FIFO), and the tests cover both the success and failure paths. Nit: the new trait method note_scheduled has a // comment rather than a /// doc comment, so its explanation won't appear in rustdoc.

Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Signed-off-by: Aakash Saravanan <aakash.saravanan@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. I found one low-severity doc issue. The new scheduling flow holds up: the threshold check moved ahead of the claim, the release-then-recheck in release_caught_up_prefetch uses SeqCst ordering, and the page-scoped prefetch_lock that a foreground miss waits on is FIFO. Together these keep scheduling notifications from being lost and keep a waiting reader from requesting a page twice. Nit: the module docs at link_fetcher.rs:37-41 still say the consumer position only moves when a link is requested; it now also moves when a download is scheduled.

Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Signed-off-by: Aakash Saravanan <aakash.saravanan@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 Medium · 2 Low

The approach is sound, with one medium concern: a reader that joins a fetch for a different page can stop early and miss its own page. Two low issues: the spawned page request keeps running after cancellation, and one prefetch exit path drops scheduling notifications.

Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Signed-off-by: Aakash Saravanan <aakash.saravanan@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 Medium · 1 Low · 2 Nit

The overall design is sound: one shared in-flight page per fetcher, scheduling that keeps prefetch moving, and link waits that can be cancelled. I found one medium robustness issue (a panic in the spawned page task leaves the shared slot stuck and blocks every later link fetch) and a few low-severity contract and termination edge cases.

Other findings

  • ⚪ Nit — The cache-miss return now always sets next_chunk_index: Some(next_server_fetch_index), even when has_more is false. The other return paths in this function, and the removed code, report None once the stream is exhausted (streaming_provider tests assert result.next_chunk_index.is_none() alongside !has_more). Keep the contract consistent: next_chunk_index: has_more.then(|| ...).
  • ⚪ Nit — The new select! only drops the waiter. The page RPC itself runs in a detached task spawned by fetch_page. It holds an Arc to the fetcher and is not tied to cancel_token, so after cancel() or close it still finishes GetResultChunks and logs error! on failure. note_scheduled can also start new prefetch loops that ignore cancellation. This is acceptable if intended, but the PR says cancellation "interrupts" link waits. Consider passing a cancellation token into SeaChunkLinkFetcher so detached page fetches and prefetch stop after the provider is cancelled.

Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Signed-off-by: Aakash Saravanan <aakash.saravanan@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 Medium

Overall the change looks solid, with one medium robustness concern: a page-fetch task that panics or is aborted leaves a stale in-flight slot, and every later link fetch for that statement then fails. The new same-page sharing, scheduling-driven prefetch and cancellation selects are otherwise consistent, and the tests exercise them.

Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved

@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 Medium · 2 Low

The main concurrency design is sound, with one medium concern: removing the synchronous server fallback means a chunk missing from the cache below the fetch cursor is never requested again. There are also two low-severity lifecycle/notification gaps in the new page-fetch and prefetch-release paths.

Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved
Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved

@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 Medium

Mostly sound. The shared in-flight page, the prefetch hand-off and the cancellation wiring look correct, and the tests cover them. One medium concern: if the background page-fetch task panics or is aborted, it leaves the shared page_fetch slot set with no result, and every later link fetch for the statement fails.

Comment thread src/reader/cloudfetch/link_fetcher.rs Resolved

This branch was previously deployed

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

Labels

skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants