Skip to content

fix(kernel): honor the CloudFetch connection option - #536

Merged
aakash-saravanan-db merged 21 commits into
mainfrom
aakash-saravanan_data/fix/cloudfetch-disabled
Nov 13, 2026
Merged

aakash-saravanan-db merged 21 commits into
mainfrom
aakash-saravanan_data/fix/cloudfetch-disabled

Conversation

@aakash-saravanan-db

@aakash-saravanan-db aakash-saravanan-db commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

With the kernel backend, WithCloudFetch(false) and the DSN option useCloudFetch=false are ignored, so large results still require direct access to cloud storage. This PR forwards the existing option when opening the native session, allowing complete results to be fetched through the SQL connection.

The connector uses the kernel's existing cloudfetch_enabled client setting. The kernel handles option precedence and result delivery. This also preserves the disable option when existing automatic recovery selects the kernel backend.

Dependency: Requires databricks-sql-kernel #436, which fixes large-result delivery with CloudFetch disabled. KERNEL_REV pins that implementation for source builds. Before merging, publish native Go bindings containing the fix and update the platform modules in go.mod and go.sum to require them. The release version has not yet been assigned.

Validation: The default and kernel-tagged test suites pass. A probe linked against the locally built native library returns all 250,000 rows and 32 MB of payload with the expected hash. Disabled delivery succeeds through a proxy that blocks storage access; enabled delivery attempts storage access. Query errors, reuse, and close also pass.

Performance follow-up: Five measured runs per mode, after warmup, give medians of 2.658 s for Thrift and 3.241 s for kernel (+21.9%). The 10% performance criterion remains unmet. Kernel issue #441 tracks result-transfer costs and evaluation of response compression separately.

@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 High · 1 Medium

Changes requested: one high concern. The new disable path sends can_cloud_download, which the repo's own docs say the SEA server rejects (CONFIG_NOT_AVAILABLE); the kernel's documented toggle is the client-result key cloudfetch_enabled. CONNECTION_PARAMETERS.md also still says the option is inert on the kernel path.

Comment thread kernel_config.go Resolved
Comment thread README.md 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.

Verdict: 1 Medium · 2 Low

Small, clean change, but I have one medium concern: WithCloudFetch(false) is mapped to the server session conf can_cloud_download, which the docs this PR deletes said SEA rejects. The kernel already has a client-only cloudfetch_enabled toggle that would avoid that risk.

Comment thread kernel_config.go Resolved
Comment thread kernel_config.go Resolved
Comment thread kernel_config_test.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.

Verdict: 1 Medium · 1 Nit

The mapping change is mostly sound: EffectiveSessionParams returns a fresh map, so the case-insensitive delete and override can't mutate the caller's session params. One medium concern: on servers that don't support can_cloud_download, a previously inert option now fails at statement time. Nit: CONNECTION_PARAMETERS.md:130 (unchanged) still says "On Thrift use WithCloudFetch" for cloudfetch_enabled, which now reads as if WithCloudFetch were Thrift-only.

Other findings

  • ⚪ Nit — This e2e test can't catch the regression it's meant to guard. Every assertion (row count, payload bytes, digest) would pass the same way if WithCloudFetch(false) were still ignored and results came through CloudFetch, which is the pre-PR behavior. The PR description says a separate probe confirmed "zero cloud-storage downloads", but nothing in this test checks that. Consider asserting on something only inline delivery can produce, e.g. a kernel result-disposition/telemetry signal or a download counter, or pointing CloudFetch downloads at an unreachable proxy so the test fails if any download is attempted. Otherwise the test only shows that large results work, not that the option is honored.

Comment thread kernel_config.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.

Verdict: 1 Medium · 1 Low · 1 Nit

The change itself is small and correct (the SessionConf map is a fresh copy, so the case-insensitive override doesn't mutate the caller's params). There is one medium concern: users who already set useCloudFetch=false on the kernel path may now hit statement-time failures on servers without paged-inline support. There are also two low issues: the interaction with cloudfetch_enabled=false is undefined, and a pass-through test is missing.

