Skip to content

fix(kernel): stop premature sync statement close (H4); bump KERNEL_REV to batch 2#830

Open
vikrantpuppala wants to merge 2 commits into
mainfrom
feat/use-kernel-cuj-batch2-fixes
Open

fix(kernel): stop premature sync statement close (H4); bump KERNEL_REV to batch 2#830
vikrantpuppala wants to merge 2 commits into
mainfrom
feat/use-kernel-cuj-batch2-fixes

Conversation

@vikrantpuppala
Copy link
Copy Markdown
Contributor

What

Connector half of the kernel batch-2 CUJ-gap fixes (databricks-sql-kernel#123). Bumps KERNEL_REV to pick up the batch-2 kernel surface, plus the one connector-side change (H4).

⚠️ KERNEL_REV is pinned to #123's branch HEAD (eb7da65) as a placeholder. Must re-pin to #123's squash-merge SHA before merging (orphan-SHA risk — same as prior batches).

H4 — don't close the kernel Statement at sync execute-return

execute_command's finally used to stmt.close() immediately after a successful stmt.execute(). For a large CloudFetch result with paginated chunk links (all_fetched=false), the kernel fetches later links lazily (get_result_chunks against the live statement) during consumption — so a premature CloseStatement broke those fetches. (Verified earlier by live repro that the common all_fetched=true case was fine, so this only bit very large paginated-link results.)

The kernel now auto-closes the server statement when its result stream drains (ExecutedStatement::next_batch end-of-stream, kernel #123), with the executed-handle Drop as the backstop for partial/abandoned reads. So the connector now flips close_stmt = False on a successful execute and closes only on the error path (where no executed handle / result set was produced to reap the statement).

The rest of batch 2 is kernel-only

cancelled-class → OperationalError, U2M refresh fail-fast, metadata statement close-on-drop, and per-binding OAuth client_id are all entirely kernel-side and need no connector code beyond the KERNEL_REV bump.

Testing

  • Unit: sync execute does-not-close-on-success / does-close-on-failure. All pass; black (pinned 22.3.0) clean.
  • E2E (live, dogfood, use_kernel=True): large multi-chunk result (5M rows) drains without premature close + cursor reuse after auto-close; server cancel surfaces as OperationalError (not ProgrammingError); plus the existing batch-1 e2e (diagnostic-info, staging, params) re-verified against the batch-2 wheel.

Depends on #123 (kernel).

This pull request and its description were written by Isaac.

…V to batch 2

Connector half of the kernel batch-2 fixes (kernel PR #123). Bumps
KERNEL_REV to pick up the batch-2 kernel surface.

H4 — don't close the kernel Statement at sync execute-return:
execute_command's finally used to `stmt.close()` immediately after
`stmt.execute()` succeeded. For a large CloudFetch result with
paginated chunk links (all_fetched=false), the kernel fetches later
links lazily (get_result_chunks against the LIVE statement) during
consumption, so a premature CloseStatement broke those fetches. The
kernel now auto-closes the server statement when its result stream
drains (ExecutedStatement::next_batch end-of-stream), with the
executed-handle Drop as the backstop for partial/abandoned reads. So
the connector now flips close_stmt=False on a successful execute and
only closes on the error path (no executed handle was produced).

The other batch-2 fixes (cancelled-class -> OperationalError, U2M
refresh fail-fast, metadata statement close-on-drop, per-binding OAuth
client_id) are entirely kernel-side and need no connector code beyond
the KERNEL_REV bump.

Tests: unit (sync execute does-not-close on success / does-close on
failure) + e2e (large multi-chunk result drains without premature
close + cursor reuse; server cancel maps to OperationalError not
ProgrammingError). All e2e verified live against dogfood.

Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
#123 picked up a follow-up commit fixing the wiremock cancelled-state
assertions (ErrorCode::Cancelled). Bump the placeholder pin so the
connector CI builds the corrected kernel. Still to be re-pinned to the
squash-merge SHA before #830 merges.

Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@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