Repository navigation
feat(config): expose TlsConfig fields + stop discarding in session.rs (stack 7/8) - #24
Closed
msrathore-db wants to merge 11 commits into
Closed
msrathore-db wants to merge 11 commits into
msrathore-db wants to merge 11 commits into
Conversation
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 16, 2026 14:39
21638e3 to
d749d5b
Compare
msrathore-db
changed the base branch from
msrathore/krn-napi-binding
to
msrathore/kernel-async-public-api
May 16, 2026 14:40
This was referenced May 16, 2026
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 17, 2026 13:15
d749d5b to
3fa02c1
Compare
msrathore-db
changed the base branch from
msrathore/kernel-async-public-api
to
msrathore/krn-connection-pool-default-bump
May 17, 2026 13:15
This was referenced May 17, 2026
Closed
This was referenced May 17, 2026
msrathore-db
force-pushed
the
msrathore/krn-connection-pool-default-bump
branch
from
May 20, 2026 10:36
b896baf to
bb2dc5e
Compare
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 20, 2026 10:36
3fa02c1 to
5cda909
Compare
msrathore-db
force-pushed
the
msrathore/krn-connection-pool-default-bump
branch
from
May 20, 2026 16:55
bb2dc5e to
54e5800
Compare
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 20, 2026 16:55
5cda909 to
1ff2cf5
Compare
msrathore-db
force-pushed
the
msrathore/krn-connection-pool-default-bump
branch
from
May 20, 2026 20:22
54e5800 to
86d21b4
Compare
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 20, 2026 20:22
1ff2cf5 to
c94be53
Compare
msrathore-db
force-pushed
the
msrathore/krn-connection-pool-default-bump
branch
from
May 21, 2026 00:03
86d21b4 to
f13abf5
Compare
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 21, 2026 00:03
c94be53 to
d8ffe65
Compare
msrathore-db
force-pushed
the
msrathore/krn-connection-pool-default-bump
branch
from
May 23, 2026 11:03
f13abf5 to
3a5ba83
Compare
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 23, 2026 11:03
d8ffe65 to
86551cc
Compare
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 24, 2026 18:43
2e626e2 to
ba63971
Compare
msrathore-db
marked this pull request as ready for review
May 24, 2026 19:39
vikrantpuppala
pushed a commit
that referenced
this pull request
May 25, 2026
…tement + rustls-tls (stack 1/8) (#26) ## Stack Linear stack of 8 PRs on `databricks/databricks-sql-kernel` landing the **SEA-driver kernel-side enablement** work. Merge in order from base ↑ to tip. The tip branch (`msrathore/krn-status-fields`, PR [#23](#23)) is the single snapshot containing every kernel-side change in flight. | Pos | PR | Branch | Scope | |---|---|---|---| | 1/8 | [#26](#26) | `kernel-async-public-api` | Remove `block_on` from ResultStream + Send-safety on Statement + rustls-tls switch via Cargo features + e2e test ported from [#20](#20) | | 2/8 | [#27](#27) | `kernel-napi-skeleton` | napi-rs binding crate skeleton (opts INTO `tls-rustls` feature from creation) | | 3/8 | [#25](#25) | `kernel-napi-classes` | Database / Connection / Statement / ResultStream napi classes | | 4/8 | [#29](#29) | `kernel-napi-statement-validity` | StatementInner ValidityFlag fix propagated from sea-operation | | 5/8 | [#28](#28) | `kernel-oauth-error-class` | Reclassify OAuth token-exchange failures as `Error::unauthenticated()` | | 6/8 | [#30](#30) | `krn-connection-pool-default-bump` | Bump `HttpConfig.pool_max_idle_per_host` default 10 → 100 | | 7/8 | [#24](#24) | `krn-tls-public-api` | Expose `TlsConfig` fields (custom_ca_cert + accept_self_signed + skip_hostname_verification) | | 8/8 | [#23](#23) | `krn-status-fields` **← TIP** | Expose 5 status accessors on `ExecutedStatement` | **Policy:** new PRs always stack on the current tip. No sibling/parallel topology. --- **This PR is position 1/8 (ROOT of the kernel stack).** ## Summary Four commits in this PR. Two kernel correctness fixes that unblock async consumers (napi, pyo3), a Cargo-feature-based TLS backend split to preserve ODBC compatibility, plus a regression test for the block_on fix: - `49ffdcb` — `fix(kernel): remove block_on from ResultStream async public surface` (305 LOC, 7 files). The previous `ResultStream` accessors used `tokio::block_on` internally, which panics with "Cannot start a runtime from within a runtime" when called from inside an enclosing tokio runtime — exactly what napi-rs's `execute_tokio_future` and PyO3's wrapper runtime do. Fix: make the `ResultReader` trait itself `async` via `async_trait`. **This is Option 1 in [issue #19](#19 — the documented "right answer" — vs the Option 2 stopgap in [PR #20](#20). - `622a59a` — `krn-async-public-api: make Statement::execute/submit Send and switch to rustls-tls` (137 LOC, 2 files). Made the futures Send + switched reqwest's TLS backend to rustls-tls. - `7c4755a` — `test(reader): port cloudfetch_drain_does_not_nest_block_on from PR #20`. E2e regression test (49 LOC) drains 1M rows from inside a `#[tokio::test(flavor = "multi_thread")]`. - `d96afd9` — `feat(config): make TLS backend selectable via Cargo features` (NEW). Splits the prior unconditional rustls switch into two opt-in features: - `default = ["tls-native"]` — direct-Rust users, C-ABI / future ODBC path get the historical `native-tls` backend. - `tls-rustls` — napi-rs binding crate (added in next PR in this stack) opts in to avoid OpenSSL-symbol clash with Node.js. ## Why the TLS-feature commit was needed `622a59a` hardcoded rustls-tls because the napi binding loaded into Node segfaults on OpenSSL 1.1 symbol clash. But that pre-empted the choice for ODBC consumers who historically use native-tls. The new `d96afd9` commit makes the backend configurable so each consumer picks its own. **Default kept as native-tls** so existing direct-Rust callers + the C-ABI / ODBC path see no behavior change. Verified locally: - `cargo check -p databricks-sql-kernel` (default tls-native): clean - `cargo check --workspace` (kernel native-tls + napi rustls-tls in same workspace): clean - `cargo test --lib --workspace`: **376 passed / 0 failed** Side benefit: the pre-existing PEM flake `test_http_client_with_invalid_pem` (D-016 in the workflow) which was failing on the rustls-tls build now passes on native-tls. CI default is back to a fully-green state. ## Test plan - `cargo test` — full lib tests still green (376 passing) - `cargo clippy --all-targets -- -D warnings` clean - Downstream napi binding builds against this surface; M2M e2e green at `sea-auth-u2m@e7c979d` on databricks-sql-nodejs ## Tracking - [PECOBLR-2670](https://databricks.atlassian.net/browse/PECOBLR-2670) — Make the async interface for rust kernel - [PECOBLR-2917](https://databricks.atlassian.net/browse/PECOBLR-2917) — Fix napi binding SIGSEGV on concurrent openSession - Parent epic: [PECOBLR-2666](https://databricks.atlassian.net/browse/PECOBLR-2666) Co-authored-by: Isaac [PECOBLR-2670]: https://databricks.atlassian.net/browse/PECOBLR-2670?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
added a commit
that referenced
this pull request
May 25, 2026
…lope + util + runtime + logger (stack 2/8) (#27) ## Stack Linear stack of 8 PRs on `databricks/databricks-sql-kernel` landing the **SEA-driver kernel-side enablement** work. Merge in order from base ↑ to tip. The tip branch (`msrathore/krn-status-fields`, PR [#23](#23)) is the single snapshot containing every kernel-side change in flight. | Pos | PR | Branch | Scope | |---|---|---|---| | 1/8 | [#26](#26) | `kernel-async-public-api` | Remove `block_on` from ResultStream + Send-safety on Statement + rustls-tls + e2e test ported from [#20](#20) | | 2/8 | [#27](#27) | `kernel-napi-skeleton` | napi-rs binding crate skeleton: Cargo manifest + lib + error envelope + util + runtime + logger | | 3/8 | [#25](#25) | `kernel-napi-classes` | Database / Connection / Statement / ResultStream napi classes | | 4/8 | [#29](#29) | `kernel-napi-statement-validity` | StatementInner ValidityFlag fix propagated from sea-operation | | 5/8 | [#28](#28) | `kernel-oauth-error-class` | Reclassify OAuth token-exchange failures as `Error::unauthenticated()` (2-line fix in auth/oauth/m2m.rs + u2m.rs) | | 6/8 | [#30](#30) | `krn-connection-pool-default-bump` | Bump `HttpConfig.pool_max_idle_per_host` default from 10 → 100 | | 7/8 | [#24](#24) | `krn-tls-public-api` | Expose `TlsConfig` fields (custom_ca_cert + accept_self_signed + skip_hostname_verification) + stop discarding in session.rs | | 8/8 | [#23](#23) | `krn-status-fields` **← TIP** | Expose 5 status accessors on `ExecutedStatement` (num_modified_rows / progress / display_message / diagnostic_info / error_details_json) | **Companion NodeJS stack** (`databricks/databricks-sql-nodejs`): 8 PRs — root [#378](databricks/databricks-sql-nodejs#378) (sea-abstraction) → [#380](databricks/databricks-sql-nodejs#380) → [#377](databricks/databricks-sql-nodejs#377) → [#379](databricks/databricks-sql-nodejs#379) → [#382](databricks/databricks-sql-nodejs#382) → [#381](databricks/databricks-sql-nodejs#381) → [#384](databricks/databricks-sql-nodejs#384) → [#383](databricks/databricks-sql-nodejs#383) (tip). **Policy:** new PRs always stack on the current tip. No sibling/parallel topology. No force-pushes on existing PRs unless absolutely necessary; if a PR's content is wrong, add a fix-up commit on top of the stack tip rather than rewriting history. --- **This PR is position 2/8.** ## Summary Lands the napi-rs binding crate as a workspace member with **infrastructure only**: no exported classes yet. ~442 LOC across 10 files. **Files added:** - `Cargo.toml` — workspace membership declaration - `napi/Cargo.toml`, `napi/build.rs`, `napi/package.json`, `napi/.gitignore` — crate manifest + napi-rs build glue - `napi/src/lib.rs` — entry point declaring 4 infra modules (no class modules yet); exports a smoke-test `version()` fn - `napi/src/error.rs` — formatter for the `__databricks_error__:<json>` napi error envelope decoded by the JS-side adapter - `napi/src/util.rs` — shared helpers - `napi/src/runtime.rs` — tokio multi-thread runtime helper - `napi/src/logger.rs` — `tracing`-to-JS logger bridge stub ## Compilability `cargo check -p databricks-sea-native` is clean. The crate compiles standalone and exposes only the `version()` probe — the JS-side loader would find a valid `.node` but no functional API yet. This split makes the infra layer reviewable on its own; the next PR adds the user-facing surface. ## Tracking - [PECOBLR-2670](https://databricks.atlassian.net/browse/PECOBLR-2670) — Make the async interface for rust kernel — napi crate skeleton - Parent epic: [PECOBLR-2666](https://databricks.atlassian.net/browse/PECOBLR-2666) Co-authored-by: Isaac [PECOBLR-2670]: https://databricks.atlassian.net/browse/PECOBLR-2670?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
vikrantpuppala
pushed a commit
that referenced
this pull request
May 25, 2026
…in) (#66) Re-targets [#27](#27) against `main`. ## What happened PR #27 was stacked on PR #26's branch (`msrathore/kernel-async-public-api`). When PR #26 squash-merged into `main` (commit `f4a18ba`), PR #27's base was not re-pointed to `main`, so merging PR #27 landed its content on the now-stale `msrathore/kernel-async-public-api` branch (merge commit `b73a688`) rather than on `main`. Result: the napi-skeleton content is not on `main` despite #27 being marked as merged. ## What this PR does Cherry-picks the squash commit from #27 (`b73a688`) onto a fresh branch from current `main`. Content is identical to what #27 should have landed — same 12 files, same `+3771 / -2` line counts. ## Review history All review approval is on #27; this PR carries the identical diff. Re-review is not required but pre-commit gate has been verified: - `cargo fmt --all -- --check` — clean - `cargo clippy --all-targets --locked -- -D warnings` — clean - `cargo test --locked` — 14 / 14 pass - `cargo build --release --locked` — clean ## Stack context This is the second of an 8-PR kernel stack (PR #26 was the first; #25/#29/#28/#30/#24/#23 follow). Each subsequent PR's base will need to be updated to point at this PR's branch (`msrathore/kernel-napi-skeleton-to-main`) once it merges to main, mirroring the same re-target pattern. ## Files - `.github/workflows/napi-checks.yml` — CI workflow for the napi crate (fmt + clippy + test + release-build with `--locked`) - `Cargo.toml` — root workspace tweak so the napi sub-crate's standalone-workspace pattern works - `napi/.gitignore`, `napi/Cargo.toml`, `napi/Cargo.lock`, `napi/build.rs`, `napi/package.json` — crate manifest + napi-rs build glue - `napi/src/lib.rs` — crate root, `version()` napi export - `napi/src/error.rs` — kernel `Error` → napi `Error` envelope mapper + pyo3 field-parity guards - `napi/src/util.rs` — `guarded()` panic-catching wrapper + `panic = "abort"` compile-time guard - `napi/src/runtime.rs` — captured tokio `Handle` accessor + PERF NOTE + async-cleanup-hook TODO for PR #25 - `napi/src/logger.rs` — Round-3 logger bridge stub with inline design sketch Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
… classes Lands the four #[napi] classes that expose the kernel's v0 surface: - Database.open() returns a Database handle (Session) - Connection.execute_statement() returns a Statement handle - Statement.fetch_next_batch() / .schema() / .cancel() / .close() - ResultStream (used internally; not directly exposed) Results cross the FFI as Arrow IPC bytes (see result.rs); the TS adapter decodes them via apache-arrow. Builds on the skeleton commit; cargo check is clean. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…xecuteOptions JS callers passing initialCatalog/initialSchema/sessionConfig on executeStatement were silently no-op'd: the kernel does not read StatementSpec::statement_conf (zero readers across src/), and the SEA wire ExecuteStatementRequest has no per-statement catalog/schema/conf fields. They were stuffed into a dead HashMap and the statement ran against whatever the session was opened with. Mirror pyo3's design: expose catalog/schema/sessionConf on ConnectionOptions (openSession), routed through Session::builder().defaults(DefaultOpts) and .session_conf(HashMap) — the kernel APIs that actually populate SEA CreateSession.catalog / .schema / .session_confs. Drop ExecuteOptions entirely; executeStatement takes only the SQL. Cross-checked: JDBC SEA carries catalog/schema only on CreateSession, not ExecuteStatement (databricks-jdbc/.../sqlexec/CreateSessionRequest .java vs ExecuteStatementRequest.java). pyo3 exposes them only on Session.__new__ (pyo3/src/session.rs:73-141) and explicitly defers statement_conf to "later phases" (pyo3/src/statement.rs:39-40). BREAKING: napi executeStatement signature changes from (sql, options) -> (sql). NodeJS driver consumers must move initialCatalog/initialSchema/sessionConfig from per-statement forwarding to per-session openSession() options. Tracked downstream. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…ailures Connection::close was fire-and-forget on the premise that the kernel's Session::close().await holds a !Send EnteredSpan across an .await. Reading the kernel: Session::close uses .instrument(span).await, which keeps the future Send. The kernel also has a compile-time assert_send(&session.close()) test that fails the build if anyone flips that pattern. Fix: await session.close() and map errors. The kernel docstring on Session::close says it exists specifically so callers can observe a DeleteSession failure — restore that contract. On Err, the kernel leaves its closed flag false so Drop's fire-and-forget cleanup retries as a fallback; the caller still gets the error to surface. Drop stays fire-and-forget — Drop can't .await, period — but the stale !Send rationale comment is removed. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
- statement.rs: two round-trip tests pinning the Arrow IPC wire-format contract between the binding and the JS-side `apache-arrow` adapter. Schema-only payload yields 0 batches; schema+batch yields 1 batch with input rows preserved. Collapse 3 identical error-wrap lambdas into a local `arrow_err` helper. - statement.rs: docstring contracts — `fetchNextBatch` post-error recovery (close and discard); `cancel` is non-idempotent against natural completion (kernel hits the wire every time). - connection.rs / statement.rs: `Drop` impls memorialize the napi-rs-runtime-alive invariant so any future process-exit reorder surfaces the assumption rather than silently leaking handles. - Prune milestone roadmap markers from module-level docs; keep the technical WHY comments (Arc/Mutex rationale, #[non_exhaustive] arms, Send-safety). Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
… cached fields, idempotent cancel, kernel close retry contract
Summary of changes across kernel + binding:
- Kernel src/statement/executed.rs: reorder ExecutedStatement::close
to set `closed=true` only after a successful wire call, mirroring
Session::close. On wire failure the flag stays false so Drop's
fire-and-forget retry runs as a fallback — without this a transient
close failure silently leaks the server-side statement until session
expiry. Allows two callers racing through `&self` to both hit the
wire (server-side close is idempotent), trading one redundant RPC
for the retry contract.
- napi/src/statement.rs:
* Cache `schema: Arc<Schema>` and `statement_id: String` on the
wrapper at construction so they survive close() — JS callers
can still build error reports against a disposed Statement.
* Add `statementId` getter via #[napi(getter)].
* Idempotent cancel via `finished: AtomicBool` — set when
fetch_next_batch observes the natural end of stream, short-circuits
cancel() to Ok(()) so a defensive cancel after natural completion
no longer surfaces an opaque server-side error.
* Route closed-state errors through napi_err_from_kernel(
KernelError::invalid_statement_handle()) via a single
statement_closed_err() helper — TS adapter reviver gets typed
KernelError(code='InvalidStatementHandle') instead of raw
Status::InvalidArg with substring-only discrimination.
* Route the non-Arrow ResultBatch fallback through the envelope too,
include CARGO_PKG_VERSION so JS-side error reports pin which
binding version was in use.
* 6 new #[cfg(test)] unit tests pinning closed-state error envelope
shape, cached-field survival, Arc cheapness, and finished-flag
toggle.
- napi/src/connection.rs:
* Add `session_id: String` cached on the wrapper, exposed as
#[napi(getter)] — survives close() for log correlation.
* Same envelope-routed closed-state error via connection_closed_err()
helper.
* 3 new #[cfg(test)] unit tests for the closed-state envelope shape
and session_id survival.
- Both wrappers: soften Drop comments to "best-effort cleanup; we do
not guarantee delete_session / close_statement on process exit"
rather than asserting the uncited "unreachable under napi-rs's
current process-exit ordering."
- Both wrappers: rewrite the `inner` field doc-comments to honestly
describe the current single-mutex serialisation behaviour and link
the follow-up JIRA candidate that tracks the lock-shape split.
- napi/src/database.rs: rationale for free-fn-over-static-method
rewritten as the positive choice (no Database state to wrap) instead
of an uncited claim about napi-rs codegen fragility.
- napi/src/lib.rs: module-level surface description updated to match
the actual exports (openSession free fn + Connection + Statement +
ArrowBatch/ArrowSchema POJOs — no Database class, no ResultStream
class).
Test suite: 24/24 pass (was 16/16). All gates clean: cargo fmt
--check, cargo clippy --all-targets -- -D warnings, cargo test --lib.
The single-mutex concurrency limitation (cancel queues behind
fetchNextBatch; concurrent executeStatement calls serialise) is
documented but unfixed — the proper fix needs a kernel-side accessor
to expose ExecutedStatement as a shared Arc<dyn ExecutedStatementHandle>
plus a separate ResultStream slot. Tracked at
sea-workflow/jira-candidates/2026-05-24-napi-cancel-during-fetch.md.
Also-deferred: typed error refactor (LOW; existing JIRA candidate
2026-05-23-napi-typed-error-refactor.md), submit/async-consumption
path (LOW; M1 scope), parameter binding (LOW; M1 scope), fetchAll
convenience (LOW; JS-side SeaResultsProvider already wraps the
streaming primitive).
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Was: KernelError::internal() — pages oncall on telemetry false-positives
because Internal-category errors are interpreted as kernel bugs.
Now: KernelError::invalid_argument() — this isn't a kernel bug, it's
"binding too old for the kernel it's linked against" (the kernel rolled
a new ResultBatch variant that this binding's decode path doesn't know
how to handle). Matches the sibling-binding convention at
pyo3/src/fetch.rs:43,58.
The error message retains env!("CARGO_PKG_VERSION") so the JS-side
adapter surfaces actionable version-skew context to the user.
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…honesty, IPC capacity, field docs, executed_async close parity, cancel-after-parent-drop regression test Addresses 7 of the 20 review findings on PR #25 directly. Remaining findings are tracked as JIRA candidates in the NodeJS workflow repo under sea-workflow/jira-candidates/. - F1+F2 (napi/src/statement.rs): drop async from Statement::schema(). The body is pure CPU work over a cached Arc<Schema> and matches pyo3/src/statement.rs::arrow_schema (sync). napi-rs handles panic conversion for sync #[napi] entry points, so the util::guarded wrapper used by the remaining async methods is not required here. - F7/I4 (napi/src/{connection,statement}.rs): rewrite the close() JSDoc to honestly state that errors are terminal from the JS side. The kernel handle is .take()-ed before the wire call (because both Session::close and ExecutedStatement::close consume the handle by value or via the close-flag pattern), so a JS-side retry sees an already-closed wrapper and returns Ok(()). Only the kernel-level Drop fires a single fire-and-forget retry. The old JSDoc claim that callers could observe and retry close failures was misleading. - F14 (napi/src/statement.rs::encode_ipc_stream): pre-size the IPC buffer with Vec::with_capacity( batch.map(get_array_memory_size).unwrap_or(0) + 4096) instead of Vec::new(). Removes ~17 reallocations on a typical 500 KB batch; 4 KiB slack covers schema header + IPC framing overhead. - F18 (napi/src/result.rs): add /// field-level docs on ArrowBatch.ipc_bytes and ArrowSchema.ipc_bytes so the generated .d.ts carries the "Decode with apache-arrow's RecordBatchReader" hint. - F3+F10 (src/statement/executed_async.rs): mirror the new load -> wire -> store-on-success close pattern from ExecutedStatement::close into ExecutedAsyncStatement::close. Restores symmetric retry-on-failure contract across both executed handles. The retry branch is currently dead code because the SEA transport (src/client/sea.rs::close_statement) swallows errors; tracked as a follow-up kernel PR in the JIRA candidate file. Until the transport surfaces errors, the new pattern is forward-prep with identical observable behavior to the previous swap pattern. - F9 (tests/v0_execute_wiremock.rs): add kernel_invariant_parent_drop_invalidates_executed_cancel. Pins the kernel-level invariant that PR #29's binding-side fix is designed around: dropping the parent Statement invalidates any outstanding ExecutedStatement's validity flag, so a subsequent cancel() short-circuits locally with InvalidStatementHandle. PR #29's StatementInner { _parent, executed } shape keeps the parent alive to avoid hitting this short-circuit. This test fails loudly if the kernel ever weakens the parent-drop semantic. Refs: vikrantpuppala PR #25 review at 2026-05-25T15:40-15:44Z (F1/F2/F3/F7/F9/F10/F14/F18). Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
When the binding's Statement wrapper was first written it held only
the kernel's ExecutedStatement. The sea-operation feature surfaced a
bug: kernel Statement::Drop invalidates its produced ExecutedStatement
via a shared ValidityFlag, so the parent kernel Statement constructed
in Connection::execute_statement was dropping at the end of that
function and rendering every subsequent cancel()/close() on the
executed handle a no-op throwing InvalidStatementHandle.
Fix: introduce StatementInner { _parent: KernelStatement, executed }
in the wrapper so both lifetimes are tied. Statement::from_executed
now takes the parent statement alongside the executed handle.
Connection::execute_statement passes both in. ValidityFlag stays set
for as long as JS holds the wrapper.
Originally landed in the nodejs sea-operation worktree (e06a5e8);
relocated here as part of the napi-source move into the kernel
workspace. The integration branch's version was the authoritative one
because it had all downstream feature merges layered in.
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…nticated Per src/kernel_error.rs:74-77 doc-comment, Unauthenticated is the intended ErrorCode for "Server returned HTTP 401 (or OIDC discovery rejected the token request)". M2M and U2M token-exchange paths were using Error::io() (-> Internal), which is reserved for kernel-side I/O / parsing failures. The misclassification caused authentication failures to surface in NodeJS as HiveDriverError instead of AuthenticationError (D-015). Fix: m2m.rs:270 and u2m.rs:433 swap Error::io() -> Error::unauthenticated(). No kernel unit tests assert ErrorCode::Internal on these paths (verified by grep) so no test updates are needed. The U2M test `test_u2m_cache_miss_with_expired_refresh` asserts only `result.is_err()`, which remains true. Deferred (worth a follow-up): distinguish oauth2::RequestTokenError subtypes so 5xx token-endpoint failures get NetworkError while invalid_client / invalid_grant / unauthorized_client stay Unauthenticated. The current change correctly handles the dominant case (bad-credentials -> 400/401 from server) and matches the existing kernel doc-comment intent. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Matches the JDBC driver's `HttpConnectionPoolSize` default (100) and the kernel-internal `HttpClientConfig` default. Closes ~9x of the throughput gap with the NodeJS thrift driver's `maxSockets: Infinity` default for high-concurrency workloads (bursty parallel executeStatement, parallel CloudFetch chunk downloads). reqwest/hyper does not bound this; the prior 10 was a kernel-side conservative choice. Spec: sea-workflow/specs/07-errors-retries/connection-pool-default-mismatch.md Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…ion.rs
The kernel has had working reqwest plumbing for custom CA certs,
self-signed acceptance, and hostname-verification skip at
client/http.rs since the original TLS migration. That implementation
has been unreachable from any public wrapper because (a) the public
TlsConfig struct in config.rs was empty and (b) session.rs explicitly
discarded any caller-supplied TlsConfig and replaced with default.
This commit:
- Adds custom_ca_cert / accept_self_signed /
skip_hostname_verification fields to public TlsConfig
- Adds a trusted_certificate_pem field to the internal
HttpTlsConfig so the public custom_ca_cert (Vec<u8>) can flow
through without a tempfile shim — foreign-language wrappers
(napi-rs Buffer / pyo3 bytes) get a direct path
- Adds HttpTlsConfig::from_public / From<&public::TlsConfig> to
project the public surface onto the internal layer
- Wires session.rs::build_http_client_config to call
HttpTlsConfig::from_public(&config.tls) instead of discarding
- Adds a custom Debug impl on the public TlsConfig that
summarises the cert bytes ("<N bytes>") instead of dumping the
whole PEM into log lines
- Adds builder-introspection tests that construct a
DatabricksHttpClient via the public -> internal mapping with
each flag in turn and verify the reqwest builder succeeds
Public TlsConfig defaults remain strict: accept_self_signed=false,
skip_hostname_verification=false, custom_ca_cert=None. The default
projection produces an internal config with `None` everywhere on
the permissive switches so RUST_LOG output stays free of no-op
overrides.
Unblocks NodeJS-side TLS Buffer->tempfile shim row (kernel now
accepts Vec<u8> directly; no tempfile needed) and is a prereq for
future mTLS work (client_cert / client_key remain unwired — that's
a separate follow-up).
The pre-existing lib-test failure in client::http::tests::
test_http_client_with_invalid_pem (D-016: reqwest::Certificate::
from_pem accepts garbage strings under the rustls-tls backend) is
unrelated to this commit and reproduces on the krn-napi-binding
base.
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
force-pushed
the
msrathore/krn-connection-pool-default-bump
branch
from
May 25, 2026 19:20
122e6d3 to
c14c1ff
Compare
msrathore-db
force-pushed
the
msrathore/krn-tls-public-api
branch
from
May 25, 2026 19:20
ba63971 to
8c0aabc
Compare
vikrantpuppala
pushed a commit
that referenced
this pull request
May 26, 2026
…3/8) (#25) ## Stack Linear stack of 8 PRs on `databricks/databricks-sql-kernel` landing the **SEA-driver kernel-side enablement** work. Merge in order from base ↑ to tip. The tip branch (`msrathore/krn-status-fields`, PR [#23](#23)) is the single snapshot containing every kernel-side change in flight. | Pos | PR | Branch | Scope | |---|---|---|---| | 1/8 | [#26](#26) | `kernel-async-public-api` | Remove `block_on` from ResultStream + Send-safety on Statement + rustls-tls + e2e test ported from [#20](#20) | | 2/8 | [#27](#27) | `kernel-napi-skeleton` | napi-rs binding crate skeleton: Cargo manifest + lib + error envelope + util + runtime + logger | | 3/8 | [#25](#25) | `kernel-napi-classes` | Database / Connection / Statement / ResultStream napi classes | | 4/8 | [#29](#29) | `kernel-napi-statement-validity` | StatementInner ValidityFlag fix propagated from sea-operation | | 5/8 | [#28](#28) | `kernel-oauth-error-class` | Reclassify OAuth token-exchange failures as `Error::unauthenticated()` (2-line fix in auth/oauth/m2m.rs + u2m.rs) | | 6/8 | [#30](#30) | `krn-connection-pool-default-bump` | Bump `HttpConfig.pool_max_idle_per_host` default from 10 → 100 | | 7/8 | [#24](#24) | `krn-tls-public-api` | Expose `TlsConfig` fields (custom_ca_cert + accept_self_signed + skip_hostname_verification) + stop discarding in session.rs | | 8/8 | [#23](#23) | `krn-status-fields` **← TIP** | Expose 5 status accessors on `ExecutedStatement` (num_modified_rows / progress / display_message / diagnostic_info / error_details_json) | **Companion NodeJS stack** (`databricks/databricks-sql-nodejs`): 8 PRs — root [#378](databricks/databricks-sql-nodejs#378) (sea-abstraction) → [#380](databricks/databricks-sql-nodejs#380) → [#377](databricks/databricks-sql-nodejs#377) → [#379](databricks/databricks-sql-nodejs#379) → [#382](databricks/databricks-sql-nodejs#382) → [#381](databricks/databricks-sql-nodejs#381) → [#384](databricks/databricks-sql-nodejs#384) → [#383](databricks/databricks-sql-nodejs#383) (tip). **Policy:** new PRs always stack on the current tip. No sibling/parallel topology. No force-pushes on existing PRs unless absolutely necessary; if a PR's content is wrong, add a fix-up commit on top of the stack tip rather than rewriting history. --- **This PR is position 3/8.** ##⚠️ Must merge together with PR #29 In isolation, this PR ships a known cancel-lifecycle bug: the first call to `Statement.cancel()` from JS returns `KernelError(InvalidStatementHandle)` instead of cancelling the in-flight statement. **Root cause** — `Connection::execute_statement` (`napi/src/connection.rs:99-104`) builds a local kernel `Statement`, awaits `stmt.execute()`, hands the resulting `ExecutedStatement` to the JS-side `Statement` wrapper, then drops the parent kernel `Statement` at end of the closure. The kernel's `Drop for Statement` (`src/statement/mutable.rs:440-450`) calls `valid.invalidate()` on the shared `ValidityFlag`. The next `Statement.cancel()` from JS reaches `ExecutedStatement::cancel()` → `self.valid.check()` → `KernelError(InvalidStatementHandle)`. **Fix** — PR [#29](#29) (next in the stack) wraps the inner state in a `StatementInner { _parent: KernelStatement, executed: ExecutedStatement }` struct that keeps the parent alive for the wrapper's lifetime. With #29 applied, the cancel lifecycle works correctly on the first call. **Stack-merge policy** — these two PRs must merge as a pair (default Github stacked-PR flow handles this). Do not merge #25 to main without #29 in the same merge train. Reviewers approving #25 in isolation should approve #29 as part of the same approval pass. ## Summary Adds the four user-facing `#[napi]` classes that expose the kernel's v0 surface to JS consumers. ~504 LOC across 4 files plus a 4-line `lib.rs` update to declare the new modules. **Classes:** - `Database` — `Database.open()` returns a Session handle - `Connection` — `Connection.execute_statement()` returns a Statement handle - `Statement` — `fetchNextBatch()` / `schema()` / `cancel()` / `close()` - `ResultStream` (internal) — used by Statement; not directly exposed Results cross the FFI as Arrow IPC bytes (see `result.rs`); the TS adapter decodes via `apache-arrow`. Together with the skeleton PR [#27](#27), this delivers the full Round 2 napi surface. ## Test plan - `cargo check -p databricks-sea-native` clean - Downstream NodeJS `npm run build:native` produces a working `.node` artifact against this stack - Downstream OAuth M2M e2e green at `sea-auth-u2m@e7c979d` building against this binding ## Tracking - [PECOBLR-2670](https://databricks.atlassian.net/browse/PECOBLR-2670) — Make the async interface for rust kernel — napi classes - Parent epic: [PECOBLR-2666](https://databricks.atlassian.net/browse/PECOBLR-2666) Co-authored-by: Isaac [PECOBLR-2670]: https://databricks.atlassian.net/browse/PECOBLR-2670?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
vikrantpuppala
pushed a commit
that referenced
this pull request
May 26, 2026
…on (stack 4/8) (#29) ## Stack Linear stack of 8 PRs on `databricks/databricks-sql-kernel` landing the **SEA-driver kernel-side enablement** work. Merge in order from base ↑ to tip. The tip branch (`msrathore/krn-status-fields`, PR [#23](#23)) is the single snapshot containing every kernel-side change in flight. | Pos | PR | Branch | Scope | |---|---|---|---| | 1/8 | [#26](#26) | `kernel-async-public-api` | Remove `block_on` from ResultStream + Send-safety on Statement + rustls-tls + e2e test ported from [#20](#20) | | 2/8 | [#27](#27) | `kernel-napi-skeleton` | napi-rs binding crate skeleton: Cargo manifest + lib + error envelope + util + runtime + logger | | 3/8 | [#25](#25) | `kernel-napi-classes` | Database / Connection / Statement / ResultStream napi classes | | 4/8 | [#29](#29) | `kernel-napi-statement-validity` | StatementInner ValidityFlag fix propagated from sea-operation | | 5/8 | [#28](#28) | `kernel-oauth-error-class` | Reclassify OAuth token-exchange failures as `Error::unauthenticated()` (2-line fix in auth/oauth/m2m.rs + u2m.rs) | | 6/8 | [#30](#30) | `krn-connection-pool-default-bump` | Bump `HttpConfig.pool_max_idle_per_host` default from 10 → 100 | | 7/8 | [#24](#24) | `krn-tls-public-api` | Expose `TlsConfig` fields (custom_ca_cert + accept_self_signed + skip_hostname_verification) + stop discarding in session.rs | | 8/8 | [#23](#23) | `krn-status-fields` **← TIP** | Expose 5 status accessors on `ExecutedStatement` (num_modified_rows / progress / display_message / diagnostic_info / error_details_json) | **Companion NodeJS stack** (`databricks/databricks-sql-nodejs`): 8 PRs — root [#378](databricks/databricks-sql-nodejs#378) (sea-abstraction) → [#380](databricks/databricks-sql-nodejs#380) → [#377](databricks/databricks-sql-nodejs#377) → [#379](databricks/databricks-sql-nodejs#379) → [#382](databricks/databricks-sql-nodejs#382) → [#381](databricks/databricks-sql-nodejs#381) → [#384](databricks/databricks-sql-nodejs#384) → [#383](databricks/databricks-sql-nodejs#383) (tip). **Policy:** new PRs always stack on the current tip. No sibling/parallel topology. No force-pushes on existing PRs unless absolutely necessary; if a PR's content is wrong, add a fix-up commit on top of the stack tip rather than rewriting history. --- **This PR is position 4/8.** ## Why this PR is structurally required (not redundant with PR #25) Reviewers may notice this PR's diff against the new PR [#25](#25) tip looks like a follow-up nicety — it is not. It is a **correctness fix** for a real lifecycle bug PR #25 ships in isolation. **The bug** — PR #25's `Connection::execute_statement` builds a local kernel `Statement`, awaits `stmt.execute()`, hands the resulting `ExecutedStatement` to the JS-side `Statement` wrapper, then drops the parent kernel `Statement` at end of the closure. The kernel's `Drop for Statement` (`src/statement/mutable.rs:440-450`) calls `valid.invalidate()` on the shared `ValidityFlag` between the parent and the executed handle. The next `Statement.cancel()` from JS reaches `ExecutedStatement::cancel()` → `self.valid.check()` → `KernelError(InvalidStatementHandle)` — the **first** cancel call is broken. **The fix** — this PR wraps the inner state in `StatementInner { _parent: KernelStatement, executed: ExecutedStatement }`, keeping the parent alive for the JS wrapper's lifetime. The shared `ValidityFlag` stays set, so cancel works on the first call. **Stack-merge policy** — PR #25 and this PR must merge as a pair (default Github stacked-PR flow handles this). The PR #25 description carries a corresponding warning. Do not merge #25 to main without this PR in the same merge train. No new tests are added here — the closed-state assertions on PR #25's `Statement::cancel()` pin the typed-error contract for the parent-dropped case, and the cancel-after-completion idempotency tests pin the JDBC contract. Both continue to pass on the merged state. End-to-end cancel-during-fetch coverage is tracked as part of the lock-shape refactor follow-up at `sea-workflow/jira-candidates/2026-05-24-napi-cancel-during-fetch.md`. ## Summary Ports the StatementInner ValidityFlag fix from the NodeJS sea-operation worktree into the kernel-side napi crate (~89 LOC, 2 files). Adds the parent-Statement-keep-alive wrapper to `napi::Statement`'s inner state so the executed handle's `ValidityFlag` stays set for the JS wrapper's lifetime. The fix was originally authored downstream in the NodeJS worktree's vendored napi copy; landing it on the kernel-side napi crate keeps the two consistent until D-006 consolidation closes the vendoring gap. ## Test plan - `cargo test` clean (24/24 lib tests pass against the merged PR #25 + #29 state) - Downstream NodeJS `sea-operation` feature already validates the fix in JS-side unit tests ## Tracking - [PECOBLR-2917](https://databricks.atlassian.net/browse/PECOBLR-2917) — Fix napi binding SIGSEGV — StatementInner ValidityFlag - Parent epic: [PECOBLR-2666](https://databricks.atlassian.net/browse/PECOBLR-2666) Co-authored-by: Isaac [PECOBLR-2917]: https://databricks.atlassian.net/browse/PECOBLR-2917?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
added a commit
that referenced
this pull request
May 26, 2026
…ted (stack 5/8) (#28) ## Stack Linear stack of 8 PRs on `databricks/databricks-sql-kernel` landing the **SEA-driver kernel-side enablement** work. Merge in order from base ↑ to tip. The tip branch (`msrathore/krn-status-fields`, PR [#23](#23)) is the single snapshot containing every kernel-side change in flight. | Pos | PR | Branch | Scope | |---|---|---|---| | 1/8 | [#26](#26) | `kernel-async-public-api` | Remove `block_on` from ResultStream + Send-safety on Statement + rustls-tls + e2e test ported from [#20](#20) | | 2/8 | [#27](#27) | `kernel-napi-skeleton` | napi-rs binding crate skeleton: Cargo manifest + lib + error envelope + util + runtime + logger | | 3/8 | [#25](#25) | `kernel-napi-classes` | Database / Connection / Statement / ResultStream napi classes | | 4/8 | [#29](#29) | `kernel-napi-statement-validity` | StatementInner ValidityFlag fix propagated from sea-operation | | 5/8 | [#28](#28) | `kernel-oauth-error-class` | Reclassify OAuth token-exchange failures as `Error::unauthenticated()` (2-line fix in auth/oauth/m2m.rs + u2m.rs) | | 6/8 | [#30](#30) | `krn-connection-pool-default-bump` | Bump `HttpConfig.pool_max_idle_per_host` default from 10 → 100 | | 7/8 | [#24](#24) | `krn-tls-public-api` | Expose `TlsConfig` fields (custom_ca_cert + accept_self_signed + skip_hostname_verification) + stop discarding in session.rs | | 8/8 | [#23](#23) | `krn-status-fields` **← TIP** | Expose 5 status accessors on `ExecutedStatement` (num_modified_rows / progress / display_message / diagnostic_info / error_details_json) | **Companion NodeJS stack** (`databricks/databricks-sql-nodejs`): 8 PRs — root [#378](databricks/databricks-sql-nodejs#378) (sea-abstraction) → [#380](databricks/databricks-sql-nodejs#380) → [#377](databricks/databricks-sql-nodejs#377) → [#379](databricks/databricks-sql-nodejs#379) → [#382](databricks/databricks-sql-nodejs#382) → [#381](databricks/databricks-sql-nodejs#381) → [#384](databricks/databricks-sql-nodejs#384) → [#383](databricks/databricks-sql-nodejs#383) (tip). **Policy:** new PRs always stack on the current tip. No sibling/parallel topology. No force-pushes on existing PRs unless absolutely necessary; if a PR's content is wrong, add a fix-up commit on top of the stack tip rather than rewriting history. --- **This PR is position 5/8.** ## Summary **Two-line fix.** Changes `Error::io()` → `Error::unauthenticated()` in two OAuth token-exchange catch arms: - `src/auth/oauth/m2m.rs:270` - `src/auth/oauth/u2m.rs:433` ## Why The previous classification surfaced OAuth credential rejections as a generic IO error → downstream JS `SeaErrorMapping` decoder produced `HiveDriverError`. The correct semantics are `AuthenticationError` (typed). This 2-line change unblocks the NodeJS M2M bad-secret e2e at `sea-auth-u2m@e7c979d` (which now correctly raises `instanceof AuthenticationError`). ## Deferred follow-up Precise classification of `oauth2::RequestTokenError` subtypes (5xx token-endpoint failures, transport errors → `NetworkError` instead of `Unauthenticated`). Tracked as NF3-1 in the NodeJS round-3 review chain; non-blocking today because JS-side retry policy isn't yet wired through SEA. ## Tracking - [PECOBLR-2878](https://databricks.atlassian.net/browse/PECOBLR-2878) — Error class hierarchy expansion — reclassify OAuth as Unauthenticated - Parent epic: [PECOBLR-2666](https://databricks.atlassian.net/browse/PECOBLR-2666) Co-authored-by: Isaac [PECOBLR-2878]: https://databricks.atlassian.net/browse/PECOBLR-2878?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
force-pushed
the
msrathore/krn-connection-pool-default-bump
branch
from
May 26, 2026 09:57
c14c1ff to
a408cd5
Compare
Collaborator
Author
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.
Stack
Linear stack of 8 PRs on
databricks/databricks-sql-kernellanding the SEA-driver kernel-side enablement work. Merge in order from base ↑ to tip. The tip branch (msrathore/krn-status-fields, PR #23) is the single snapshot containing every kernel-side change in flight.kernel-async-public-apiblock_onfrom ResultStream + Send-safety on Statement + rustls-tls + e2e test ported from #20kernel-napi-skeletonkernel-napi-classeskernel-napi-statement-validitykernel-oauth-error-classError::unauthenticated()(2-line fix in auth/oauth/m2m.rs + u2m.rs)krn-connection-pool-default-bumpHttpConfig.pool_max_idle_per_hostdefault from 10 → 100krn-tls-public-apiTlsConfigfields (custom_ca_cert + accept_self_signed + skip_hostname_verification) + stop discarding in session.rskrn-status-fields← TIPExecutedStatement(num_modified_rows / progress / display_message / diagnostic_info / error_details_json)Companion NodeJS stack (
databricks/databricks-sql-nodejs): 8 PRs — root #378 (sea-abstraction) → #380 → #377 → #379 → #382 → #381 → #384 → #383 (tip).Policy: new PRs always stack on the current tip. No sibling/parallel topology. No force-pushes on existing PRs unless absolutely necessary; if a PR's content is wrong, add a fix-up commit on top of the stack tip rather than rewriting history.
This PR is position 7/8.
Summary
Makes the public
TlsConfigactually configurable. The rustls plumbing for custom CA certs, self-signed acceptance, and hostname-verification skip has existed atsrc/client/http.rs:75-95since the rustls migration — it was just unreachable because (a) the publicTlsConfigstruct inconfig.rswas empty and (b)session.rs:529,537explicitly discarded any caller-suppliedTlsConfigand replaced with default.This PR exposes the existing implementation. No new TLS code — only public surface + wiring.
Changes
1. Public
TlsConfig(src/config.rs:346-352) — was#[non_exhaustive] pub struct TlsConfig {}, now:Custom
Debugimpl prints"<N bytes>"instead of dumping PEM contents.2.
session.rs:529,537—HttpTlsConfig::default()replaced withHttpTlsConfig::from_public(&config.tls).3.
HttpTlsConfig— addedtrusted_certificate_pem: Option<Vec<u8>>alongside existingtrusted_certificate_path(kept for legacy ADBC code path).http.rsadds the in-memory PEM as an additional root cert when set.Out of scope
Test plan
cargo test --lib config tls_configcargo check --workspacecleancargo clippy --all-targets -- -D warningscleanUnblocks
Vec<u8>→ no tempfile needed)Tracking
Co-authored-by: Isaac