Skip to content

fix(napi): propagate StatementInner ValidityFlag fix from sea-operation (re-target to main) - #78

Merged
msrathore-db merged 2 commits into
mainfrom
msrathore/krn-napi-statement-validity-v2
May 26, 2026
Merged

msrathore-db merged 2 commits into
mainfrom
msrathore/krn-napi-statement-validity-v2

Conversation

@msrathore-db

Copy link
Copy Markdown
Collaborator

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 fix(napi): propagate StatementInner ValidityFlag fix from sea-operation (stack 4/8) #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 (merged to msrathore/kernel-napi-classes at f4fa428 instead of main).
  • Tracking JIRA: PECOBLR-2917 (concurrency / SIGSEGV class of issues this fix addresses).

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>
Files modified are pre-existing on main (`ea4d398`) — confirmed by
running cargo fmt --check against origin/main. Applying canonical
rustfmt to clear the workspace-wide `cargo fmt --check` failure
that was blocking DA approval on this PR. Pure mechanical fmt; no
semantic change.

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.

2 participants