Repository navigation
fix(cloudfetch): keep link prefetch ahead of downloads - #466
aakash-saravanan-db merged 9 commits into
Conversation
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
There was a problem hiding this comment.
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.
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
There was a problem hiding this comment.
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.
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
There was a problem hiding this comment.
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.
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
There was a problem hiding this comment.
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 whenhas_moreisfalse. The other return paths in this function, and the removed code, reportNoneonce the stream is exhausted (streaming_provider tests assertresult.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 byfetch_page. It holds anArcto the fetcher and is not tied tocancel_token, so aftercancel()or close it still finishesGetResultChunksand logserror!on failure.note_scheduledcan 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 intoSeaChunkLinkFetcherso detached page fetches and prefetch stop after the provider is cancelled.
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 --releasepasses (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.