Repository navigation
feat(napi): expose maxConnections on openSession ConnectionOptions - #74
Merged
Merged
Conversation
This was referenced May 25, 2026
msrathore-db
added a commit
that referenced
this pull request
May 26, 2026
…nf map Add a Quick-reference section at the top mapping the six implementation PRs (#74/#75/#76/#392/#393/#394) to features + test counts, plus a Python comparison table showing how each feature maps to Python's `use_sea=True` / `use_kernel=True` reference implementations. Scope-down the Statement conf map + Query tags rows in Section 3 to clarify the implementation is napi-only — the public NodeJS `ExecuteStatementOptions` surface does not yet expose them. Wiring to public API is a follow-up increment. Documented as Note 7. Addresses DA's round-3 PR #77 review point on Statement conf map scope. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Collaborator
Author
|
Re-review requested — round-3 fixups landed; DA round-3 sign-off received. Round-3 final tip: This PR went through three rounds of DA verification (round-1 → round-2 → round-3) covering the F1
DA's consolidated approval message confirms 17/17 live e2e reproduced across the full F1-F4 stack. Stale-approval dismissal on prior fixup push is the only reason this PR needs a fresh approver pass. Co-authored-by: Isaac |
3 tasks done
Surfaces the kernel's `HttpConfig::pool_max_idle_per_host` knob to the napi-rs JS surface as `maxConnections?: number` on the `ConnectionOptions` interface for `openSession()`. When absent, the kernel default of 100 (set in `c14c1ff` on this stack) applies. When present, the value flows through `SessionBuilder::http(...)` into the `reqwest` connection pool that the kernel uses for SEA HTTP transport. Mirrors the Python connector's `use_sea=True` backend, which accepts `max_connections` as a kwarg and forwards it to urllib3's `maxsize`. The NodeJS Thrift backend does NOT expose this knob, so this is a SEA-only extension; no parity break. Type round-trip: napi-rs serialises `Option<u32>` as JS `number | undefined`. Pool sizes up to `2^32 - 1` fit safely; typical values are in the 10-500 range. Kernel-side change is zero — `HttpConfig` already carries the field, the builder already accepts it. This commit is napi-only. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Make the binding-specific default explicit instead of relying on the kernel core's HttpConfig::default() — that default stays at the conservative kernel value (10), and each binding chooses its own user-facing default when constructing the session. The napi binding's default is 100, matching the JDBC driver's HttpConnectionPoolSize and closing the throughput gap vs the NodeJS Thrift driver's maxSockets: Infinity for bursty workloads (concurrent executeStatement, parallel CloudFetch chunk downloads). Encoded as the public NAPI_DEFAULT_POOL_MAX_IDLE_PER_HOST constant so reviewers and downstream binding authors can see the per-binding default policy. The pyo3 binding inherits the kernel default of 10 (matching Python urllib3's maxsize=10). Supersedes the closed PR #30 which would have lifted the kernel default itself — that conflated 'napi wants 100' with 'every kernel consumer wants 100', and the per-binding split is the right shape. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
force-pushed
the
msrathore/krn-max-connections
branch
from
May 26, 2026 10:08
0c5ca3f to
9c2ad89
Compare
vikrantpuppala
approved these changes
May 26, 2026
msrathore-db
added a commit
that referenced
this pull request
May 26, 2026
Pull in PR #74 (napi maxConnections with per-binding default 100). Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
added a commit
that referenced
this pull request
May 29, 2026
…k 8/8) (#23) ## Summary Combined PR carrying **kernel-stack positions 7/8 (TLS public API)** and **8/8 (SEA status accessors)** as a single 2-commit diff rebased onto `main`, plus follow-up review-response commits. PR #24 (original 7/8) was closed; its content is the first commit here. The sync and async kernel execution handles (`ExecutedStatement` from `Statement::execute()`, `ExecutedAsyncStatement` from `Statement::submit()`) now both expose the same four extended SEA status accessors — matching the Thrift `IOperation.status()` contract where the field set is available on the same handle regardless of how the caller drove polling. The kernel `Error` type carries those fields onto terminal-error states (`FAILED` / `CANCELED` / `CLOSED-no-data`) so wrappers see the same fields Thrift surfaced on `TGetOperationStatusResp` for failed statements. The napi binding (`databricks-sea-native`) exposes the matching JS surface (5 method/getter additions on `Statement`, 3 envelope keys on the JS Error) so JS callers migrating from the Thrift driver see the same field set they used to read from `TGetOperationStatusResp`. The pyo3 binding is intentionally untouched here. ## What this PR ships ### Public surface (kernel) **`config::TlsConfig`** — was an empty `#[non_exhaustive]` placeholder; now carries: - `custom_ca_cert: Option<Vec<u8>>` (PEM bytes, in-memory — no tempfile shim for napi-rs / pyo3) - `accept_self_signed: bool` - `skip_hostname_verification: bool` Multi-cert bundle support (`reqwest::Certificate::from_pem_bundle`) covers root+intermediate concatenations on both `tls-native` and `tls-rustls` backends. `session.rs::build_http_client_config` honours the caller-supplied `TlsConfig` instead of discarding it. Custom Debug impls redact PEM byte counts. **`types::sea::StatementStatus`** is now `#[non_exhaustive]` (external Rust callers can't struct-literal it; new fields stay non-breaking). Adds: - `num_modified_rows: Option<i64>` - `display_message: Option<String>` - `diagnostic_info: Option<String>` - `error_details_json: Option<String>` Custom redacting `Debug` truncates the three unbounded server strings to `<N chars>` so a `?status` in a tracing span doesn't dump multi-MB blobs. **`ExecutedStatement` (sync handle, from `Statement::execute()`)** exposes 4 accessors mirroring the above fields — populated from the terminal SEA `StatementStatus` captured at construction. Reachable on `Succeeded` / `Closed-with-inline-data` paths. **`ExecutedAsyncStatement` (async handle, from `Statement::submit()`)** mirrors the same 4 accessors. Internally caches `latest_status: Arc<std::sync::Mutex<SeaStatementStatus>>`, seeded with the initial `submit_statement` response and overwritten on every `status()` / `await_result()` poll. Same Thrift `IOperation.status()` contract on both consumption modes. **`kernel_error::Error`** gains three additive optional fields — `display_message`, `diagnostic_info`, `error_details_json` — plus matching builder setters. Populated by `carry_extended_status()` in `client/sea.rs::terminal_outcome` on `Failed` / `Cancelled` / `Closed-no-data` arms so the extended fields flow through to wrappers on the failure path. ### napi binding (`databricks-sea-native`) The JS-visible `Statement` class adds 4 async accessor methods mirroring Thrift's `TGetOperationStatusResp` field names: `numModifiedRows()`, `displayMessage()`, `diagnosticInfo()`, `errorDetailsJson()`. The JS Error envelope (`napi/src/error.rs`) becomes a strict superset of the pyo3 set — in addition to the 8 pyo3-aligned keys (`code` / `message` / `sqlState` / `errorCode` / `vendorCode` / `httpStatus` / `retryable` / `queryId`), it carries `displayMessage` / `diagnosticInfo` / `errorDetailsJson` whenever the kernel Error has them populated. JS callers catching errors get the same field surface they used to read from Thrift's failed-operation status. ### pyo3 binding **Untouched.** The kernel's Error gains new fields but pyo3's `attach_attrs` continues attaching only the original 8; the three Thrift-parity fields can be wired up later in a pyo3-specific follow-up if Python consumers want them. The async-handle accessor additions follow through to `ExecutedAsyncStatement` regardless (pyo3 wraps the kernel handle). ## What is NOT in this PR - **`progress` accessor** — removed from this PR. Empirical evidence: SDK Java's `StatementStatus` has no `progress` field, the live SEA wire doesn't populate one, and the live Thrift wire returned `progressUpdateResponse = null` on every poll of a 37s heavy TPC-H query against pecotesting (verified 2026-05-27). A `TODO(pr23-followup)` block at the kernel + napi sites documents the empirical evidence and the shape constraints for re-introduction (mirror Thrift's `TProgressUpdateResp` struct, not a bare `Option<f64>`). A forward-compat test (`test_statement_status_ignores_unknown_progress_field`) pins that the kernel won't break if the SEA server later starts emitting a `progress` JSON key. - **`errorDetailsJson` server-side behaviour** — gated server-side by `spark.databricks.sql.errorDetailsJson.enabled`, declared `internal()` and default-false in `DatabricksSQLConf.scala`. NOT settable via client session-conf (verified: pecotesting returns `[CONFIG_NOT_AVAILABLE] SQLSTATE: 42K0I` when SET). The kernel's wire-shape behaviour is correct already (passes through whatever the server sends); docstrings on all surfaces (`types::sea`, `ExecutedStatement`, `Error`, napi `Statement.errorDetailsJson`) explicitly call out this gating so users understand why the field is `None` on most workspaces. - **Public TLS surface on the napi binding** — the kernel side is built; the napi `Connection.openSession({ tls: ... })` plumbing remains a follow-up PR. The kernel surface is intentionally stricter (default = full validation, opt-in relaxations) than the existing NodeJS Thrift driver's hardcoded `rejectUnauthorized: false`; motivation is Python connector parity (Python exposes `_tls_no_verify` / `_tls_verify_hostname` / `_tls_trusted_ca_file` / `_tls_client_cert_*`) + better-than-Thrift defaults on SEA NodeJS. A `TODO(pr23-followup)` block on `config::TlsConfig` documents the Thrift evidence and the rationale. - **Two publicly-reachable `TlsConfig` types** (`config::TlsConfig` + `client::http::TlsConfig`) — `client::http::TlsConfig` is technically reachable via `client::http` being a `pub mod`. Documented (internal-only path field), deferred to a follow-up that gates the internal struct to `pub(crate)` after a downstream-consumer audit. ## Live-warehouse validation (pecotesting via `DATABRICKS_PECOTESTING_TOKEN_PERSONAL`) Empirical probes captured on 2026-05-27: - **Sync handle, SELECT 1 against SQL warehouse:** all 4 accessors reachable, all return `None` (server-omitted on classic SQL warehouse SELECT). Accessor wiring confirmed. - **Sync handle, `SELECT * FROM nonexistent_table` (FAILED):** kernel `Error` carries `sql_state=Some("42P01")`, `error_code=Some("BAD_REQUEST")`; the 3 extended fields are `None` because the SEA server emits less than Thrift on that error class (Thrift populated both `displayMessage` and `diagnosticInfo` for the same query — a real SEA-vs-Thrift wire divergence the kernel correctly passes through without inventing values). - **Async handle, `SELECT 1` via `submit() + await_result()`:** all 4 accessors reachable, return `None`. - **Async handle wiremock coverage:** initial-submit-terminal status caching, terminal-poll caching across `await_result`, and explicit `status()` cache refresh — all pinned by 3 new tests. - **`numModifiedRows` via Thrift on a real INSERT/UPDATE:** populated correctly (3 for `INSERT VALUES (1),(2),(3)`, 2 for `UPDATE ... WHERE n>1`). SEA equivalent behaves the same because the kernel passes the wire field through verbatim. - **`errorDetailsJson` via Thrift across 8 distinct error classes (parser, analyzer, runtime, raise_error, assert, function-lookup, group-by, table-not-found):** **null on every one** because `spark.databricks.sql.errorDetailsJson.enabled` is off in the workspace. Confirms the server-side gating documented in the docstrings. - **Baseline regression check (`select_one_round_trip` + `select_with_positional_params`):** still pass against live warehouse after all kernel-side changes. ## Commits 1. `90a40663` — `krn-tls-public-api: expose TlsConfig fields + stop discarding in session.rs` (was PR #24) 2. `f2af099a` — `krn-status-fields: expose 5 status accessors on ExecutedStatement` (note: `Statement::execute()` constructs `ExecutedStatement::new` with 6 positional args, not 5 — the original commit message off-by-one; subsequent commits use the correct count) 3. `132e904` — Merge `main` into branch (pulls in PR #74 napi maxConnections) 4. `10a852e` — `krn-status-fields: review fixes + napi Thrift-parity surface` — addresses F1 / F4 / F5 / F6 / F7 / F8 / F9 / F10 / F15 / F16 / F18 / F19 / F20 / F22 / F24 from the ultrareview, plus the napi-side Thrift-parity exposure (5 JS accessor methods + 3 envelope keys + parity test update from "strict 8" to "superset of pyo3 + 3 Thrift fields") 5. `752d1fa` — `krn-status-fields: clarify TLS doc + add polling-path status test` — P2.3 + P2.4 6. `af3a80a` — `krn-status-fields: drop speculative progress field + clarify TLS Thrift intent` — R2 (live-warehouse evidence) + R1 (Thrift TLS investigation) 7. `43183ae` — `krn-status-fields: mirror extended-status accessors on async handle + errorDetailsJson gating doc` — P1.2 (async-handle mirror) + `errorDetailsJson` server-flag documentation ## Tests **Combined branch on latest commit:** 453/453 lib + 14/14 wiremock + 14/14 async-execute-wiremock + 16/16 integration + 26/26 napi passing. New in this PR (across all commits): - `tls_config_default_is_strict` (commit 1) - `tls_config_debug_redacts_ca_cert_bytes` (commit 1) - `test_statement_status_with_extended_fields` (commit 2 + updates) - `test_statement_status_extended_fields_absent` (commit 2 + updates) - `test_statement_status_ignores_unknown_progress_field` (commit 6 — forward-compat) - `executed_statement_surfaces_extended_status_fields` (commit 2) - `executed_statement_status_fields_default_to_none` (commit 2) - `polling_path_carries_terminal_status_not_initial` (commit 5) - `test_http_client_with_multi_cert_pem_bundle` (commit 4 — TLS bundle fix) - `test_http_client_with_empty_pem_bytes_errors` (commit 4) - `test_tls_config_from_public_default_is_strict` (commit 4 — strict-Some(false) mapping) - `envelope_field_set_matches_pyo3_setattr_contract` (updated in commit 4 to reflect Thrift-parity superset) - `envelope_omits_thrift_extension_fields_when_unpopulated` (commit 4) - `envelope_surfaces_thrift_extension_fields_verbatim` (commit 4) - `async_await_result_caches_terminal_status_for_accessors` (commit 7) - `async_submit_caches_initial_terminal_status` (commit 7) - `async_status_call_refreshes_cached_status` (commit 7) - Live e2e: `live_select_status_accessors_default_to_none` (commit 4) - Live e2e: `live_failed_statement_error_envelope_carries_extended_fields` (commit 4) - Live e2e: `live_async_handle_exposes_extended_status_accessors` (commit 7) ## Gates - `cargo +stable fmt --all -- --check` — exit 0 - `cargo clippy --all-targets -- -D warnings` — exit 0 (kernel + napi) - `cargo test --lib` — **453/453 passing** - `cargo test --tests` — all non-ignored passing - `cargo test --test v0_async_execute_wiremock` — 14/14 passing - napi `cargo test` — 26/26 passing - pyo3 `cargo build` — clean (untouched) ## Tracking - [PECOBLR-2871](https://databricks.atlassian.net/browse/PECOBLR-2871) — Async statement lifecycle — extended status fields - [PECOBLR-2874](https://databricks.atlassian.net/browse/PECOBLR-2874) — Corporate network connectivity — custom CA + mTLS - Parent epic: [PECOBLR-2666](https://databricks.atlassian.net/browse/PECOBLR-2666) Co-authored-by: Isaac [PECOBLR-2871]: https://databricks.atlassian.net/browse/PECOBLR-2871 [PECOBLR-2874]: https://databricks.atlassian.net/browse/PECOBLR-2874 [PECOBLR-2666]: https://databricks.atlassian.net/browse/PECOBLR-2666 --------- Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surfaces the kernel's
HttpConfig::pool_max_idle_per_hostknob to the napi-rs JS surface asmaxConnections?: numberon theConnectionOptionsinterface foropenSession(). When absent, the kernel default of 100 (set inc14c1ffon this stack) applies.Mirrors the Python connector's
max_connectionskwarg on the SEA backend. The NodeJS Thrift backend does NOT expose this knob; this is a SEA-only extension. No parity break.Implementation
max_connections: Option<u32>tonapi/src/database.rs::ConnectionOptionsSessionBuilder::http(HttpConfig{pool_max_idle_per_host: max as usize, ..default})Option<u32>as JSnumber | undefined; values up to2^32 - 1round-trip safelyKernel-side change is zero —
HttpConfigalready carries the field, the builder already accepts it. This PR is napi-only.Stack
This is PR 9 of the SEA stack, branched off
msrathore/krn-status-fields(PR #23). The corresponding NodeJS side lives in branchmsrathore/sea-max-connections(pushed to databricks-sql-nodejs).Test plan
cargo buildpassescargo clippy --all-targets -- -D warningspassesnapi build --platformregeneratesindex.d.tswithmaxConnections?: numberonConnectionOptionstests/unit/sea/auth-max-connections.test.ts— 9 cases passing (omit, valid, boundary, 0-reject, neg-reject, non-int-reject, NaN-reject, M2M arm, U2M arm)