Repository navigation
fix(napi): propagate StatementInner ValidityFlag fix from sea-operation (stack 4/8) - #29
Merged
vikrantpuppala merged 1 commit intoMay 26, 2026
Conversation
This was referenced May 16, 2026
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 17, 2026 13:15
2eff8ed to
edaebc0
Compare
This was referenced May 17, 2026
Closed
This was referenced May 17, 2026
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 20, 2026 10:36
edaebc0 to
ddbad30
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
2 times, most recently
from
May 20, 2026 16:55
898e46c to
51cc7f1
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 20, 2026 16:55
ddbad30 to
cccedf5
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 20, 2026 20:22
51cc7f1 to
4517677
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 20, 2026 20:22
cccedf5 to
b77c150
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 21, 2026 00:03
4517677 to
350a0ec
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 21, 2026 00:03
b77c150 to
b5d78e0
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 23, 2026 11:03
350a0ec to
d8f7a27
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 23, 2026 11:03
b5d78e0 to
ca82f09
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 23, 2026 11:30
d8f7a27 to
b5d0ec3
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 23, 2026 11:30
ca82f09 to
3f1673e
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 23, 2026 21:48
b5d0ec3 to
9a6161d
Compare
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
4 times, most recently
from
May 24, 2026 18:43
66220e0 to
9c04b0b
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>
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 25, 2026 07:33
ae27b2d to
96dfa69
Compare
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>
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 25, 2026 10:07
96dfa69 to
e684c4c
Compare
msrathore-db
added a commit
that referenced
this pull request
May 25, 2026
…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>
msrathore-db
force-pushed
the
msrathore/kernel-napi-classes
branch
from
May 25, 2026 19:09
e684c4c to
9c56fbe
Compare
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>
msrathore-db
force-pushed
the
msrathore/kernel-napi-statement-validity
branch
from
May 25, 2026 19:20
9c04b0b to
4acde6a
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
approved these changes
May 26, 2026
msrathore-db
added a commit
that referenced
this pull request
May 26, 2026
…on (re-target to main) (#78) ## Summary Re-targets the StatementInner ValidityFlag fix that was originally landed in PR #29 against `main`. PR #29 (`fix(napi): propagate StatementInner ValidityFlag fix from sea-operation (stack 4/8)`) was inadvertently merged into the stack-parent branch `msrathore/kernel-napi-classes` instead of into `main`. Since `msrathore/kernel-napi-classes` (PR #25) has since been squash-merged into `main`, the validity fix never reached `main` — `ea4d398` on `main` is just the PR #25 squash, missing the validity flag fix. ## What's in this PR Two commits: 1. **`bdc1e2a` — cherry-pick of PR #29's commit `4acde6a`** ("napi: propagate StatementInner ValidityFlag fix from sea-operation"). Untouched content; pure cherry-pick. Changes `napi/src/connection.rs` + `napi/src/statement.rs` (90 lines). 2. **`4245a2c` — `cargo fmt --all` chore-fixup** to clear inherited rustfmt drift on `src/metadata/static_data.rs`, `src/metadata/type_mapping.rs`, `src/reader/mod.rs`. These files are pre-existing on `main` at `ea4d398` (confirmed by running `cargo +stable fmt --all -- --check` against `origin/main`). Pure mechanical fmt; no semantic change. ## Why the validity fix matters From PR #29's commit message: kernel `Statement::Drop` invalidates its produced `ExecutedStatement` via a shared `ValidityFlag`. The parent kernel `Statement` constructed in `Connection::execute_statement` was dropping at the end of that function, rendering every subsequent `cancel()`/`close()` on the executed handle a no-op throwing `InvalidStatementHandle`. This PR introduces `StatementInner { _parent: KernelStatement, executed }` 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. ## Gates Verified on this branch (`4245a2c`): - `cargo +stable fmt --all -- --check` — EXIT 0 - `cargo clippy --all-targets -- -D warnings` — EXIT 0 - `cargo test --lib` — 441/441 passing ## History - Original PR: [#29](#29) (merged to `msrathore/kernel-napi-classes` at `f4fa428` instead of `main`). - Tracking JIRA: PECOBLR-2917 (concurrency / SIGSEGV class of issues this fix addresses). --------- 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>
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 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 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_statementbuilds a local kernelStatement, awaitsstmt.execute(), hands the resultingExecutedStatementto the JS-sideStatementwrapper, then drops the parent kernelStatementat end of the closure. The kernel'sDrop for Statement(src/statement/mutable.rs:440-450) callsvalid.invalidate()on the sharedValidityFlagbetween the parent and the executed handle. The nextStatement.cancel()from JS reachesExecutedStatement::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 sharedValidityFlagstays 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 atsea-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'sValidityFlagstays 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 testclean (24/24 lib tests pass against the merged PR feat(napi): openSession / Connection / Statement napi surface (stack 3/8) #25 + fix(napi): propagate StatementInner ValidityFlag fix from sea-operation (stack 4/8) #29 state)sea-operationfeature already validates the fix in JS-side unit testsTracking
Co-authored-by: Isaac