Skip to content

feat(config): bump HttpConfig pool_max_idle_per_host default 10 → 100 (stack 6/8) - #30

Closed
msrathore-db wants to merge 1 commit into
mainfrom
msrathore/krn-connection-pool-default-bump
Closed

msrathore-db wants to merge 1 commit into
mainfrom
msrathore/krn-connection-pool-default-bump

Conversation

@msrathore-db

@msrathore-db msrathore-db commented May 17, 2026 •

Copy link
Copy Markdown
Collaborator

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) is the single snapshot containing every kernel-side change in flight.

Pos PR Branch Scope
1/8 #26 kernel-async-public-api Remove block_on from ResultStream + Send-safety on Statement + rustls-tls + e2e test ported from #20
2/8 #27 kernel-napi-skeleton napi-rs binding crate skeleton: Cargo manifest + lib + error envelope + util + runtime + logger
3/8 #25 kernel-napi-classes Database / Connection / Statement / ResultStream napi classes
4/8 #29 kernel-napi-statement-validity StatementInner ValidityFlag fix propagated from sea-operation
5/8 #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 krn-connection-pool-default-bump Bump HttpConfig.pool_max_idle_per_host default from 10 → 100
7/8 #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 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 (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 6/8.

Summary

Bumps the default of HttpConfig::pool_max_idle_per_host from 10 to 100 (~3 LOC of substantive change + a test).

Why

thrift NodeJS uses Node's http.Agent({ maxSockets: Infinity }) by default — effectively unbounded connections per host. The Rust kernel defaults pool_max_idle_per_host to 10. On high-concurrency NodeJS-SEA workloads, SEA caps connections at 10 while thrift saturates the host. Closing this gap by bumping to 100 gives ~9× throughput headroom on parallel-query workloads without exposing a new public field.

Phase 2 (separate work) will promote pool_max_idle_per_host to a user-tunable JS-side option via the napi binding; spec'd in driver.md#27.

Changes

  • src/config.rs: default value bumped from 10 → 100; docstring updated
  • src/config.rs:617-622: new test http_config_default_pool_max_idle_per_host_is_100 verifies the new default

Test plan

  • cargo test --lib --workspace http_config_default_pool — 1/1 passing
  • cargo test --lib --workspace — full lib suite still green (1 pre-existing PEM flake D-016 unrelated)
  • cargo clippy --all-targets -- -D warnings clean

Spec

07-errors-retries/connection-pool-default-mismatch.md — full rationale + Phase 1/Phase 2 plan.

Tracking

Co-authored-by: Isaac

@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from c7e6399 to b896baf Compare May 17, 2026 13:15
@msrathore-db
msrathore-db changed the base branch from msrathore/kernel-async-public-api to msrathore/kernel-oauth-error-class May 17, 2026 13:15
@msrathore-db msrathore-db changed the title feat(config): bump HttpConfig pool_max_idle_per_host default 10 → 100 feat(config): bump HttpConfig pool_max_idle_per_host default 10 → 100 (stack 6/8) May 17, 2026
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from b896baf to bb2dc5e Compare May 20, 2026 10:36
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch 2 times, most recently from 5199c59 to 3333527 Compare May 20, 2026 16:55
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from bb2dc5e to 54e5800 Compare May 20, 2026 16:55
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from 3333527 to f6a3a0e Compare May 20, 2026 20:22
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from 54e5800 to 86d21b4 Compare May 20, 2026 20:22
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from f6a3a0e to 6db8e4d Compare May 21, 2026 00:03
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from 86d21b4 to f13abf5 Compare May 21, 2026 00:03
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from 6db8e4d to f3505e7 Compare May 23, 2026 11:03
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from f13abf5 to 3a5ba83 Compare May 23, 2026 11:03
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from f3505e7 to fb8bcfb Compare May 23, 2026 11:30
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from 3a5ba83 to 97515ae Compare May 23, 2026 11:30
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from fb8bcfb to de6966d Compare May 23, 2026 21:48
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from 97515ae to 0e66279 Compare May 23, 2026 21:48
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from de6966d to 5badf23 Compare May 24, 2026 15:54
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from 0e66279 to 0fd53f1 Compare May 24, 2026 15:54
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from 5badf23 to 4c83f26 Compare May 24, 2026 18:09
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from 0fd53f1 to f7bcc87 Compare May 24, 2026 18:09
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from 4c83f26 to 185096c Compare May 24, 2026 18:43
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from f7bcc87 to 122e6d3 Compare May 24, 2026 18:43
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>
@msrathore-db
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from 185096c to 09472d7 Compare May 25, 2026 19:20
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from 122e6d3 to c14c1ff Compare May 25, 2026 19:20
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
msrathore-db force-pushed the msrathore/kernel-oauth-error-class branch from 09472d7 to 17772cf Compare May 26, 2026 09:46
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>
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>
@msrathore-db
msrathore-db force-pushed the msrathore/krn-connection-pool-default-bump branch from c14c1ff to a408cd5 Compare May 26, 2026 09:57
@msrathore-db
msrathore-db changed the base branch from msrathore/kernel-oauth-error-class to main May 26, 2026 09:57
@msrathore-db

Copy link
Copy Markdown
Collaborator Author

Closing — superseded by the configurable-per-binding approach. The kernel default HttpConfig::pool_max_idle_per_host stays at the conservative 10. Each binding now sets its own default when constructing the session: napi defaults to 100 (encoded in PR #74's napi/src/database.rs), pyo3 stays at the kernel default of 10. Users can still override via the binding's API.

msrathore-db added a commit that referenced this pull request May 26, 2026
Make the binding-specific default explicit instead of relying on the
kernel core's HttpConfig::default() — that default stays at the
conservative kernel value (10), and each binding chooses its own
user-facing default when constructing the session.

The napi binding's default is 100, matching the JDBC driver's
HttpConnectionPoolSize and closing the throughput gap vs the NodeJS
Thrift driver's maxSockets: Infinity for bursty workloads
(concurrent executeStatement, parallel CloudFetch chunk downloads).

Encoded as the public NAPI_DEFAULT_POOL_MAX_IDLE_PER_HOST constant
so reviewers and downstream binding authors can see the per-binding
default policy. The pyo3 binding inherits the kernel default of 10
(matching Python urllib3's maxsize=10).

Supersedes the closed PR #30 which would have lifted the kernel
default itself — that conflated 'napi wants 100' with 'every kernel
consumer wants 100', and the per-binding split is the right shape.

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant