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
18 changes: 18 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ changes go in their respective binding's NEXT_CHANGELOG.

### Added

- C ABI: `kernel_session_config_set_retry_config()` — expose the crate's existing
HTTP retry knobs (`HttpConfig::retry_min_wait` / `retry_max_wait` /
`retry_max_retries` / `overall_timeout`) over the C ABI so a host can make its own
`RetryWaitMin` / `RetryWaitMax` / `RetryMax` / retry-budget policy authoritative
instead of the kernel default; `max_retries=0` disables retries, and
`overall_timeout_ms=0` keeps the kernel's default budget (non-zero overrides it).
The retry budget is always bounded — a large `max_retries` is still capped by it.
Benefits ODBC too. (Consumed by the Go driver via `WithRetries`,
databricks/databricks-sql-go#412.)
- C ABI: client-only `session_conf` key `cloudfetch_max_chunks_in_memory` — carried
by the existing `kernel_session_config_set_session_conf()` setter (no new symbol),
it bounds how many decompressed CloudFetch chunks the kernel holds in memory at
once (peak RSS on large result sets; default 16). Accepts a positive integer;
a value above the kernel ceiling (256) is clamped, and a non-numeric / non-positive
value is ignored (default preserved) with a warning rather than failing session
creation. The key is client-only — it is consumed before session creation and never
reaches the SEA wire. Benefits ODBC too.

### Updated

### Fixed
Expand Down
37 changes: 36 additions & 1 deletion include/databricks_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,17 @@ KernelStatusCode kernel_session_config_set_auth_u2m(KernelSessionConfig* config,
uint16_t redirect_port,
const char* scopes);

/* Add (or overwrite) one server-bound session-conf entry. */
/* Add (or overwrite) one session-conf entry. Keys are normally server SET
* parameters forwarded on the SEA wire (allowlist-filtered). A small set of
* reserved keys are instead CLIENT-ONLY: they tune the kernel locally, are
* consumed before session creation, and NEVER reach the wire. Client-only keys
* (matched case-insensitively):
*
* cloudfetch_max_chunks_in_memory — positive integer; how many decompressed
* CloudFetch chunks the kernel holds in memory at once (bounds peak RSS on
* large result sets; default 16). A value above the kernel ceiling (256) is
* clamped; a non-numeric / non-positive value is ignored (default kept) with
* a warning — a bad tuning value never fails session open. */
KernelStatusCode kernel_session_config_set_session_conf(KernelSessionConfig* config,
const char* key,
const char* value);
Expand Down Expand Up @@ -303,6 +313,31 @@ KernelStatusCode kernel_session_config_set_tls_allow_self_signed(KernelSessionCo
KernelStatusCode kernel_session_config_set_tls_skip_hostname_verification(KernelSessionConfig* config,
bool skip);

/* 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
* retries AFTER the initial attempt (so at most `max_retries + 1` total
* attempts, and `0` disables retries); `overall_timeout_ms` is the cumulative
* retry budget across all attempts (`0` keeps the kernel default — pass
* non-zero to override it). Lets a host's RetryWaitMin / RetryWaitMax /
* RetryMax / retry-timeout surface override the kernel's built-in policy
* (default 5 retries, 1s..60s, 900s budget) when this setter is not called.
*
* The retry budget is ALWAYS bounded — there is no "unlimited" value. A large
* `max_retries` is still capped by the (default or overridden) budget: if the
* exponential backoff sums past `overall_timeout_ms` the remaining attempts do
* not run, so raise `overall_timeout_ms` alongside a large `max_retries` if you
* want them all to fire. A non-zero `overall_timeout_ms` smaller than
* `min_wait_ms` guarantees ZERO retries (the first backoff already exceeds the
* budget); it is accepted but the kernel logs a warning.
*
* `min_wait_ms == 0` or `max_wait_ms < min_wait_ms` returns InvalidArgument.
* Benefits ODBC too. */
KernelStatusCode kernel_session_config_set_retry_config(KernelSessionConfig* config,

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.

CloudFetch client knob is undiscoverable at the API boundary

The retry knob ships a typed header symbol + a NEXT_CHANGELOG.md entry. The cloudfetch_max_chunks_in_memory client knob ships neither — it lives only in Rust source comments (src/session.rs). For a C ABI whose header is the contract, an external host (the ODBC/Go consumers the changelog courts with "Benefits ODBC too") has no way to learn the key exists or what values it accepts. The two error contracts also diverge: retry rejects bad input with InvalidArgument; cloudfetch silently warns-and-ignores.

Live verification: built at this SHA and tested against a real warehouse — the knob mechanism works end-to-end (range(100000) streamed back with max_chunks=4; an invalid value was ignored without failing connect). So this is purely a documentation/discoverability gap, not a functional bug — but a shipped-but-undocumented tunable is effectively dead to the very consumers it targets.

Suggested fix

Add a NEXT_CHANGELOG.md entry and a header comment near set_session_conf enumerating recognized client-only session_conf keys and their accepted values. Longer term, document a single rule for "typed C-ABI symbol vs client session_conf key" so the choice is principled rather than decided per-PR.

Reviewers: architecture. Confidence: 82.

--- Posted by code-review-squad · /full-review · feedback: #code-review-squad-feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c887904.

  • Added a NEXT_CHANGELOG.md entry for the cloudfetch_max_chunks_in_memory client-only key (accepted values, 256 ceiling / clamp, warn-and-ignore on bad input, never reaches the wire).
  • Added a header comment near set_session_conf documenting the client-only-vs-server-SET distinction and enumerating the recognized client key + its accepted values, so a C host reading the contract can discover it.

On the divergent error contracts (retry InvalidArgument vs cloudfetch warn-and-ignore): kept deliberately. A retry range is structurally invalid (a degenerate range must not reach the client), whereas the chunk knob is a best-effort perf tuning where a typo should not turn into a connect failure — so it clamps/ignores with a warning instead. Both behaviors are now documented at the boundary.

uint64_t min_wait_ms, uint64_t max_wait_ms,
uint32_t max_retries,
uint64_t overall_timeout_ms);

/* ─── Session lifecycle ───────────────────────────────────────────────*/

/*
Expand Down
Loading
Loading