Repository navigation
fix: treat a failed close of a finished operation as best effort - #592
Open
vuanhphung wants to merge 1 commit into
Open
vuanhphung wants to merge 1 commit into
vuanhphung wants to merge 1 commit into
Conversation
Once the backend has reported the statement finished, a failed close request (e.g. a 404 on CloseOperation / CloseStatement) is logged as a warning, emitted as error telemetry and reported in the returned status, and the operation is closed locally. Before the statement finishes, close failures still throw, since closing is what stops a running statement. Fixes #480 Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
vuanhphung
temporarily deployed
to
azure-prod
November 11, 2026 23:16 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 11, 2026 23:16 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 11, 2026 23:16 — with
GitHub Actions
Inactive
This branch was previously 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.
DBSQLOperation.close()rethrew any failure of the close request. A teardown CloseOperation that failed after the results were fully read (e.g. a 404) therefore escapedclose(), and the rest of the teardown was skipped: the operation stayed open locally (reads were not blocked), stayed registered on its session, and never emitted statement-complete telemetry. The same happened toautoCloseiterators and streams at the end of the data, and on the kernel backend whenever its CloseStatement fails.The fix is in the
DBSQLOperationfacade, so it covers both backends. Once the backend has reported the statement finished, a failed close is logged atwarn, emitted as error telemetry (as before), and reported in the returnedStatus'sinfo. The operation is then closed locally as usual. The server-side result is also freed when the session closes. Before the statement has finished, a close failure still throws and the operation stays open so the close can be retried, because there the close is what stops a running statement.Verification: new unit tests cover both backends with a mocked failing close (HTTP 404 and an error status): drained results,
finished(), anautoCloseiterator, the session-close cascade, and the still-throwing case before the statement finishes. All of them failed onmain.npm test(1535 passing), lint, type-check, and build pass. A live script against a warehouse, run on Thrift anduseKernel: true, checks three cases: a normal close after draining 10k rows; a close failure injected after draining (close()resolves, a warning is logged, reads are refused, andSELECT 1on the same session still works); and a close failure on a running query (still throws, then the retry succeeds). The injected-failure case fails onorigin/mainon both backends.Performance: the only addition to the default path is one flag store per wait. An in-memory micro-benchmark (200k chunks, 15 alternating fresh-process runs) gave a median of 202.3 ms on main and 204.7 ms on this branch, within the 0.9% A/A noise. Live execute+drain+close of
range(100000), alternating builds: Thrift 594.1 vs 600.3 ms (8 runs each), kernel 300.0 vs 304.6 ms (4 runs each), with overlapping ranges.Fixes #480
This pull request and its description were written by Isaac.