Skip to content

Redundant CloseStatement DELETE on inline direct-results path (statement already state=CLOSED) #188

Closed

Description

@eric-wang-1990

Summary

When a query's result is delivered inline via direct results (SEA ExecuteStatement returns status.state == CLOSED — the statement is already closed server-side), the kernel still issues a redundant CloseStatement (HTTP DELETE /api/2.0/sql/statements/{id}) on ExecutedStatement::close().

Per the spec (adbc-drivers/databricks#566 — matched by C# ADBC and databricks-jdbc), no CloseStatement should be sent when the statement is already closed. Surfaced by the conformance suite (databricks-driver-test, spec CLOUDFETCH-013), committed there as a #[should_panic] xfail tripwire.

Repro (proxy-captured wire trace)

A plain SELECT 1 (inline direct results):

CreateSession
ExecuteStatement   → response status.state = CLOSED
… drain rows …
close()            → DELETE /api/2.0/sql/statements/{id}   ← redundant (already CLOSED)

Test inline_direct_results_no_redundant_close_statement in tests/kernel/tests/cloud_fetch.rs asserts CloseStatement == 0 on the inline path; currently fails.

Relationship to #168

#168 reports the same redundant CloseStatement on the metadata path and states the regular-query path correctly recognizes CLOSED and skips the close. This issue shows the redundant close also fires on the inline direct-results regular-query path — so the fix should suppress the close whenever the ExecuteStatement response already reported state=CLOSED, regardless of path. Filing separately so the inline-path conformance cell (CLOUDFETCH-013) has a precise tracker; close as duplicate of #168 if you prefer to track both under one.

Activity

  1. vikrantpuppala commented on Aug 10, 2026

    @vikrantpuppala
    Collaborator

    Resolved by #222 (merged), alongside #168.

    Finding on the inline sync-query path (this issue's premise): the redundant CloseStatement on the inline direct-results regular-query path is not reproducible against current main — that path already skips the close. Statement::execute computes already_closed = result.status.state == StatementState::Closed (landed in #140) and pre-seeds the shared closed flag, so the drain auto-close, explicit close(), and Drop all short-circuit. #222 adds a wire-level regression test locking this in — execute_closed_inline_skips_close_statement (a plain SELECT 1 inline with state=CLOSED, drained + explicitly closed → asserts 0 DELETEs). It's a verified tripwire: forcing already_closed = false makes it fail with one observed DELETE.

    What #222 actually fixed: the same bug pattern did exist on the async path (Statement::submit → ExecutedAsyncStatement). Reaching CLOSED via an await_result() / fetch_result() poll never flipped the closed flag, so close()/Drop fired a redundant DELETE. Fixed in materialise_result (the common sink for both), mirroring the sync path.

    Note on CLOUDFETCH-013: the xfail tripwire referenced here (tests/kernel/tests/cloud_fetch.rs) lives in the databricks-driver-test repo, so #222 can't touch it. Its CloseStatement == 0 assertion on the inline sync path now holds against the kernel — that cell can be un-xfailed there once the kernel pin is bumped past #222. If the driver-test proxy replay was still observing a stray DELETE, the likely source was the async path (now fixed) or the deliberate fire-and-forget close ordering (a detached runtime.spawn, not a redundant close — see the rationale in #222; it's not a correctness issue and was intentionally kept off the critical path per #85).

    Closing as resolved by #222. Reopen if the driver-test conformance cell still shows a redundant close on the kernel-sync inline path after the pin bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions