Repository navigation
Commit 1282d43
committed
review(pr69): address P1/P2 feedback — stale-link, clock-skew, refresh cursors, coverage
Addresses seven review items on PR #69 (batched link refresh on
presigned-URL expiry):
### P1 — Important
1. **In-flight Downloading task uses stale-link snapshot.** The
download loop cloned `entry.link` into a local before
`downloader.download(&link).await`. If a concurrent
`refresh_links_batch` wrote a fresh URL during the .await, the
suspended download continued against the stale URL and burned a
retry attempt on the failure.
Fix: after a failed download, compare the cached link's URL to
the URL we tried. If different (refresh ran concurrently),
don't count that attempt against the retry budget — loop
immediately and pick up the fresh URL on the next iteration.
2. **Proactive `is_expired()` check spins under client clock
skew.** If the client clock is N seconds ahead, every freshly-
issued URL appears expired. Both the proactive check and the
dedupe re-check see "still expired" → RPC per
schedule_downloads iteration, bounded only by RTT.
Fix: after a successful refresh, if the link for the requested
start_chunk_index is *still* `is_expired()` per the local
clock, surface a hard error rather than loop. The error
message calls out client/server clock skew as the likely
cause, making the failure mode debuggable.
3. **`refetch_links_from` did not update link-fetcher continuation
cursors.** Unlike `fetch_links`, the refresh path inserted into
the cache but didn't touch `next_server_fetch_index` /
`next_row_offset` / `all_links_fetched`. A refresh response
carrying `next_chunk_index = None` (PR #68's end-of-stream
sentinel) was silently dropped — the prefetch loop would keep
firing past the end of the result set.
Fix: mirror the cursor-update block from `fetch_links`. Use
`fetch_max` so an early-window refresh doesn't rewind progress.
Also runs `decode_continuation` to honour the PR #68
transition-period total_chunk_count guard.
### P2 — Minor
4. **Misleading "still missing" error message.** The error only
fired when `entry.link == None`. The stale-link case (server
returned a batch not including chunk_index) hit `Some(stale)`
and silently burned retries. The new check in
`refresh_links_batch` (P1 #2 fix) catches both cases; the
download-task message is upgraded to mention clock-skew as the
alternative root cause.
5. **`refresh_batch_dedups_concurrent_calls` ran on single-threaded
runtime.** Switched to
`#[tokio::test(flavor = "multi_thread", worker_threads = 2)]`
so the TokioMutex dedupe path is exercised under genuine
contention.
6. **Test coverage gaps** — added five new tests for previously
uncovered paths:
- `refresh_batch_preserves_cancelled_and_released_states` —
terminal arms.
- `refresh_batch_inserts_new_chunk_for_window_expansion` —
the `else` branch that materialises previously-unseen
chunks.
- `refresh_batch_errors_when_server_truncates_window` — guard
against the server returning a batch missing the requested
chunk_index.
- `refresh_batch_propagates_rpc_error` — RPC-failure path.
- `refresh_batch_errors_on_stale_after_refresh_clock_skew` —
P1 #2 regression guard.
7. **`refresh_links_batch` not cancellation-aware** — documented
the behaviour: RPC runs to completion even if `cancel_token`
fires; acceptable in practice (SEA RPCs are short and on the
cancellation path no consumer is waiting); revisit if a
long-RPC transport lands.
### Tests
10 refresh-batch tests pass (5 pre-existing + 5 new). Clippy clean.
Stacked on PR #68's force-pushed tip (`bee7c1f`), so this PR is
rebased and the merge order is now PR #68 → PR #69 cleanly.
Co-authored-by: Isaac
Signed-off-by: Gopal Lal <gopal.lal@databricks.com>1 parent 4c1395c commit 1282d43
2 files changed
Lines changed: 397 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
829 | 859 | | |
830 | 860 | | |
831 | 861 | | |
| |||
0 commit comments