Repository navigation
feat(kernel): async public API — remove block_on + Send-safety on Statement + rustls-tls (stack 1/8) - #26
Conversation
krn-async-public-api: remove block_on from ResultStream and async public surface. ResultStream::next_batch and ResultReaderAdapter / OwnedBatchIter were declared async but the wrapped ResultReader trait was sync, forcing CloudFetchResultReader to call self.runtime_handle.block_on on its async StreamingCloudFetchProvider. When ResultStream::next_batch().await ran from napi-rs's tokio runtime this triggered tokio's nested-runtime safety check and panicked. Made the kernel-internal ResultReader trait async (via async_trait, already a dependency). CloudFetchResultReader now awaits its provider directly. ResultStream::from_reader becomes pub(crate) async fn (schema is pulled asynchronously); ResultStream::next_batch awaits the reader without block_on; in-memory readers (InMemoryReader, EmptyReader, InlineArrowReader, the four test mocks) gain async impls that resolve immediately. OwnedBatchIter and ResultReaderAdapter keep their sync Iterator surfaces via futures::executor::block_on (executor-agnostic, not tokio), with doc-comments noting that CloudFetch consumers must drive them from inside a tokio context. No new dependencies. Sync C ABI in src/ffi/ unchanged (still unimplemented!()). Files: src/reader/mod.rs, src/reader/test_utils.rs, src/result_stream.rs, src/statement/mutable.rs, src/statement/executed_async.rs, src/metadata_v0.rs, src/metadata/static_data.rs Tests: cargo check pass, cargo test --lib pass (366 passed) Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…to rustls-tls
Two coupled changes that unblock the napi-rs binding for Round 2:
1. Statement::execute / Statement::submit are now Send.
Both methods held a tracing::EnteredSpan (!Send) across .await
boundaries via `let _g = self.session.log_span().clone().entered();`.
napi-rs's execute_tokio_future requires Send, so calling
Statement::execute().await from a #[napi] async fn failed to
compile. Switch the per-method span entry from .entered() to
wrapping the body in `async { … }.instrument(span)`. Identical
observable behaviour; resulting future is Send because
tracing::Span is Send (only EnteredSpan is !Send).
2. reqwest features: native-tls → rustls-tls.
When loaded into Node 24 (openssl 3.x statically linked), the
binding crashes with SIGSEGV at require() time because the
kernel's native-tls dynamic-links openssl 1.1, which collides
with Node's symbols. rustls is pure Rust + ring and has no
system openssl dep.
One pre-existing test, test_http_client_with_invalid_pem, regresses
because rustls's Certificate::from_pem doesn't error on syntactic
garbage the way native-tls does. Tracked as a follow-up to update
the test to use a structurally-valid PEM. 365/366 lib tests pass.
Session::close still holds EnteredSpan across .await — out of
scope for Round 2; the binding works around it with fire-and-forget
drop. Same .entered() → .instrument() fix applies.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Adds an e2e regression guard for issue #19 — drains 1M rows from inside a #[tokio::test(flavor = "multi_thread")] to verify that the Option-1 async-trait fix in this branch doesn't regress into a nested-block_on panic. Adapted from PR #20 (author @vikrantpuppala) which proposed Option 2 (block_in_place + Handle::current().block_on as a stopgap). Our branch picks Option 1 (make ResultReader trait async) per issue #19's own "right answer" recommendation. The test is independent of the fix mechanism — it just asserts the panic doesn't return. e2e tests; run via: DATABRICKS_HOST=... DATABRICKS_HTTP_PATH=... DATABRICKS_TOKEN=... \ cargo test --test v0_execute_e2e cloudfetch_drain_does_not_nest_block_on -- --ignored Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
The previous commit (8657251) hardcoded reqwest's rustls-tls backend to unblock the napi-rs binding (Node statically links OpenSSL 3.x; native-tls's dynamic link against system OpenSSL 1.1 segfaults at module load). That choice is correct for napi but pre-empts the decision for other consumers — notably the C ABI / ODBC path (currently skeleton in src/ffi/), which historically uses native-tls. This commit makes the TLS backend a Cargo feature so each consumer picks its own: [features] default = ["tls-native"] tls-native = ["reqwest/native-tls"] tls-rustls = ["reqwest/rustls-tls"] Direct-Rust users + the C-ABI path + pyo3 use the default tls-native and get the historical native-tls behavior. The napi binding crate (added in the follow-up commit / next PR in this stack) explicitly opts INTO tls-rustls. Exactly one TLS feature MUST be enabled per consumer. Cargo feature unification would activate both reqwest TLS backends simultaneously, which is a build error — isolated by each consumer setting default-features = false where appropriate. Verified locally: - cargo check -p databricks-sql-kernel (default tls-native) PASS - cargo test --lib --workspace 376 passed / 0 failed Side benefit: the pre-existing PEM flake test (D-016 test_http_client_with_invalid_pem) which failed on the rustls-tls build passes on native-tls. CI default is back to a green state. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
d96afd9 to
af5894a
Compare
The `tls-native` / `tls-rustls` features are mutually exclusive in intent, not in compile. The prior comment claimed enabling both would be "a build error" — reqwest 0.12 actually accepts both features together and silently links both TLS stacks. In a napi cdylib that defeats the reason for switching to rustls: system OpenSSL still gets linked, and on Node process load it clashes with Node's statically linked OpenSSL. The structural enforcement lives in the napi crate (which is its own workspace, not a kernel-workspace member), introduced in the follow-up napi-skeleton PR. This commit updates the comment so the invariant is described accurately for anyone reading the kernel features in isolation. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
| let closed = Arc::new(AtomicBool::new(already_closed)); | ||
| self.last_statement_id = Some(result.statement_id.clone()); | ||
| self.last_valid = Some(valid.clone()); | ||
| self.last_closed = Some(Arc::clone(&closed)); |
There was a problem hiding this comment.
[HIGH CONFIDENCE — flagged by all 9 reviewers] · MEDIUM
Both execute() (lines 165-181) and submit() (lines 222-232 — file the comment there separately or note inline) write self.last_statement_id and self.last_valid twice. In execute() the first let valid = ValidityFlag::new() is shadowed ~12 lines later; the first allocation is dead and ExecutedStatement is wired to the second flag. In submit() the same pattern minus the shadow — two ValidityFlag::new() allocations and two identical writes.
Functionally a no-op (last-write-wins, wires consistent), but:
- Extra
ValidityFlagallocation per call for nothing. - Clearly a botched merge of commit
622a59aontoaed2efb(the SELECT-1 perf fix). - Any future refactor inserting an
.awaitbetween the two blocks would introduce a race onself.last_valid. clippydoes not catch this (the intermediate writes count as "uses").
Suggested fix: delete the first let valid = ValidityFlag::new(); plus the trio of self-assignments in both methods.
| self.last_closed = Some(Arc::clone(&closed)); | |
| cancel_state.observe(&result.statement_id); | |
| guard.defuse(); | |
| let valid = ValidityFlag::new(); | |
| // Only `Closed` triggers the short-circuit. `Succeeded` means | |
| // the server still owns the statement and we must issue | |
| // CloseStatement. `Failed` / `Canceled` are terminal but still | |
| // server-side-tracked — also fall through to the standard close | |
| // path. See `prepare_for_dispatch` for why omitting | |
| // `wait_timeout` typically yields `Closed` on the inline-result | |
| // fast path. | |
| let already_closed = result.server_state == StatementState::Closed; | |
| let closed = Arc::new(AtomicBool::new(already_closed)); | |
| self.last_statement_id = Some(result.statement_id.clone()); | |
| self.last_valid = Some(valid.clone()); | |
| self.last_closed = Some(Arc::clone(&closed)); |
There was a problem hiding this comment.
Fixed in commit dcc4d15. Dropped the first let valid = ValidityFlag::new(); and the first write trio in execute() so the single allocation drives both self.last_valid and the returned ExecutedStatement. Single allocation, single write block. Verified locally — cargo test --workspace 382/382, clippy clean.
| let closed = Arc::new(AtomicBool::new(false)); | ||
| self.last_statement_id = Some(response.statement_id.clone()); | ||
| self.last_valid = Some(valid.clone()); | ||
| self.last_closed = Some(Arc::clone(&closed)); |
There was a problem hiding this comment.
[HIGH CONFIDENCE — flagged by all 9 reviewers] · MEDIUM (companion to F1 in execute())
Same merge artifact: self.last_statement_id and self.last_valid are written twice (lines 222-224 set the first pair; lines 230-232 set the same pair again). No shadowing here, just dead duplicated writes.
Suggested fix: delete the first trio of self-assignments (lines 222-224) so the bookkeeping happens exactly once.
| self.last_closed = Some(Arc::clone(&closed)); | |
| cancel_state.observe(&response.statement_id); | |
| guard.defuse(); | |
| let valid = ValidityFlag::new(); | |
| // submit path always uses wait_timeout=0s, so the server can't | |
| // return CLOSED yet; start the flag false and let later close() | |
| // calls flip it. | |
| let closed = Arc::new(AtomicBool::new(false)); | |
| self.last_statement_id = Some(response.statement_id.clone()); | |
| self.last_valid = Some(valid.clone()); | |
| self.last_closed = Some(Arc::clone(&closed)); |
There was a problem hiding this comment.
Fixed in commit dcc4d15. Dropped the first trio of self.last_* writes in submit() so the bookkeeping happens exactly once. No shadowing here, so same valid flows through to ExecutedAsyncStatement::new.
| // CloudFetch readers (which use tokio primitives internally), | ||
| // callers must drive iteration from inside a tokio runtime | ||
| // context — use the async `ResultStream::next_batch` instead. | ||
| match futures::executor::block_on(self.inner.next_batch()) { |
There was a problem hiding this comment.
[HIGH CONFIDENCE — flagged by all 9 reviewers] · HIGH (companion to F2 in result_stream.rs)
ResultReaderAdapter::next (the arrow::RecordBatchReader impl) has the identical futures::executor::block_on(self.inner.next_batch()) pattern, and ResultReaderAdapter is pub — reachable from external Arrow consumers (ADBC-shaped wrappers, FFI prototypes). Same runtime-nesting / no-reactor failure modes as F2.
The doc-comment at lines 632-637 correctly mentions the tokio-context requirement but does NOT mention the block_in_place requirement for multi-thread runtimes; the code lost the runtime handle that previously made this safe.
Suggested fix: same as F2 — restore a runtime-aware blocking call (e.g., block_on_in_runtime), or move the adapter behind pub(crate) / #[cfg(test)].
There was a problem hiding this comment.
Fixed in commit dcc4d15. Both ResultReaderAdapter::next (here) and OwnedBatchIter::next now route through a new util::runtime::block_on_current_runtime helper. The helper inspects Handle::try_current().runtime_flavor() at call time and dispatches:
- MultiThread runtime →
block_in_place + handle.block_on(fut)(the safe pattern for CloudFetch's tokio primitives) - CurrentThread or no runtime →
futures::executor::block_on(fut)fallback (works for in-memory readers' immediately-ready futures; CloudFetch on current_thread is logically unbridgeable)
This consolidates the sync→async bridging policy in one place. I kept ResultReaderAdapter's visibility as pub (it's reachable from external Arrow-FFI consumers) and addressed the rustdoc concern from F12 by adding a paragraph documenting the #[async_trait::async_trait] requirement for external ResultReader implementors.
| @@ -254,7 +254,7 @@ impl Metadata { | |||
| GET_CATALOGS_SCHEMA.clone(), | |||
There was a problem hiding this comment.
[HIGH CONFIDENCE — flagged by 5 reviewers] · HIGH
PR title and description claim "Send-safety on Statement". Statement::execute / submit correctly swap let _g = span.entered(); for async {}.instrument(span). But the same let _g = self.session.log_span().clone().entered(); pattern remains at:
src/statement/executed_async.rs:151(status),:181(await_result),:246(fetch_result)src/session.rs:327(Session::close)src/metadata_v0.rs:246, 271, 315, 378, 424, 464, 502, 527, 544, 554— all 10Metadata::*methods
tracing::span::EnteredSpan is !Send (it holds a PhantomData<*mut ()>), so every one of these futures is !Send. A napi-rs caller doing let exec = stmt.submit().await?; exec.await_result().await?; (the documented async path) hits a confusing "future is not Send" error pointing at tracing::span::PhantomNotSend — extremely binding-generator-hostile.
Verified at PR head SHA: grep -c entered() in metadata_v0.rs returns 10; grep -c instrument returns 0.
Suggested fix: mechanical sweep — apply async {}.instrument(span).await to all 14 sites in this PR while the pattern is fresh. The precedent is in executed.rs:124,143 (already done). Otherwise document explicitly in docs/spec-v0.md that only Statement::execute/submit are Send-safe in stack 1/8.
There was a problem hiding this comment.
Fixed in commit dcc4d15. Swept all 14 cited sites + one more I found at mutable.rs:272 (Statement::close — also held an EnteredSpan across .await). Pattern is async {...}.instrument(span).await everywhere now. Total 15 sites:
metadata_v0.rs: list_catalogs, list_schemas, list_tables, list_columns, primary_keys, foreign_keys, functions, procedures, type_info, table_typesexecuted_async.rs: status, await_result, fetch_resultsession.rs: closemutable.rs: execute, submit (already done in this PR), close (newly swept)
Plus F5 compile-time assert_send block added in src/lib.rs covering all of these so a future revert to let _g = span.entered(); fails to compile instead of regressing silently.
| [features] | ||
| default = ["tls-native"] | ||
| tls-native = ["reqwest/native-tls"] | ||
| tls-rustls = ["reqwest/rustls-tls"] |
There was a problem hiding this comment.
[HIGH CONFIDENCE — flagged by 6 reviewers] · HIGH
A downstream consumer who writes databricks-sql-kernel = { version = "0.1", default-features = false } and forgets to add a TLS feature gets a build that compiles and links cleanly but fails on every HTTPS call at runtime ("TLS backend not configured" from reqwest). The Cargo.toml comment discusses mutual exclusivity but doesn't guard against zero-selection.
Suggested fix: add a compile-time guard to src/lib.rs:
#[cfg(not(any(feature = "tls-native", feature = "tls-rustls")))]
compile_error!("databricks-sql-kernel requires one of `tls-native` or `tls-rustls`");
#[cfg(all(feature = "tls-native", feature = "tls-rustls"))]
compile_error!("`tls-native` and `tls-rustls` are mutually exclusive; the napi binding must disable defaults");Standard idiom used by reqwest, sqlx, and rustls-native-certs.
There was a problem hiding this comment.
Fixed in commit dcc4d15. Added two compile_error! guards in src/lib.rs:
#[cfg(not(any(feature = "tls-native", feature = "tls-rustls")))]
compile_error!("databricks-sql-kernel requires one of `tls-native` (default) or `tls-rustls`. If you set `default-features = false`, opt back into one explicitly.");
#[cfg(all(feature = "tls-native", feature = "tls-rustls"))]
compile_error!("`tls-native` and `tls-rustls` are mutually exclusive — enabling both links two TLS stacks and defeats the napi crate's rustls switch. The napi binding must disable defaults (`default-features = false`) before enabling `tls-rustls`.");Verified locally: cargo check --no-default-features correctly fires the zero-feature guard; cargo check --features tls-rustls (which leaves tls-native from defaults active) correctly fires the both-features guard.
| # silently picks one at runtime — but in a napi cdylib it defeats the | ||
| # whole reason for the rustls switch: system OpenSSL gets linked in | ||
| # anyway, and on process load that clashes with Node.js's statically | ||
| # linked OpenSSL. |
There was a problem hiding this comment.
[HIGH CONFIDENCE — flagged by 6 reviewers] · HIGH (related to F4a)
The comment claims:
The napi crate enforces the intent structurally by being its own workspace (not a member of this kernel workspace), so
cargo build --workspacehere only seestls-nativevia pyo3 and never unifies the two.
This is factually wrong — verified locally with cargo tree -i reqwest -f "{p} {f}" at PR head:
reqwest v0.12.28 ...native-tls,rustls-tls,rustls-tls-webpki-roots...
├── databricks-sql-kernel ... default,tls-native
└── oauth2 v5.0.0 default,reqwest,rustls-tls
oauth2 = "5" enables rustls-tls by default, so the kernel today already links BOTH TLS stacks into the workspace build. The napi mitigation (separate workspace) still works for napi specifically, but the documented rationale is wrong and will mislead future contributors.
Suggested fix: either correct the comment, or actually disable oauth2's default features to back the claim:
oauth2 = { version = "5", default-features = false, features = ["reqwest"] }There was a problem hiding this comment.
Fixed in commit dcc4d15. Verified your cargo tree finding locally — oauth2 = "5" has default = ["reqwest", "rustls-tls"], so the kernel workspace was already linking both stacks. Two changes:
-
Pinned
oauth2 = { version = "5", default-features = false, features = ["reqwest"] }so oauth2 inherits the kernel's TLS choice instead of forcing rustls.cargo tree -i reqwest -f "{p} {f}"after the fix confirms only the consumer-selected backend is active. -
Rewrote the misleading Cargo.toml comment to describe what actually enforces mutual exclusivity now (the compile_error guards from F4a + the oauth2 default-features strip), not the napi crate's separate workspace.
| stmt.spec().sql("SELECT * FROM range(1000000)"); | ||
| let mut exec = stmt.execute().await.expect("execute range(1000000)"); | ||
|
|
||
| let rows = drain_rows(exec.result_stream_mut()).await; |
There was a problem hiding this comment.
[MODERATE CONFIDENCE — flagged by 2 reviewers] · MEDIUM
The new cloudfetch_drain_does_not_nest_block_on test uses #[tokio::test(flavor = "multi_thread")]. That was required under Option-2 (PR #20's block_in_place stopgap). Under Option-1 (this PR's async trait), the fix is supposed to be runtime-flavor-independent — and the test docstring claims exactly that.
The more valuable regression guard is current_thread, which would catch a future sync→async bridge being reintroduced (a current_thread runtime + nested block_on is the worst case).
Also: the 1M-row threshold for CloudFetch is server-side-configurable. If Databricks tunes the inline/external threshold up, this test silently flips to inline and stops covering the path.
Suggested fix: flip to current_thread (or duplicate for both flavors), and add a disposition == "EXTERNAL_LINKS" (or equivalent) assertion so the test fails loudly if the path isn't actually exercised.
There was a problem hiding this comment.
Addressed in commit f782035. Added a current_thread-flavor sibling test cloudfetch_drain_works_on_current_thread_runtime as the discriminating regression guard — block_in_place panics on current_thread, so any future reintroduced sync→async bridge would crash here even if it survived the multi_thread test.
Deferred the disposition assertion: the status accessor that would let us assert disposition == "EXTERNAL_LINKS" lands in PR #23 (krn-status-fields, top of the stack). Filed as a TODO inside the test docstring; will wire it in once #23 merges.
| match futures::executor::block_on(self.reader.next_batch()) { | ||
| Ok(Some(batch)) => Some(Ok(batch)), | ||
| Ok(None) => { | ||
| self.done = true; |
There was a problem hiding this comment.
[HIGH CONFIDENCE — flagged by all 9 reviewers] · HIGH
OwnedBatchIter::next bridges async→sync with futures::executor::block_on(self.reader.next_batch()). For in-memory readers (immediately-ready futures) this is fine. For CloudFetchResultReader, whose future awaits tokio::sync::Notify / tokio::time::sleep / tokio::select! inside StreamingCloudFetchProvider:
futures::executor::block_ondoes NOT usetokio::task::block_in_place. On a current-thread runtime, immediate self-deadlock. On a multi-thread runtime, the OS worker thread is parked without telling tokio.- It does NOT install a tokio reactor — any tokio I/O / timer inside the awaited future panics with "there is no reactor running".
The doc-comment at lines 596-599 claims this follows "the tokio::task::block_in_place pattern in docs/spec-v0.md" — but the actual call is futures::executor::block_on, which is exactly NOT that pattern.
The pre-PR code routed through block_on_in_runtime (still exists in src/util/runtime.rs and is used by OAuth) which had this right. This is a milder variant of the very issue #19 this PR claims to fix, just on the C-ABI / ODBC / sync-iterator path instead of async.
Suggested fix: either (a) thread a tokio::runtime::Handle back into OwnedBatchIter and call block_on_in_runtime(&handle, self.reader.next_batch()), or (b) downgrade into_owned_batches to pub(crate) and document that consumers must use next_batch().await for CloudFetch-backed streams.
There was a problem hiding this comment.
Fixed in commit dcc4d15. See the companion reply on src/reader/mod.rs for the full architectural fix — short version: both this site and the ResultReaderAdapter::next site now route through util::runtime::block_on_current_runtime, which uses block_in_place + handle.block_on on a multi-thread runtime (the CloudFetch-safe pattern), falls back to futures::executor::block_on on current_thread / no-runtime (works for in-memory readers).
The doc comment in into_owned_batches is rewritten to describe the new behavior accurately — no more "follows the block_in_place pattern" claim that didn't match the code.
Code Review Squad — Multi-Agent ReviewMerge Safety Score: 42 / 100 — HIGH RISK 9/9 specialized reviewers delivered (security, devils-advocate, language, test, architecture, maintainability, agent-compat, ops, performance). Cross-reviewer convergence on the high-severity findings is strong: 9 of 9 flagged F1 and F2; 5–6 flagged F3 and F4. Block on: F1 (duplicate Strongly recommend in this PR: F3 (complete the Recommend (follow-up acceptable): F4b (Cargo.toml comment is factually wrong — verified Doc only: F9 (narrow PR description re OAuth still hazardous), F10 (split Cargo.lock churn), F11 (system-CA caveat for napi), F12 (rustdoc/visibility on Core architectural change (sync→async trait for Could not post inline comments for: F4c, F5, F6, F7 — their target files ( F4c —
|
|
Security side-effect: heads-up that this PR transitively closes the bulk of the repo's open dependabot alerts. The
Remaining 3 advisories are covered by:
Worth flagging in case it helps prioritise review of this 8-PR stack. None of this needs to change in the PR itself — just adding the context so the security impact is visible. |
… runtime-aware sync iterators, harden TLS feature wiring Addresses HIGH-severity findings from PR #26 review: F1 + F1b — `src/statement/mutable.rs:execute/submit`. Both methods wrote `self.last_statement_id` / `self.last_valid` twice; `execute()` also re-allocated `ValidityFlag` via shadowing. A future `.await` inserted between the two write blocks would have raced on `self.last_valid`. Dropped the first write trio in each method. F2 + companion — `src/result_stream.rs:OwnedBatchIter::next` and `src/reader/mod.rs:ResultReaderAdapter::next`. Both called `futures::executor::block_on(self.reader.next_batch())`. For CloudFetch readers (which `.await` tokio primitives inside `StreamingCloudFetchProvider`) this either self-deadlocks under a current-thread runtime or parks the worker without telling tokio under multi-thread — a milder reprise of the issue-#19 hazard this PR was supposed to fix, on the sync iterator path. Added `util::runtime::block_on_current_runtime` which inspects `Handle::try_current().runtime_flavor()` and routes to `block_in_place + handle.block_on` under multi-thread, falls back to `futures::executor::block_on` for current-thread + no-runtime cases. F3 — Send-safety sweep. PR title claimed "Send-safety on Statement" but only `Statement::execute`/`submit` had been migrated to `.instrument(span)`. 15 sites still wrote `let _g = ...entered();` which makes the surrounding `async fn` future `!Send` (`EnteredSpan` carries a `PhantomData<*mut ()>`). Migrated all of them: `Metadata::{list_catalogs, list_schemas, list_tables, list_columns, primary_keys, foreign_keys, functions, procedures, type_info, table_types}`, `ExecutedAsyncStatement::{status, await_result, fetch_result}`, `Session::close`, `Statement::close`. F4a — TLS feature compile-time guard. Added two `compile_error!`s in `src/lib.rs`: one for zero TLS features (a `default-features = false` consumer who forgets to opt back in), one for both features (which would link both TLS stacks and defeat the napi crate's rustls switch). Verified both fire under `cargo check --no-default-features` and `cargo check --features tls-rustls` respectively. F4b — `oauth2 5.x` enables `default = ["reqwest", "rustls-tls"]`, silently unifying both TLS stacks in the kernel workspace before this commit. Pinned `oauth2 = { version = "5", default-features = false, features = ["reqwest"] }` so the kernel's own `tls-native` / `tls-rustls` feature is the only thing controlling the reqwest backend. Corrected the misleading Cargo.toml comment that claimed the napi crate's separate workspace was the load-bearing structural guarantee — it isn't anymore; the compile_error guards plus the oauth2 default-features strip are. F5 — added compile-time `assert_send` on the futures returned by `Statement::{execute, submit, close}`, `ExecutedAsyncStatement::{status, await_result, fetch_result}`, `Session::close`, and the eight `Metadata::*` methods. A maintainer reverting `.instrument(span)` back to `let _g = span.entered();` would silently regress Send-ness while all in-tree tests still passed; this catches it at the build that introduces it. F4c docstring — refuted the reviewer's claim that `danger_accept_invalid_hostnames` panics under rustls (verified locally that reqwest 0.12.28 installs `IgnoreHostname` under rustls). The kernel's own TlsConfig docstring at line 88 said "Requires the `native-tls` backend" — also incorrect. Updated to reflect that the knob works under both backends. F12 (partial) — kept `pub trait ResultReader` public but added a rustdoc paragraph documenting the `#[async_trait::async_trait]` requirement for external implementors. Downgrading the trait to `pub(crate)` was the alternative but would have broken the RecordBatchReader-shaped `ResultReaderAdapter` surface that the ADBC / FFI paths will eventually consume. Verification: - `cargo +stable fmt --all -- --check` - `cargo clippy --all-targets -- -D warnings` clean - `cargo test --workspace`: 382 passed / 0 failed (up from 376) - `cargo check --no-default-features --features tls-rustls` clean - `cargo check --features tls-rustls` correctly fires the both-features compile_error - `cargo check --no-default-features` correctly fires the zero-features compile_error Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…on for CloudFetch drain Addresses MEDIUM-severity findings F7 and F8 from the PR #26 review. F7 — CI was running only `cargo clippy --all-targets -- -D warnings` and `cargo test --workspace`, both with default features (which resolves to `tls-native`). The downstream napi binding opts INTO `tls-rustls`. Without a CI job for that build, a feature-gated cfg typo or a dep update that breaks rustls compilation would only surface when the napi crate's CI broke — long after the kernel PR landed. Added `check-tls-rustls` job: `cargo check --no-default-features --features tls-rustls` plus a clippy run with the same flags, so warnings caught under tls-native stay honest under tls-rustls and vice versa. F8 — the existing `cloudfetch_drain_does_not_nest_block_on` test uses `#[tokio::test(flavor = "multi_thread")]`. That flavor was required under PR #20's Option-2 (`block_in_place` stopgap); under Option-1 (this PR's async trait), the fix is supposed to be runtime-flavor-independent. A future refactor that reintroduced a sync→async `block_on` bridge protected by `block_in_place` would still pass `multi_thread` but `current_thread` is the worst case (`block_in_place` panics there). Added a sibling `cloudfetch_drain_works_on_current_thread_runtime` test annotated `flavor = "current_thread"` as the discriminating regression guard. Both tests stay `#[ignore]` — they require a live workspace and CloudFetch-disposition results, same as before. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Review-comment audit — resolution summaryTwo commits pushed:
Verification: Issue-body findings (couldn't post inline since target files weren't in this PR's diff)
Cross-reference@gopalldb — your dependabot side-effect note still stands, all 14 listed bumps remain in the Cargo.lock and the alert closures should happen on merge. |
Pull in 11 commits from main: - feat: TIMESTAMP_NTZ + TIMESTAMP_LTZ TypedValue variants (#58) - chore(ci): CODEOWNERS, dependabot config, JFrog routing - chore(deps): cargo-minor-and-patch group + GHA bumps Bringing the PR #26 branch up-to-date so CI runs against current main. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com> # Conflicts: # Cargo.lock
Bring in PR #36 (ResultPostProcessor + complex-types-as-JSON), re-applying PR #26's async-ification on top: ResultReader trait stays async; create_reader stays async; ResultPostProcessor adopts async constructor where it needs to .await an inner schema/batch. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com> # Conflicts: # src/client/sea.rs # src/reader/mod.rs
…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>
…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>
…, empty-result schema, composite types, TIMESTAMP tz, metadata reshape, named params) (#72) ## Re-land of #64 PR #64 was filed as a stacked PR with base \`docs/complex-types-json-stringify\`. That parent branch's content reached \`main\` via #36 (squash-merge) on 2026-05-25 06:16Z. PR #64 then merged at 07:33Z — but **into the parent branch**, which by that point was effectively detached from \`main\`. The merge commit (\`fd2c576\`) is not an ancestor of \`origin/main\`, so #64's content never reached the public branch even though GitHub reports it as \`MERGED\`. This is verifiable: \`\`\` $ git merge-base --is-ancestor fd2c576 origin/main && echo on || echo off off \`\`\` This PR cherry-picks \`fd2c576\` onto \`main\` so the eight comparator-parity fixes (most importantly: named-parameter binding, required by released connector PR #803 in \`databricks-sql-python\`) actually land. **Connector #803 is currently broken in the wild** because it calls \`Statement.bind_named_param\` which doesn't exist on the public kernel. ## Cherry-pick details Single content conflict: \`src/reader/mod.rs\` imports. \`main\` requires \`DataType\` + \`async_trait\` (added by #26 after #64 was filed); the cherry-pick branch didn't. Resolved by keeping \`main\`'s wider import set and dropping the now-unused \`DataType\` (the cherry-picked content uses other identifiers, not \`DataType\`, at this site). ## Verification - \`cargo build --workspace\` — clean - \`cargo test --lib\` — **436/436 pass** - \`cargo test --test v0_execute_wiremock\` — **11/11 pass** ## Original #64 description (preserved below for review continuity) Eight comparator-parity fixes in the kernel's result-reader, metadata-reshape, and parameter-binding pipelines, surfaced by the python-comparator audit: 1. **\`intervals_as_string\` post-processor option** — pyarrow's Python bindings can't decode Arrow's \`month_interval\` (id 21) at all. Every kernel-backend \`SELECT *\` over a table with \`INTERVAL YEAR TO MONTH\` columns threw \`ArrowNotImplementedError\`. 32 / 88 comparator diffs. 2. **PyO3 binding for both result-config knobs** — \`complex_types_as_json\` + \`intervals_as_string\` as \`Session(...)\` kwargs. 3. **Empty-result schema fix** — \`extract_schema_from_manifest\` now routes through the shared \`databricks_type_to_arrow\` mapper; DECIMAL/INTERVAL/VOID/ARRAY/MAP/STRUCT no longer fall through to \`Utf8\`. Recursive parser for composite type text. 4. **TIMESTAMP tz-aware** — plain TIMESTAMP maps to \`Timestamp(Microsecond, Some("Etc/UTC"))\` to match the non-empty wire path. 5. **\`getTables(types=[])\` returns zero rows** — matches Thrift; was returning all rows. 6. **\`getColumns\` REMARKS null → \`""\`** — matches Thrift consumers' expectations. 7. **\`getColumns\` IS_AUTO_INCREMENT defaults to \`"NO"\`** — Databricks tables don't support auto-increment; \`"NO"\` is the domain-correct answer. 8. **Named-parameter binding** — \`StatementParameter.name\` is \`openapi_required=true\` per the canonical SEA proto; kernel now exposes \`Statement::bind_named_param\` (Rust + PyO3) and forwards \`spec.named_params\` through the SEA \`parameters\` array. Full original PR description and comparator outcome table: #64 This pull request and its description were written by Isaac. Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
…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>
…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>
…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>
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 switch via Cargo features + e2e test ported from #20kernel-napi-skeletontls-rustlsfeature from creation)kernel-napi-classeskernel-napi-statement-validitykernel-oauth-error-classError::unauthenticated()krn-connection-pool-default-bumpHttpConfig.pool_max_idle_per_hostdefault 10 → 100krn-tls-public-apiTlsConfigfields (custom_ca_cert + accept_self_signed + skip_hostname_verification)krn-status-fields← TIPExecutedStatementPolicy: 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 previousResultStreamaccessors usedtokio::block_oninternally, which panics with "Cannot start a runtime from within a runtime" when called from inside an enclosing tokio runtime — exactly what napi-rs'sexecute_tokio_futureand PyO3's wrapper runtime do. Fix: make theResultReadertrait itselfasyncviaasync_trait. This is Option 1 in issue #19 — the documented "right answer" — vs the Option 2 stopgap in PR #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 historicalnative-tlsbackend.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
622a59ahardcoded 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 newd96afd9commit 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): cleancargo check --workspace(kernel native-tls + napi rustls-tls in same workspace): cleancargo test --lib --workspace: 376 passed / 0 failedSide 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 warningscleansea-auth-u2m@e7c979don databricks-sql-nodejsTracking
Co-authored-by: Isaac