Repository navigation
fix(sea): close orphaned statement when execute_and_read fails - #92
Merged
vikrantpuppala merged 4 commits intoJun 1, 2026
Merged
Conversation
After ``call_execute_api`` succeeds the SEA statement is open on the server. Two paths into a leak that would otherwise persist until SQL Gateway's ``CommandInactivityTimeout`` (~1h): 1. ``wait_for_completion`` returns ``Error::timeout`` while the server still considers the statement live in PENDING / RUNNING. Terminal FAILED / CANCELED is the server's own cleanup signal and doesn't need a CloseStatement, but the polling-timeout path does. 2. ``create_reader`` fails. The most likely sub-failure is ``ResultPostProcessor::new`` -> ``StreamingCloudFetchProvider:: get_schema`` eagerly downloading chunk 0 to extract the result schema; a non-retriable 4xx / persistent 5xx on that GET propagates up. The probe in driver-test PR #410's CLOUDFETCH-016 caught this: on a perpetual ``cloudfetch_500``, the kernel exhausted retries and never issued ``DELETE /api/2.0/sql/statements/{id}``. Capture the ``statement_id`` from the initial response (before ``wait_for_completion``) and fire a best-effort close on both failure paths via ``close_statement``. Since the trait method already swallows its own errors, the wrapper here is just a logging seam that attributes which phase failed so traces stay diagnosable. New wiremock reproducer in ``tests/v0_execute_wiremock.rs`` (``execute_cloudfetch_chunk0_failure_closes_statement``): mounts a SUCCEEDED execute response with external_links pointing at the mock server, then 404s the chunk-0 GET. Asserts the mock observes a DELETE on the statement. Test fails on baseline (5 chunk-0 GET retries then no DELETE); passes with the fix in this commit. End-to-end verified against the driver-test proxy suite's CLOUDFETCH-016-equivalent path: raised=1 CloseStatement=1 DeleteSession=1 vs. baseline: raised=1 CloseStatement=0 DeleteSession=1 Closes the kernel half of the orphaned-op bug surfaced by databricks/databricks-driver-test#410. Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
had a problem deploying
to
azure-prod
May 30, 2026 12:22 — with
GitHub Actions
Failure
gopalldb
approved these changes
Jun 1, 2026
Apply cargo fmt to arrow_parser.rs and fix the TlsConfig doc examples in config.rs / session.rs, which used struct-literal syntax with ..default() against a #[non_exhaustive] struct — illegal from the doc tests' external-crate context. Construct via TlsConfig::default() and assign public fields instead. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
had a problem deploying
to
azure-prod
June 1, 2026 05:17 — with
GitHub Actions
Failure
The rust-e2e workflow mapped DATABRICKS_HTTP_PATH from secrets.TEST_PECO_WAREHOUSE_HTTP_PATH, but the azure-prod environment has no secret by that name — its secrets are DATABRICKS_HOST, DATABRICKS_HTTP_PATH, DATABRICKS_TOKEN. The unknown name resolved to empty, so require_host_and_path() panicked with 'DATABRICKS_HTTP_PATH must be set' and the whole v0 E2E suite failed. Point it at the secret that actually exists. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
had a problem deploying
to
azure-prod
June 1, 2026 05:26 — with
GitHub Actions
Failure
The check-tls-rustls job was the only cargo job in pr-checks.yml missing the ./.github/actions/setup-jfrog step that its sibling clippy/test jobs run. On the protected runners, direct crates.io access is blocked (go/hardened-gha); without setup-jfrog the cargo fetch has no db-cargo-remote config or OIDC token, so dependency download fails with 'SSL connect error (unexpected eof while reading)' fetching arrow-array — the recurring fast-fail seen on every run. Add setup-jfrog and align the checkout / toolchain pins with the other jobs. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
had a problem deploying
to
azure-prod
June 1, 2026 05:28 — with
GitHub Actions
Failure
This was referenced Jun 1, 2026
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After
call_execute_apisucceeds the SEA statement is open on the server. Two paths into a leak that would otherwise persist until SQL Gateway'sCommandInactivityTimeout(~1h):wait_for_completionreturnsError::timeoutwhile the server still considers the statement live in PENDING / RUNNING. Terminal FAILED / CANCELED is the server's own cleanup signal and doesn't need a CloseStatement, but the polling-timeout path does.create_readerfails. The most likely sub-failure today isResultPostProcessor::new→StreamingCloudFetchProvider::get_schemaeagerly downloading chunk 0 to extract the result schema; a non-retriable 4xx / persistent 5xx on that GET propagates up.The kernel never issues
DELETE /api/2.0/sql/statements/{id}in either case.How the bug surfaced
Investigation triggered by databricks-driver-test#410 CLOUDFETCH-016. The proxy-test suite ran a perpetual
cloudfetch_500scenario againstSELECT id FROM range(2000000)and observed:Session-level cleanup fires, but the per-statement handle is orphaned. Traced down to
execute_and_read: it propagatescreate_readererrors via?without persisting thestatement_idfor later cleanup.Fix
Capture the
statement_idfrom the initial response (beforewait_for_completion) and fire a best-effort close on either failure path via theTransport::close_statementtrait method.close_statementalready swallows its own errors; the wrapper here is a logging seam that attributes which phase failed (wait_for_completionvscreate_reader) so traces stay diagnosable.Validation
Unit reproducer (
tests/v0_execute_wiremock.rs::execute_cloudfetch_chunk0_failure_closes_statement): mounts a SUCCEEDED execute response withexternal_linkspointing at the mock server, then 404s the chunk-0 GET. Asserts the mock observes aDELETE /api/2.0/sql/statements/{id}.Full suite:
cargo test --workspace --lib --tests— 619 tests pass, 0 failures, 0 new ignored.cargo clippy --all-targetsclean (no new warnings from the modified files; pre-existing fmt drift insrc/reader/cloudfetch/arrow_parser.rsis unrelated and pre-existing onmain).End-to-end via driver-test: rebuilt the proxy-test venv against this branch (
DATABRICKS_KERNEL_PATH=$BRANCH) and re-ran the CLOUDFETCH-016 equivalent path:Out of scope (follow-ups)
databricks-sql-python) has the same shape of bug on the Thrift path —ThriftDatabricksClient.execute_commandconstructs the ResultSet inline, and a failingThriftCloudFetchQueue.__init__(which eagerly downloads chunk 0) propagates without callingclose_command. That fix belongs in the connector repo and will be a separate PR.StreamingCloudFetchProvider::get_schema. The deeper design question is whetherget_schemashould download chunk 0 to extract the schema, or whether the schema can be derived from the SEAmanifestalone. Lazy schema extraction would eliminate this entire failure mode (no download untilnext_batch). That's a larger change worth its own PR.This pull request and its description were written by Isaac.
Downstream fixes / reviewer note
Transport::close_statementto surface post-retry wire errors instead of swallowing them. This PR is still needed: it adds the missing best-effort close call onexecute_and_readfailure paths. When rebasing after fix(kernel,napi): surface close_statement errors + non-blocking concurrent executeStatement #99, keep the cleanup behavior and explicitly log/ignore close failures at this best-effort call site.