Skip to content

feat: re-fetch expired Thrift CloudFetch links - #586

Open
vuanhphung wants to merge 1 commit into
mainfrom
feat/issue-475-cloudfetch-link-refetch
Open

vuanhphung wants to merge 1 commit into
mainfrom
feat/issue-475-cloudfetch-link-refetch

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Expired Thrift CloudFetch links fail large or slow reads; the existing seconds-based expiry check also misses the server's epoch-millisecond timestamps. Re-fetch links on the consumer path under the operation lock, using the original operation and absolute row offsets. Renew the remaining page with bounded partial-response follow-ups, preserve completed downloads, and restart renewed downloads in parallel across rows, Arrow batches and IPC.

Use milliseconds and a 30-second buffer only when renewal is possible, honoring larger internal buffers. Near-expiry HTTP 400/403s can renew, following the kernel's stale-link recovery; unexpired failures keep normal download handling. Local expiry alone never fails a read: storage still decides validity under clock skew. Final CloudFetch operations now remain open until consumption/Close; cancellation stops renewal and terminal errors preserve download causes plus bounded, redacted renewal errors. Operations that cannot renew retain the existing download error. No new public option or required interface member.

Verified on v2.0.0 (73b9a3a): lint clean; uncached make test 1,900 tests/15 credential-gated skips in 54.055s versus 58.821s before trimming (4.766s saved); pure-Go build, root/rows race tests, and full kernel-tagged build/tests on default Go 1.27.4 with bindings v1.5.0. Renewal/millisecond regressions fail on main; the new closed-operation 503 test fails before the correction and passes on main. Three live Thrift tests pass without skips (47.858s): each API preserves 2M ordered IDs/checksum 1,999,999,000,000, with zero versus one renewal; three-page IPC preserves 8.5M/checksum 36,124,995,750,000 and cursor restoration. Live timings use a shared warehouse. The three generated-file formatting exceptions also occur on main. Shared CLOUDFETCH-001 still XFAILs on its injected HTTP 401, not timestamp expiry; it is not counted as passing coverage.

Benchstat uses identical overlays, three alternating fresh processes/version and six 500ms samples/process (n=18/case/version). The disclosed v2 rebase sweep below reaches +7.07% loopback overhead (small IPC, p<.001); large batches measure +5.36%. A fresh sweep measures loopback rows 254.0→264.0 µs (+3.93%, p<.001), with other loopback differences not significant (p≥.051). Memory overhead is +2.72/+2.79/+4.79% for small rows/batches/IPC; large rows +2.66%, batches -2.14%, IPC -3.16%. These microbenchmarks do not establish zero overhead; tiny results retain roughly 0.8–1.2 KiB and 10–12 extra allocations. Percentages in the retained table denote p<.05; other differences are not significant.

No-expiry workload Memory main → branch Loopback main → branch
6×3 rows 59.41 → 60.14 µs (+1.24%) 257.5 → 261.9 µs
6×3 batches 58.31 → 58.14 µs 258.0 → 264.1 µs (+2.36%)
6×3 IPC 54.01 → 54.37 µs 253.0 → 270.9 µs (+7.07%)
32×1000 rows 3.090 → 3.095 ms 4.103 → 4.232 ms (+3.14%)
32×1000 batches 1.324 → 1.301 ms (-1.79%) 3.533 → 3.722 ms (+5.36%)
32×1000 IPC 1.296 → 1.249 ms (-3.57%) 3.530 → 3.641 ms

Cross-driver state

Driver State Notes
JDBC Supported Internal 60s buffer; ChunkLinkDownloadService.java:363 @0ad7a49; strict milliseconds, DatabricksHttpException.
Python Partial (SEA) Thrift buffer 0, terminal Error; downloader.py:57,181 @087b2bf. SEA uses kernel.
Go Partial → Supported Thrift renews with max(30s, internal MinTimeToExpiry=0); existing DriverError/expiry matching retained. SEA unchanged.
Node.js Partial (SEA) Thrift milliseconds, no buffer, terminal Error; CloudFetchResultHandler.ts:125 @abedbbf. SEA uses kernel.
Kernel Supported Internal 30s buffer, batched renewal, kernel_error::Error; link_fetcher.rs:120, types/cloudfetch.rs:30 @fe52b66.

