Skip to content

fix(cloudfetch): degrade non-positive download-thread counts to the default - #549

Merged
vuanhphung merged 3 commits into
mainfrom
fix/issue-439-nonpositive-download-threads
Nov 13, 2026
Merged

vuanhphung merged 3 commits into
mainfrom
fix/issue-439-nonpositive-download-threads

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

WithMaxDownloadThreads(0), WithMaxDownloadThreads(-1) and the DSN form maxDownloadThreads=<=0 were accepted. Session open and execution succeeded, but the first CloudFetch read failed with row number 0 is not contained in any arrow batch: EOF. NewConnector applies options after config.WithDefaults(), so the only clamp (CloudFetchConfig.WithDefaults) never saw the user's value. The scheduler loop for downloadTasks.Len() < MaxDownloadThreads then started no downloads.

NewConnector now normalizes the value after all options are applied. That also covers the DSN path, because OpenConnector applies ParseDSN's UserConfig as an option. A non-positive value logs one warning naming maxDownloadThreads (WithMaxDownloadThreads) and the value, then uses the default of 10. This follows the ODBC spec reference: warn, keep the default, connect. Positive values, including very large ones, are unchanged. A non-numeric DSN value still fails sql.Open with ErrInvalidDSNFormat, like every other numeric DSN parameter.

Verification:

  • Unit tests. Option and DSN paths with -1, 0, 1, 15, 100000 and unset, asserting the value and exactly one warning. A fake-Thrift CloudFetch read drives the real connector, Thrift client and download pool against a local Arrow file server; on main it fails with the exact EOF.
  • Checks. make lint (0 issues), make test, go test -race, and the kernel-tagged suite all pass. The one kernel-tagged failure, TestKernelCloudFetchDisabledPreservesUnsupportedServerError, fails identically on main with the published v1.4.0 archive.
  • Live, Thrift. TestE2ECloudFetchNonPositiveMaxDownloadThreads reads 300,000 rows over CloudFetch (presigned downloads counted) with WithMaxDownloadThreads(-1). It fails on main with the EOF, and is added to the credentialed Thrift nightly.
  • Live, kernel. An ad-hoc 1M-row read with -1 on the kernel backend passes; the knob is inert there.
  • Shared conformance test. TestInvalidClientSideCloudFetchKnobValueDoesNotFailSessionOpen (driver-test#1242, passthrough mode) passes on this branch and SKIPs (xfail) on main.

Performance: the change runs once per NewConnector and doesn't touch the CloudFetch scheduling or download code, so fetch performance can't change.

Cross-driver state

Driver State Notes
JDBC Not supported (rejects) cloudFetchThreadPoolSize (default 16) throws DatabricksValidationException for <= 0 or non-numeric, ValidationUtil.java:61-75 @0cb8c24
Python Partial max_download_threads (default 10) is not validated; ThreadPoolExecutor raises ValueError at execute, download_manager.py:52 @5a1a7ec
Go Not supported → Supported (this PR) warns and uses the default 10 (ODBC semantics)
Node.js Not applicable cloudFetchConcurrentDownloads is not user-settable, DBSQLClient.ts:157 @93a9112
Kernel Supported cloudfetch_max_chunks_in_memory (default 16): warns and skips on the session-conf path, session.rs:1229-1283 @db23442
ODBC (reference) Supported MaxChunksInMemory: WARN, keeps the default, kernel_connection.cpp:697-711 @ff8f0ff

Adversarial review: converged in round 1 with no high findings; both mediums are fixed (the live test's CloudFetch download counter now normalizes the configured hostname, and the test runs in the nightly).

Fixes #439

This pull request and its description were written by Isaac.

@vuanhphung
vuanhphung marked this pull request as ready for review November 13, 2026 09:53

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

Looks good. The fix runs in NewConnector after all options are applied, so it covers both the WithMaxDownloadThreads option and the DSN parameter (the DSN path goes through withUserConfig). Positive values are unchanged. I found no correctness, error-handling or test-coverage problems; the fake-Thrift CloudFetch test exercises the real download pool. One follow-up: the warning also fires on the kernel backend, where the setting has no effect. That is harmless.

Other findings

  • ⚪ Nit — README.md:331 and CONNECTION_PARAMETERS.md:178 still list maxDownloadThreads with no note on what happens when the value is <= 0. doc.go now documents the warn-and-use-default behavior; mirroring that note in both tables would keep the docs consistent.

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

✅ No issues identified by the review bot.

vuanhphung and others added 3 commits November 13, 2026 18:23
…efault

WithMaxDownloadThreads(<=0) and maxDownloadThreads=<=0 bypassed the only
clamp, which ran before options were applied. The CloudFetch scheduler then
started no downloads, and the first read failed with "row number 0 is not
contained in any arrow batch: EOF".

NewConnector now normalizes the value after all options (including the DSN
UserConfig), logs one warning naming the option and value, and uses the
default of 10, matching the ODBC reference behavior for CLOUDFETCH-019.

Fixes #439

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>
…nightly

The live #439 guard counted every request whose hostname differed from the
raw configured value. A scheme- or port-prefixed DATABRICKS_PECOTESTING
hostname therefore counted warehouse RPCs as CloudFetch downloads, and the
download assertion became vacuous. The configured value is now parsed the
way WithServerHostname parses it and compared case-insensitively, with a
credential-free regression test.

Also add the guard to the credentialed Thrift nightly selector, so it runs
outside manual invocations.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>
Mirror the doc.go note in README.md and CONNECTION_PARAMETERS.md.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>
@vuanhphung
vuanhphung force-pushed the fix/issue-439-nonpositive-download-threads branch from 5f90176 to 505f8d9 Compare November 13, 2026 18:25

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

✅ No issues identified by the review bot.

@vuanhphung
vuanhphung enabled auto-merge November 13, 2026 18:32
@vuanhphung
vuanhphung added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit b72f29d Nov 13, 2026
14 checks passed
@vuanhphung
vuanhphung deleted the fix/issue-439-nonpositive-download-threads branch November 13, 2026 18:51
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.

[coverage] Conformance findings: CLOUDFETCH-019

1 participant