Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
- Evict kernel connections when SEA reports a missing or invalid session, and reject later requests locally without replaying the failed statement.
- Reduce Thrift row-scan CPU by binding scalar readers and null/type handling once per Arrow record (databricks/databricks-sql-go#602).
- **Behavior change:** Closed Thrift Arrow row scanners return an explicit error without logging an ERROR instead of stale values; a destination whose column count differs from the Arrow holders now errors instead of filling leading columns or NULL-padding missing columns. Column-value setup failures now stop scanning and are retained for subsequent scans instead of only being logged and ignored (databricks/databricks-sql-go#602).
- Support SOCKS proxies on the kernel backend; see [Proxy](CONNECTION_PARAMETERS.md#proxy).
Comment thread
cathleeny marked this conversation as resolved.
Resolved
Comment thread
cathleeny marked this conversation as resolved.
Resolved
Comment thread
cathleeny marked this conversation as resolved.
Resolved
Comment thread
cathleeny marked this conversation as resolved.
Resolved
- **Behavior change:** On the kernel backend, `NO_PROXY` now also applies to CloudFetch storage and OAuth hosts, with the differences from the Thrift path listed in [Proxy](CONNECTION_PARAMETERS.md#proxy).

## v2.0.0 (2026-11-23)

Expand Down
36 changes: 31 additions & 5 deletions CONNECTION_PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,40 @@ used for:
## Proxy

Both backends honor the standard `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` environment
variables. Note the kernel path accepts **http(s) proxies only**: a `socks*` proxy URL
(honored on the Thrift path) is rejected at connect on the kernel path. Kernel SOCKS
support is tracked in PECOBLR-4152.
variables, including `socks5://` and `socks5h://` proxy URLs. Credentials go in the URL userinfo
(`socks5h://user:pass@proxy:1080`, RFC 1929 for SOCKS5).

For a SOCKS `HTTPS_PROXY`, the kernel path keeps the Thrift path's behavior:

- `socks5://` is sent to the kernel as `socks5h://`, so the proxy resolves the
warehouse and CloudFetch host names, as on the Thrift path.
- `socks5h://` resolves at the proxy on both paths.
- `socks4://` and `socks4a://` fail at connect with `ErrInvalidKernelConfig` when the
warehouse uses the proxy. The Thrift path cannot use them either. When `NO_PROXY`
bypasses the warehouse, the URL is passed to the kernel as is, so the connection works
if no host needs the proxy; hosts that do, such as CloudFetch storage, go through the
SOCKS4 proxy, where the Thrift path would fail.

On the kernel path, the driver passes one proxy for every host (warehouse, CloudFetch
storage and OAuth) together with `NO_PROXY` as the kernel's bypass list. It is the
warehouse's proxy, or `HTTPS_PROXY` when the warehouse connects directly (for example
through `NO_PROXY`). As on the Thrift path, these variables are read once per process. The
warehouse always follows Go's `NO_PROXY` rules exactly. For other hosts, two things
differ from the Thrift path:

- A `host:port` entry applies only with port 443 (CloudFetch storage and OAuth use 443);
entries for other ports are dropped, so those hosts stay proxied.
- `.example.com` and `*.example.com` also bypass `example.com` itself.

`ALL_PROXY` differs between the paths. Thrift ignores it. On the kernel path, when the
warehouse connects directly and no `HTTPS_PROXY` is set, the driver passes no proxy and the
kernel reads `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY` itself. A `socks5://` `ALL_PROXY`
therefore resolves host names locally, and `socks4://` / `socks4a://` are accepted.

| Connector option | Thrift | Kernel | Notes |
|---|:---:|:---:|---|
| *(environment)* | ✅ | ✅ | `HTTP(S)_PROXY` / `NO_PROXY`. |
| `WithKernelProxy(KernelProxy{URL, Username, Password, BypassHosts})` | ❌ | ✅ | Explicit proxy with out-of-band basic-auth credentials and a structured bypass list — the "advanced" fields the env-var path can't express. Overrides the environment proxy; a malformed URL is rejected at connect. |
| *(environment)* | ✅ | ✅ | `HTTP(S)_PROXY` / `NO_PROXY`; `ALL_PROXY` on the kernel path only. |
| `WithKernelProxy(KernelProxy{URL, Username, Password, BypassHosts})` | ❌ | ✅ | Explicit proxy with out-of-band credentials (basic auth, or RFC 1929 for SOCKS5) and a structured bypass list — the "advanced" fields the env-var path can't express. Overrides the environment proxy; a malformed URL is rejected at connect. The URL is passed to the kernel verbatim: `http`, `https`, `socks4`, `socks4a`, `socks5` and `socks5h` are accepted, and `socks4` / `socks5` resolve host names locally while `socks4a` / `socks5h` resolve them at the proxy. |

## Telemetry

Expand Down
2 changes: 1 addition & 1 deletion KERNEL_REV
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3b691d2a2c235ef847d61b308c31604979830994
a29235cbea9532efa5572ebff010045583a19cbe
Comment thread
cathleeny marked this conversation as resolved.
Resolved
35 changes: 20 additions & 15 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,28 +779,33 @@ func WithKernelSkipHostnameVerify() ConnOption {
// misplaced BypassHosts) compile cleanly and fail only at runtime with wrong proxy
// credentials.
type KernelProxy struct {
// URL is the proxy URL (e.g. "http://proxy.internal:3128"). Required; empty is a
// no-op, leaving the environment-derived proxy (if any) in effect.
// URL is the proxy URL (e.g. "http://proxy.internal:3128" or
// "socks5h://proxy.internal:1080"). Required; empty is a no-op, leaving the
// environment-derived proxy (if any) in effect. It is passed to the kernel
// verbatim: http, https, socks4, socks4a, socks5 and socks5h are accepted;
// socks4/socks5 resolve the target host locally and socks4a/socks5h at the proxy.
URL string
// Username / Password are optional out-of-band basic-auth credentials, supplied
// here rather than embedded in the URL userinfo. Empty means unset.
// Username / Password are optional out-of-band proxy credentials (basic auth for
// an HTTP proxy, RFC 1929 for SOCKS5), supplied here rather than embedded in the
// URL userinfo. Empty means unset.
Username string
Password string
// BypassHosts is an optional comma-separated no-proxy host list. NO_PROXY is
// consumed during environment resolution and not forwarded to the kernel, so this
// is the only way to give the kernel a structured bypass list. Empty means unset.
// BypassHosts is an optional comma-separated no-proxy host list, passed to the
// kernel verbatim. It replaces the environment path's bypass list, which the driver
// translates from NO_PROXY. Empty means unset.
BypassHosts string
}

// WithKernelProxy configures an explicit HTTP proxy for the kernel backend, with
// optional out-of-band basic-auth credentials and a comma-separated bypass
// (no-proxy) host list. It overrides the HTTP(S)_PROXY / NO_PROXY environment the
// kernel path otherwise mirrors from the Thrift path.
// WithKernelProxy configures an explicit HTTP or SOCKS proxy for the kernel backend, with
// optional out-of-band credentials (basic auth for an HTTP proxy, RFC 1929 for SOCKS5)
// and a comma-separated bypass (no-proxy) host list. It overrides the HTTP(S)_PROXY /
// NO_PROXY environment the kernel path otherwise mirrors from the Thrift path.
//
// Use this instead of the proxy environment when you need the "advanced" fields
// the env-var path can't express: a structured bypass list (NO_PROXY is consumed
// during environment resolution, not forwarded to the kernel) or basic-auth
// credentials supplied out of band rather than embedded in the URL userinfo.
// Use this instead of the proxy environment when you need what the env-var path
// can't express: a bypass list in the kernel's own matching rules, passed verbatim
// (the env path translates NO_PROXY into that list, approximating Go's rules for
// hosts other than the warehouse), or credentials supplied out of band rather than
// embedded in the URL userinfo.
// KernelProxy.Username / Password / BypassHosts may be empty (passed to the kernel
// as NULL, i.e. unset). An empty KernelProxy.URL is a no-op — the environment-derived
// proxy, if any, stays in effect. A malformed URL is rejected at connect
Expand Down
16 changes: 8 additions & 8 deletions internal/backend/kernel/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,14 @@ func (k *KernelBackend) applyKernelTLS(cfg *C.KernelSessionConfig) error {
return nil
}

// applyProxy forwards the HTTP proxy config to the session config. The URL is set
// when either the environment configured one for this endpoint or the caller
// supplied one via WithKernelProxy (resolveKernelProxy decides which). The
// optional basic-auth credentials and bypass list ride along; each is NULL when
// empty (the env path folds credentials into the URL and consumes NO_PROXY during
// resolution, so it leaves them empty — Go's proxy-env convention). A no-op when
// ProxyURL is empty (direct connection). The kernel applies the URL as an explicit
// override of its own env-var behavior.
// applyProxy forwards the HTTP or SOCKS proxy config to the session config. The URL
// is set when either the environment configured one or the caller supplied one via
// WithKernelProxy (resolveKernelProxy decides which). The optional credentials and
// bypass list ride along; each is NULL when empty. The env path keeps credentials
// in the URL userinfo and sets the bypass list from NO_PROXY, translated to the
// kernel's matching rules. A no-op when ProxyURL is empty, which leaves proxy
// selection to the kernel's own env-var handling. The kernel applies the URL as an
// explicit override of that env-var behavior.
func (k *KernelBackend) applyProxy(cfg *C.KernelSessionConfig) error {
if k.cfg.ProxyURL == "" {
return nil
Expand Down
21 changes: 11 additions & 10 deletions internal/backend/kernel/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ type Config struct {
TLSClientKeyPEM []byte
TLSSkipHostnameVerify bool

// ProxyURL configures an HTTP proxy. It is either resolved for this endpoint
// from the same HTTP(S)_PROXY / NO_PROXY environment the Thrift path uses
// (NO_PROXY applied during resolution), or set explicitly via WithKernelProxy.
// Empty leaves the kernel on a direct connection.
// ProxyURL configures an HTTP or SOCKS proxy for every kernel destination. It
// is either resolved from the same HTTP(S)_PROXY / NO_PROXY environment the
// Thrift path uses, or set explicitly via WithKernelProxy. Empty leaves proxy
// selection to the kernel's own environment handling.
//
// ProxyUsername / ProxyPassword are out-of-band basic-auth credentials (an
// alternative to embedding them in ProxyURL's userinfo). ProxyBypassHosts is
// a comma-separated no-proxy list honored kernel-side. All three are only
// meaningful with an explicit WithKernelProxy — the env-var path folds
// credentials into the URL and consumes NO_PROXY during resolution, so it
// leaves these empty. Empty fields are passed as NULL (kernel default).
// ProxyUsername / ProxyPassword are out-of-band proxy credentials (an
// alternative to embedding them in ProxyURL's userinfo); only WithKernelProxy
// sets them, since the env-var path keeps credentials in the URL.
// ProxyBypassHosts is a comma-separated no-proxy list honored kernel-side:
// WithKernelProxy's list, or on the env-var path NO_PROXY translated to the
// kernel's matching rules (plus loopback, and the warehouse when NO_PROXY
// bypasses it). Empty fields are passed as NULL (kernel default).
ProxyURL string
ProxyUsername string
ProxyPassword string
Expand Down
33 changes: 30 additions & 3 deletions internal/backend/kernel/include/databricks_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,10 @@ KernelStatusCode kernel_init_logging_callback(const char* level,
* override.
*/

/* Route traffic through an HTTP/HTTPS proxy. `url` is required (e.g.
* "http://proxy.corp:8080"); `username` / `password` / `bypass_hosts`
* (comma-separated) are optional — pass NULL to omit. */
/* Route traffic through an HTTP/HTTPS or SOCKS proxy. `url` is required
* (e.g. "http://proxy.corp:8080" or "socks5h://proxy.corp:1080"; schemes
* http, https, socks4, socks4a, socks5, socks5h); `username` / `password` /
* `bypass_hosts` (comma-separated) are optional — pass NULL to omit. */
KernelStatusCode kernel_session_config_set_proxy(KernelSessionConfig* config, const char* url,
const char* username, const char* password,
const char* bypass_hosts);
Expand Down Expand Up @@ -487,6 +488,32 @@ KernelStatusCode kernel_session_config_set_tls_client_certificate(
KernelSessionConfig* config, const uint8_t* cert_pem, size_t cert_len,
const uint8_t* key_pem, size_t key_len);

/* Enable or disable TLS certificate-revocation checking (default: off).
*
* Supported only on Windows with the tls-rustls backend, where Windows CryptoAPI
* checks the revocation of the chain it builds for the server certificate, after
* webpki has verified the chain. A revoked certificate is always rejected.
* `accept_undetermined` governs a status that cannot be determined (a fetch
* failure or timeout, an offline status, a partial chain): false rejects it
* (strict), true accepts it. `check_revocation` false disables the check whatever
* `accept_undetermined` says. Revocation is also skipped when the self-signed
* setter is set.
*
* CRL and OCSP retrieval uses Windows networking and proxy settings, not the
* kernel's proxy configuration, and Windows caches the results. The check is
* synchronous: it blocks the calling thread's TLS handshake until CryptoAPI
* returns, so a connect or operation timeout can be exceeded by up to the
* revocation budget (about 10 s for CRL and OCSP retrieval in total, shared by a
* handshake's one or two chain builds; AIA and other chain-building fetches are
* bounded per URL, not in total). Session
* resumption is disabled while checking is on.
*
* Requesting it on any other platform, or on tls-native, makes opening a session
* fail with InvalidArgument, and the error names the unsupported platform or
* backend. So does requesting it for a host that is not https. */
KernelStatusCode kernel_session_config_set_tls_certificate_revocation(
KernelSessionConfig* config, bool check_revocation, bool accept_undetermined);

/* Configure the HTTP retry / backoff policy. `min_wait_ms` / `max_wait_ms`
* are the backoff-wait bounds between attempts (the wait is exponential
* with jitter, clamped to this range); `max_retries` is the number of
Expand Down
4 changes: 3 additions & 1 deletion kernel_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func newKernelBackend(ctx context.Context, cfg *config.Config) (backend.Backend,
// HTTP(S)_PROXY / NO_PROXY environment for the kernel. resolveKernelProxy is
// pure Go (untagged, in kernel_config.go) with its own unit coverage, so it
// (and proxyForEndpoint) resolve here rather than in buildKernelConfig.
resolveKernelProxy(cfg, &kc)
if err := resolveKernelProxy(cfg, &kc); err != nil {
return nil, err
}
return kernel.New(kc), nil
}

Expand Down
24 changes: 16 additions & 8 deletions kernel_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,29 @@ func kernelRetryConfig(cfg *config.Config) *kernel.RetryConfig {
// resolveKernelProxy fills the kernel Config's proxy fields. An explicit
// WithKernelProxy (KernelExperimental.ProxyURL non-empty) wins verbatim,
// including its out-of-band credentials and bypass list; otherwise the
// endpoint's environment-derived proxy URL is used (with no credentials or
// bypass list — the env path folds credentials into the URL userinfo and
// consumes NO_PROXY during resolution, per Go's proxy-env convention). Kept
// untagged here (like buildKernelConfig) so the explicit-over-env precedence is
// asserted under CGO_ENABLED=0 (see TestResolveKernelProxy); newKernelBackend
// environment proxy is used for every kernel destination, with NO_PROXY
// translated into the kernel's bypass list (see proxyForEndpointFunc). The env
// path carries no separate credentials: they stay in the URL userinfo. An env
// socks4/socks4a proxy that the warehouse selects returns ErrInvalidKernelConfig
// (see kernelEnvProxyURL).
// Kept untagged here (like buildKernelConfig) so the explicit-over-env precedence
// is asserted under CGO_ENABLED=0 (see TestResolveKernelProxy); newKernelBackend
// calls it after buildKernelConfig so it stays a thin assembler.
func resolveKernelProxy(cfg *config.Config, kc *kernel.Config) {
func resolveKernelProxy(cfg *config.Config, kc *kernel.Config) error {
if ke := cfg.KernelExperimental; ke != nil && ke.ProxyURL != "" {
kc.ProxyURL = ke.ProxyURL
kc.ProxyUsername = ke.ProxyUsername
kc.ProxyPassword = ke.ProxyPassword
kc.ProxyBypassHosts = ke.ProxyBypassHosts
return
return nil
}
proxyURL, bypassHosts, err := proxyForEndpoint(cfg)
if err != nil {
return err
}
kc.ProxyURL = proxyForEndpoint(cfg)
kc.ProxyURL = proxyURL
Comment thread
cathleeny marked this conversation as resolved.
Resolved
kc.ProxyBypassHosts = bypassHosts
return nil
}

// resolveKernelAuth picks the kernel auth form from the config. The kernel backend
Expand Down
Loading
Loading