Follow JDBC's Thrift offset/range contract and the kernel's 30s buffer. Storage fallback avoids clock-skew-only failures. Sibling #565/#587 changes are not included.

Addresses #475 (part 3)

This pull request and its description were written by Isaac.

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

🔀 1 finding considered and dismissed by the judge
  • 🟡 Medium internal/rows/arrowbased/batchloader.go:652 — When renewal is unavailable (renewalBuffer==0, e.g. direct results with CloseOperation), a locally-expired link now gets a GET, and the storage 403 falls throug
    Judge's evidence: if res.StatusCode == http.StatusForbidden && renewalBuffer > 0 && isLinkExpired(link.ExpiryTime, renewalBuffer) {

@vuanhphung
vuanhphung force-pushed the feat/issue-475-cloudfetch-link-refetch branch from e02272c to 8c6a337 Compare November 23, 2026 22:52

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Low

Looks good, no blocking concerns. I traced renewal locking, how the operation lifecycle closes, cancellation, and redaction across the rows, batches and IPC paths. Nit: after Close, cloudIPCStreamIterator.Next now returns context.Canceled instead of io.EOF. Every caller I checked stops before calling it.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

return task, nil, 0, refetchErr
}
renewalFailure = refetchErr
if lastDownloadErr == nil && lastStatus == 0 {

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 — When a retryable GET failure is followed by backoff into the expiry buffer and the renewal RPC then fails, recoverExpiredDownload returns the error. The saved download cause or status blocks the fallback to the original URL, even though retries remain and storage may still accept the URL under clock skew. Track whether the download was interrupted rather than exhausted, and resume the original URL within its remaining retry budget. This is a narrow edge case.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as follow-up under the approved D27 scope. A real GET failure has already occurred and the renewal RPC also failed; this is not a failure based only on the local clock. The same stop condition exists at 8c6a337 (lastDownloadErr == nil gates fallback in recoverExpiredDownload). Preserving a partially consumed GET retry budget would add recovery state/semantics beyond this scope correction. The last download cause/status and renewal RPC error remain visible.


This comment was generated with GitHub MCP.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open at 08c0893: batchloader.go:300 still skips the original-URL fallback after a GET failure even when retries remain; deferring it is fine.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Checked the overview nit about Next after Close: this is the internal CloudFetch iterator reporting the cancellation needed to stop in-flight work; the public rows/batch/IPC consumers stop before calling it after Close. Leaving that internal behavior unchanged rather than widening this scope round.


This comment was generated with GitHub MCP.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

The kernel CI job exited with native SIGPIPE during the unchanged unsupported-inline/TLS cleanup. Reproduced on untouched main 73b9a3a with GOTOOLCHAIN=go1.27.3 CGO_ENABLED=1 go test -tags databricks_kernel -count=100 -run '^TestKernelCloudFetchDisabledPreservesUnsupportedServerError$' .: the same TLS-close diagnostic followed by signal: broken pipe (0.373s). The full local tagged suite passes on default Go 1.27.4. Reran the failed CI job once; keeping this unrelated native teardown issue out of the PR.


This comment was generated with GitHub MCP.

Honor millisecond expiry and renew pending page links on the consumer
path with a 30-second buffer, bounded retries, and preserved error causes.
Let storage decide validity under clock skew.

Keep final CloudFetch operations open until consumption or Close so long
reads can renew links. No public API or option changes.

Addresses #475 (part 3)

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@vuanhphung
vuanhphung force-pushed the feat/issue-475-cloudfetch-link-refetch branch from 08c0893 to 904ff85 Compare November 24, 2026 00:17

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

This branch has not been deployed

No deployments
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