Skip to content

fix: bound Thrift CloudFetch downloads with ClientTimeout - #587

Open
vuanhphung wants to merge 1 commit into
mainfrom
fix/issue-475-cloudfetch-download-timeout
Open

vuanhphung wants to merge 1 commit into
mainfrom
fix/issue-475-cloudfetch-download-timeout

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Thrift CloudFetch downloads could wait indefinitely for headers or body data. Apply the existing 900s ClientTimeout per whole-transfer attempt: cap a copy of http.DefaultClient, preserving its transport pool, cookies, redirects and shorter timeout, and construct WithTransport clients after options. CloudFetch now uses the last WithTransport, as Thrift already did. No new option or API; rebased onto v2.0.0.

The bound includes continuously progressing transfers, not just inactivity; existing retries can extend total elapsed time beyond 900s. Omit the link's presigned query string from Thrift download errors/logs while retaining typed causes. Kernel v1.5.0 already redacts its own errors and is unchanged. Expiry/re-fetch and final expiry diagnostics remain in #586.

Verification: reduced regressions still fail on origin/main and pass here: default-client header/body stalls, a distinct stalling WithTransport, option order, default-client settings and error redaction. Unit (1,837 tests; ten envless credential skips), lint, build/vet, root race, five Arrow-package race runs and kernel-tagged build/targeted tests pass on Go1.27.4. All three affected live Thrift tests pass without skips (5.755s; 2M default-client rows and 300K WithTransport rows). Three generated-file gofmt exceptions match main.

Download benchmark, 5MiB: no measurable timing change across reruns (both directions observed); about 1 KiB and 10–11 extra allocations per file. Live warehouse timings are shared-worker correctness measurements.

Cross-driver state

Driver State Notes
JDBC Supported socketTimeout=900s, inactivity; DatabricksHttpClient.java:148 @0ad7a49; DatabricksSQLException.
Python Supported Internal download_timeout=60s, inactivity; cloudfetch/downloader.py:58 @087b2bf; RequestError.
Go Thrift Not supported → Supported Existing ClientTimeout=900s, whole transfer per attempt; batchloader.go:62; deadline cause retained.
Node.js Supported retriesTimeout=15min, total file budget; CloudFetchResultHandler.ts:160 @abedbbf; RetryError.
Kernel Supported, unchanged Fixed 20s chunk budget and query redaction; session.rs:1134, client/http.rs:1024 @1aa8d8a (v1.5.0); ErrorCode::Timeout.

Follow the general request-setting model with Node/kernel-like whole-transfer semantics, retaining Go's per-attempt retry scope rather than changing its retry policy.

Adversarial review: converged with zero open highs; all scope reductions applied, bot approved, and duplicate pre-existing hardening threads resolved as out of scope.

Addresses #475 (part 2)

This pull request and its description were written by Isaac.

@vuanhphung
vuanhphung marked this pull request as ready for review November 20, 2026 07:20

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

@vuanhphung vuanhphung added the skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test) label Nov 20, 2026
@vuanhphung
vuanhphung force-pushed the fix/issue-475-cloudfetch-download-timeout branch from bcbc38d to 6c6f29d Compare November 23, 2026 22:56

@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 findings. Download clients now get a bounded timeout regardless of option order, the existing error chain is kept, and the tests cover stalled headers and bodies on all three result APIs. Possible follow-up: a redirect Location whose query differs from the original link is not redacted by the string-replace path.

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

Comment thread internal/rows/arrowbased/batchloader.go 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.

🔀 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, with one low concern. The timeout wiring (a capped copy of the default client, and the WithTransport client built after options are applied) is correct and well tested. Error redaction misses one narrow redirect case.

Comment thread internal/rows/arrowbased/batchloader.go Resolved
Bound each Thrift CloudFetch transfer attempt with the existing 900s
ClientTimeout so stalled downloads cannot wait indefinitely. Preserve
default-client settings and use the final WithTransport option for downloads.
Omit the link's presigned query string from download errors.

Addresses #475 (part 2)

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@vuanhphung
vuanhphung force-pushed the fix/issue-475-cloudfetch-download-timeout branch from d13de1a to b689358 Compare November 23, 2026 23: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.

@aakash-saravanan-db aakash-saravanan-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving the timeout fix. Please address the blocking inline comment about preserving pkg/errors.Cause compatibility before merging.

return strings.ReplaceAll(downloadErr.cause.Error(), downloadErr.rawQuery, "[REDACTED]")
}

func (downloadErr redactedCloudFetchError) Unwrap() error {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blocking: please preserve github.com/pkg/errors.Cause compatibility before merging.

The new redactedCloudFetchError implements Unwrap() but not Cause(). pkg/errors.Cause follows only Cause(), so it now stops at this wrapper. I reproduced the same truncated-body download failure on the base and this PR: errors.Is(err, io.ErrUnexpectedEOF) is true on both, but pkgerrors.Cause(err) == io.ErrUnexpectedEOF changes from true on the base to false here. Applications using the latter to classify failures lose the underlying cause.

Please add Cause() error returning downloadErr.cause, alongside Unwrap(), and a regression test. I verified that this restores compatibility while the existing redaction tests still pass.

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

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