Other findings

  • ⚪ Nit — The "enabled" test only checks the default case, where no session params are set. It doesn't check that a user-supplied can_cloud_download in SessionParams is passed through unchanged when UseCloudFetch is true. That pass-through is what keeps the new override limited to the disabled case. A short subtest would lock in that contract, so a later refactor that strips the key unconditionally (for example, moving the delete loop outside the if) gets caught.

Comment thread kernel_config.go Resolved
Comment thread kernel_config.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.

Verdict: 1 Medium · 2 Nit

The mapping logic is correct: EffectiveSessionParams returns a fresh map, so callers are never mutated, and unit tests cover the override cases well. There is one medium compatibility concern: user-set cloudfetch_enabled=false is now silently dropped and can_cloud_download=false is forced, which can break existing kernel configs on servers that lack paged-inline support.

Other findings

  • ⚪ Nit — w.(http.Hijacker) is an unchecked type assertion inside the proxy handler. If the writer is not a Hijacker (for example, if the test server is ever switched to HTTP/2), the handler panics instead of returning an error. Use the two-value form and send a 500 when it fails. Separately, the goroutine running io.Copy(upstream, buffered) is never joined. It only ends when the deferred upstream.Close() runs, which is fine for a test, but it is worth a short comment.
  • ⚪ Nit — The "CloudFetch enabled keeps the server default" subtest only checks the exact lowercase key can_cloud_download. It does not check that UseCloudFetch is actually true in baseKernelConfig(), so it relies on that helper staying in sync. Set c.UseCloudFetch = true explicitly so this test cannot pass for the wrong reason if the helper's defaults change.

Comment thread kernel_config.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.

Verdict: 1 Medium · 1 Low

Looks good overall: the kernel path now forwards WithCloudFetch(false) as can_cloud_download=false. The session map is a fresh copy, so callers' params are not mutated, and the unit tests cover case-insensitive overrides well. There are two concerns: users whose servers lack paged inline support may now see a hard failure at query time, and caller-supplied session params are overridden without any warning.

Comment thread kernel_config.go Resolved
Comment thread kernel_config.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.

Verdict: 1 Medium · 2 Low

The change is correct and narrowly scoped: one medium concern and two low ones. The override works on a fresh copy of the session conf, so the caller's map isn't mutated, and the enabled default is untouched. The medium concern is that can_cloud_download=false is now also injected into the Reyden auto-recovery session for Thrift users who set WithCloudFetch(false), which can turn a transparent recovery into a hard failure.

Comment thread kernel_config.go Resolved
Comment thread kernel_config.go Resolved
Comment thread kernel_cloudfetch_e2e_test.go Resolved
@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan_data/fix/cloudfetch-disabled branch from 7ea648f to d57a128 Compare November 11, 2026 00:32

@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 Medium · 1 Low

The change looks correct: EffectiveSessionParams returns a fresh map that is never nil, so the in-place delete/insert is safe and the caller's params are left alone. The new tests cover case-insensitive overrides, the enabled default, and a hermetic case where the server lacks paged-inline support. My one medium concern is that explicit user session params are now overridden without any log message.

Comment thread kernel_config.go Resolved
Comment thread kernel_config.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.

Verdict: 1 Medium · 1 Nit

Looks good overall. WithCloudFetch(false) is now passed through cleanly on the kernel backend as can_cloud_download=false, and the unit, Reyden-fallback and e2e tests cover it well. One medium concern: users who followed the old cloudfetch_enabled=false advice can break on servers without paged-inline support. Nit: the imports in kernel_cloudfetch_test.go aren't split into stdlib and third-party groups like the rest of the repo.

Other findings

  • ⚪ Nit — The proxy only allows a CONNECT whose target equals net.JoinHostPort(host, "443"), where host is the raw DATABRICKS_PECOTESTING_SERVER_HOSTNAME. If that value has a scheme (https://...), a trailing slash, or different letter case, every tunnel is blocked. The test then fails with a 403 connection error, which looks like a driver regression rather than a test-environment mismatch. WithServerHostname already accepts a scheme-prefixed host, so this mismatch is plausible. Normalize host first (strip the scheme and trailing /, and compare case-insensitively), or derive the allowed authority from the same parsing the connector uses.

Comment thread kernel_config.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.

Verdict: 1 Medium · 1 Low · 1 Nit

The change is correct and well tested, with one medium concern. Forcing can_cloud_download=false turns a previously ignored option into hard failures on servers without paged inline support, and that includes connections moved to the kernel automatically by the Reyden fallback. Nit: the imports in kernel_cloudfetch_test.go are not grouped the goimports way (stdlib separate from third-party), unlike the rest of the repo.

Other findings

  • ⚪ Nit — The fake server only checks that can_cloud_download is "false". It doesn't check that cloudfetch_enabled or other conflicting keys were left out of the request. The test also only covers a statement-time CONFIG_NOT_AVAILABLE failure. The docs promise that an error at session creation also surfaces without falling back, and nothing tests that path. Adding a case where POST /sessions returns the config error would cover the other half of the documented contract.

Comment thread kernel_config.go Resolved
Comment thread kernel_config.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.

Verdict: 3 Low

The change looks correct, with 3 low-severity notes. Warning-message accuracy, warning frequency, and how easy the new hard failure is to diagnose. EffectiveSessionParams returns a fresh non-nil map, so deleting keys while ranging and mutating it is safe, and unit and e2e tests cover the override, case-insensitive matching, and the no-fallback paths.

Comment thread kernel_config.go Resolved
Comment thread kernel_config.go Resolved
Comment thread kernel_config.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.

Verdict: 1 Medium · 1 Nit

The implementation looks correct, with one medium design concern. Configs that set WithCloudFetch(false) and/or the previously recommended cloudfetch_enabled=false now fail hard on warehouses without paged-inline support. The session-conf override itself is sound: EffectiveSessionParams returns a fresh map, keys are matched case-insensitively, the enabled default is left alone, and the tests cover precedence and the no-fallback behavior well.

Other findings

  • ⚪ Nit — The override loop has a deliberate rule for when to warn: always for cloudfetch_enabled, and for can_cloud_download only when its value is not false. No test checks this. The new subtests only check the resulting SessionConf. Because the warning goes through a package-level sync.Once, a test would need a resettable hook, for example a package var for the once or the log function. Without one, a reversed condition (e.g. warning on a harmless can_cloud_download=false, or never warning) would pass CI.

Comment thread kernel_config.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.

Verdict: 1 Low

Looks good, with one low-severity note about the warning that fires when raw session parameters are overridden. The override logic works on the fresh map returned by EffectiveSessionParams() and leaves the caller's map untouched. Key matching ignores case, and the enabled-by-default path is unchanged. The fake-server and Reyden recovery tests cover rejection both at session creation and at first statement.

Comment thread kernel_config.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.

Verdict: 1 Low

Looks good. There is one low-severity note about the override warning firing only once per process. The override logic works on the fresh copy that EffectiveSessionParams returns, so the caller's session parameters are not changed. Matching is case-insensitive, and unit, fake-server and e2e tests cover direct use, automatic recovery and the no-fallback behavior.

Comment thread kernel_config.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.

Verdict: 2 Low

Looks good. Two low-severity notes: the warning's level and once-per-process scope, and where the e2e test lives and how strict its proxy check is. The change forwards WithCloudFetch(false) as can_cloud_download=false on the kernel path. It works on the fresh copy returned by EffectiveSessionParams, so caller maps are not mutated, and tests cover the explicit-kernel path, automatic recovery, and unsupported servers.

Comment thread kernel_config.go Resolved
Comment thread kernel_cloudfetch_e2e_test.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.

Verdict: 1 Low

Looks good, with one low-severity gap: no test covers when the new override warning fires. When CloudFetch is disabled, buildKernelConfig correctly removes conflicting keys from a fresh EffectiveSessionParams copy (matching names in any letter case) and forces can_cloud_download=false, and tests cover the direct kernel path, automatic recovery from Thrift, server rejection, and the no-retry behaviour.

Comment thread kernel_config.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.

Verdict: 1 Low

Looks good: the override logic works on a fresh copy of the session params (EffectiveSessionParams), so callers' maps aren't modified, and the enabled default, case-insensitive key handling and once-per-process warning are well covered by tests. One low note: the changelog's migration guidance leaves out users who set only WithCloudFetch(false).

Comment thread CHANGELOG.md 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.

✅ No issues identified by the review bot.

@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 Low · 1 Nit

Looks correct: the Go side only forwards a nil-or-false client conf after the session confs, the default (UseCloudFetch=true) path is unchanged, and the native kernel handles precedence and errors. I found two low-severity issues: the docs disagree with the code about how the option is forwarded, and the e2e test also sets the raw cloudfetch_enabled param, so it can't show the new option works by itself.

Other findings

  • ⚪ Nit — The e2e test sets both WithCloudFetch(false) and the raw session param cloudfetch_enabled=false. Because the raw param is also set, the test can't show that WithCloudFetch(false) works on its own, which is the main behavior this PR adds. Today the raw param and the forwarded option end up as the same client-conf key, so the test could pass even if buildKernelConfig stopped forwarding the option. Please add a variant with only WithCloudFetch(false) (the unit test in kernel_cloudfetch_test.go has the same overlap), or drop the raw param here.

Comment thread CONNECTION_PARAMETERS.md 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.

Verdict: 1 Low

Looks good, with one low observability nit. The option goes from buildKernelConfig to the native client-conf setter while the config handle is still owned, and the existing deferred free covers the error path. Tests cover forwarding, unsupported-server errors with and without automatic recovery, and a restricted-proxy e2e run.

Comment thread internal/backend/kernel/backend.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.

Verdict: 2 Low

Looks good, with two low-severity notes. The option is forwarded correctly: UseCloudFetch defaults to true in config.go:785, the client-conf setter is in the vendored header, and an early setter error is freed by the existing consumed defer. Merging still depends on the native release gate described in the PR (KERNEL_REV points at an unreleased kernel commit).

Comment thread internal/backend/kernel/backend.go Resolved
Comment thread kernel_cloudfetch_e2e_test.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.

Verdict: 2 Nit

Looks good, with two nits and no correctness issues. WithCloudFetch(false) is now passed to the kernel's client-conf setter after the session confs, and the existing deferred free still releases the config on a setter error. The default (UseCloudFetch=true, set at internal/config/config.go:785) leaves kernel behaviour unchanged. The Reyden fallback, unsupported-server and restricted-proxy e2e cases are covered by the new tests.

Other findings

  • ⚪ Nit — The new setter's error prefix kernel: set CloudFetch option doesn't match the kernel: set_<abi_name>[key] pattern used by every other setter in OpenSession (for example set_session_conf[%s]). Something like kernel: set_client_conf[cloudfetch_enabled] would keep log searches consistent.
  • ⚪ Nit — CONNECTION_PARAMETERS.md mentions a specific release ("Released kernel 1.4.0 uses an older inline path…") and a merge-gate note about publishing the connector. That text will go stale once the native release ships. Consider removing it when the minimum native dependency is bumped.

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

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

Looks good, with one low concern: the new unit test depends on how the kernel formats its requests. Forwarding WithCloudFetch(false) to the kernel's cloudfetch_enabled client conf is correct. If a setter call fails, the config is freed by the existing consumed defer, and leaving the value nil when the option is true keeps the kernel's defaults. As the description says, this must not merge until the native Go bindings with the kernel #436 fix are published and the platform modules in go.mod/go.sum are updated. Until then, tagged builds using the prebuilt bindings won't have the matching kernel behavior. Nit: the docs dropped the old note that CAN_CLOUD_DOWNLOAD is not a valid SEA session conf, which may still help users who set it directly.

Comment thread kernel_cloudfetch_test.go Resolved
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
…etting

Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan_data/fix/cloudfetch-disabled branch from a66ceb4 to b08ba0c Compare November 13, 2026 01:45

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

@aakash-saravanan-db
aakash-saravanan-db added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 9983f08 Nov 13, 2026
14 checks passed
@aakash-saravanan-db
aakash-saravanan-db deleted the aakash-saravanan_data/fix/cloudfetch-disabled branch November 13, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants