Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
045eb3d
Complete Volume file operations through the native kernel
aakash-saravanan-db Nov 13, 2026
39e220b
Consume Volume instructions after failed completion
aakash-saravanan-db Nov 13, 2026
a9d2822
Fetch completed async results without a redundant status poll
aakash-saravanan-db Nov 13, 2026
83c64bc
Clarify asynchronous Volume completion
aakash-saravanan-db Nov 13, 2026
60405d2
Pin the native source for Volume completion
aakash-saravanan-db Nov 14, 2026
bf4b6fe
Document completed async result retrieval
aakash-saravanan-db Nov 14, 2026
1f46bb1
Select the Windows-compatible Volume kernel
aakash-saravanan-db Nov 14, 2026
49467c5
Keep async result reuse in the kernel and tolerate missing cancellers
aakash-saravanan-db Nov 14, 2026
72b2ff4
Pin native Volume storage retry and terminal response fixes
aakash-saravanan-db Nov 14, 2026
6edd22c
Preserve Volume error provenance and stream teardown
aakash-saravanan-db Nov 14, 2026
2e792ad
Avoid cancelling completed Volume transfers during close
aakash-saravanan-db Nov 14, 2026
96ab090
Format Volume cancellation cleanup comprehension
aakash-saravanan-db Nov 14, 2026
74b9ad7
Select native Volume inactivity timeout correction
aakash-saravanan-db Nov 14, 2026
bdbcc38
build(kernel): select corrected Volume completion
aakash-saravanan-db Nov 14, 2026
e608451
build: select native Volume cancellation and error handling
aakash-saravanan-db Nov 15, 2026
a331f18
build: use native root authorization fix
aakash-saravanan-db Nov 15, 2026
97b297f
build: update kernel source for replayable uploads
aakash-saravanan-db Nov 15, 2026
6eba7a7
build: update kernel for local stream close
aakash-saravanan-db Nov 15, 2026
ae01e83
fix(volume): select replayable file uploads and tighten validation
aakash-saravanan-db Nov 15, 2026
5b71b2d
fix(kernel): use permission-preserving Volume downloads
aakash-saravanan-db Nov 16, 2026
6abd81c
build(kernel): select sanitized storage redirects
aakash-saravanan-db Nov 16, 2026
fe93149
Select native Volume lifetime and replay implementation
aakash-saravanan-db Nov 16, 2026
25bd38f
Pin kernel with statement lifecycle cleanup
aakash-saravanan-db Nov 16, 2026
bc0de64
Document Volume handles and verify async owner cleanup
aakash-saravanan-db Nov 16, 2026
78789f7
build: select kernel with async result cleanup
aakash-saravanan-db Nov 16, 2026
4923547
build: select kernel with Volume instruction error telemetry
aakash-saravanan-db Nov 16, 2026
663b751
build: pin kernel with complete Volume instruction handling
aakash-saravanan-db Nov 16, 2026
eec3ca9
build: use corrected kernel volume completion
aakash-saravanan-db Nov 17, 2026
6ef4e29
build: select kernel with origin-safe Volume redirects
aakash-saravanan-db Nov 17, 2026
ccd617a
build: select kernel with normalized upload lengths
aakash-saravanan-db Nov 17, 2026
689ae4a
build: pin kernel completion telemetry correction
aakash-saravanan-db Nov 17, 2026
a22c079
build: select kernel with restricted-directory GET support
aakash-saravanan-db Nov 18, 2026
8a2a79a
Keep distinct Volume ownership test cases
aakash-saravanan-db Nov 18, 2026
923910c
build: pin kernel with bounded symlink resolution
aakash-saravanan-db Nov 18, 2026
8d0564f
Document kernel connection-close cancellation
aakash-saravanan-db Nov 18, 2026
afe2b3b
refactor(volume): streamline completion ownership
aakash-saravanan-db Nov 19, 2026
cd76794
build: select updated Volume kernel
aakash-saravanan-db Nov 19, 2026
b69bf71
fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 20, 2026
99142c7
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 20, 2026
ec8aebc
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 20, 2026
cc78e88
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 20, 2026
88d4cd7
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 20, 2026
6d98fe1
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 20, 2026
f9e2121
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 20, 2026
3b36a8b
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 21, 2026
24eedca
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 22, 2026
7f2e16a
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 22, 2026
0c44d15
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 22, 2026
10e4c12
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 23, 2026
27a7b44
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 23, 2026
2e1419e
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 23, 2026
4fba913
fixup! fix(volume): preserve Python errors and transfer telemetry
aakash-saravanan-db Nov 23, 2026
d039556
fix(volume): preserve HTTP status in staging errors
aakash-saravanan-db Nov 24, 2026
65a252d
docs(volume): format the transfer timeout setting
aakash-saravanan-db Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/kernel-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ jobs:
DATABRICKS_SERVER_HOSTNAME: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }}
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
DATABRICKS_CATALOG: peco
steps:
- name: Check out connector
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Unreleased
- Speed up `fetchone()`, `fetchmany()` and `fetchall()` by building each result `Row` with fewer Python calls. The rows are unchanged. Large results and many concurrent cursors in one process benefit most.
- Support Volume `PUT`, `GET` and `REMOVE` on the kernel backend, including existing Python stream uploads. Local file paths and resolved symlink targets must stay within configured allowed roots.

# 4.10.0 (2026-11-24)
- Upgrade Databricks SQL Kernel to 1.5.0, with lower overhead for buffered fetches and closing drained cursors, and Arrow and Quinn security updates.
Expand Down
30 changes: 23 additions & 7 deletions CONNECTION_PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ to change without notice.

| Option | Type | Thrift | Kernel | Default Value | Note |
| ------------------------------------ | ----------- | :----: | :----: | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `_socket_timeout` | `float` (s) | ✅ | ✅ | `900` (Thrift); `120` (kernel) | Thrift: socket send/recv/connect timeout. Kernel: total HTTP request deadline from connect through response-body completion. A positive value is forwarded; unset or `0` selects the kernel's 120s default. On the kernel path, `0` is neither unlimited nor an immediate timeout. |
| `_socket_timeout` | `float` (s) | ✅ | ✅ | `900` (Thrift SQL); `120` (kernel SQL) | Thrift: socket send/recv/connect timeout. Kernel: total HTTP request deadline from connect through response-body completion. A positive value is forwarded; unset or `0` selects the kernel's 120s SQL request default. For Volume transfers see Volume file paths. |
| `_pool_connections` | `int` | ⚠️ | ❌ | `10` | Number of pools in the shared Python HTTP client. On Thrift this affects auxiliary auth/feature-flag/telemetry traffic, not the separate Thrift query transport. Kernel-owned network traffic does not use this client. |
| `_pool_maxsize` | `int` | ⚠️ | ⚠️ | `20` (Python); `100` (kernel when unset) | Max idle connections retained per host. It configures the shared Python client but not the Thrift query transport. With kernel ≥ 1.1.0, a positive value also configures the kernel's Rust HTTP pool. Unset or `0` keeps each client's default. |
| `_proxy_auth_method` | `str` | ✅ | ❌ | `None` | `basic` or `negotiate` (Kerberos). Applied to both Thrift query traffic and the shared Python client. It is not forwarded to the kernel's Rust transport. See [`docs/proxy.md`](docs/proxy.md). |
Expand Down Expand Up @@ -171,7 +171,7 @@ to change without notice.
| `use_inline_params` | `bool` \| `"silent"` | ✅ | ✅ | `False` | Render parameters inline (legacy) vs. native bound params (DBR 14.1+). Shared cursor code performs the rendering before dispatch, so both backends honor it identically. |
| `ignore_transactions` | `bool` | ✅ | ✅ | `True` | When `True`: `commit()` is a no-op, `rollback()` raises `NotSupportedError`, and setting `autocommit` is a no-op. |
| `fetch_autocommit_from_server`| `bool` | ✅ | ✅ | `False` | Query the server (`SET AUTOCOMMIT`) for autocommit state instead of returning the cached value. |
| `staging_allowed_local_path` | `str` \| `List[str]` | ✅ | ❌ | `None` | Local path(s) permitted for Unity Catalog Volume `PUT`/`GET`. **Thrift-only** — the kernel has no Volume API yet. |
| `staging_allowed_local_path` | `str` \| `List[str]` | ✅ | ✅ | `None` | Local path(s) permitted for Unity Catalog Volume `PUT`/`GET`. Kernel also checks resolved symlink targets; see below. |

## Telemetry

Expand Down Expand Up @@ -208,13 +208,12 @@ are forwarded when supported by the installed kernel binding.
`enable_query_result_lz4_compression`.
5. Arrow-native rendering for `_use_arrow_native_decimals` /
`_use_arrow_native_timestamps` (complex types **are** forwarded).
6. `staging_allowed_local_path` (Volume `PUT`/`GET`).
7. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`,
6. Retry fine-tuning beyond the four forwarded knobs: `_retry_delay_default`,
`_retry_dangerous_codes`, `_respect_server_retry_after_header`,
`_retry_max_redirects`, `_enable_v3_retries`.
8. `force_enable_telemetry`.
9. `_port` and `_connection_uri`.
10. `_pool_connections` and `_proxy_auth_method` do not configure the
7. `force_enable_telemetry`.
8. `_port` and `_connection_uri`.
9. `_pool_connections` and `_proxy_auth_method` do not configure the
kernel-owned network stack.

### Supported on Kernel, missing / ignored on Thrift
Expand Down Expand Up @@ -242,6 +241,23 @@ are forwarded when supported by the installed kernel binding.
`force_enable_telemetry`, and an omitted `enable_telemetry` or circuit-breaker
setting uses the kernel's default.

### Volume file paths

With `use_kernel=True`, SQL `PUT`, `GET` and `REMOVE` complete their file
operations before `execute()` or `get_async_execution_result()` returns.
`PUT` and `GET` require requested paths and resolved symlink targets within
`staging_allowed_local_path`; `REMOVE` needs no local root.
`execute(input_stream=stream)` reads the stream only when requested by the server.
Completed transfers return no instruction rows.
On the kernel backend, cancelling or closing the cursor stops a running
transfer. The Thrift backend lets it finish.
A GET that has started copying into the destination finishes the copy.

Volume transfers have no total deadline.
An explicit positive `_socket_timeout` caps storage connection establishment, reads, upload progress and PUT response waits.
A redirected PUT resend has no idle bound.
Unset or `0` leaves storage inactivity unbounded.

> All kernel-path behavior reflects the current **early-access** surface and is
> subject to change. Generated against connector version `4.5.0`; the source of
> truth is `Connection.__init__` (`src/databricks/sql/client.py`) and the
Expand Down
2 changes: 1 addition & 1 deletion KERNEL_REV
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5c3a909771f749174567af074bfe18c24a335f5c
2d5518601d631e4274f0ab3662235c509e746950
9 changes: 8 additions & 1 deletion src/databricks/sql/backend/kernel/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ def reraise_kernel_error(exc: "_kernel.KernelError") -> "Error":
"operation-id": getattr(exc, "query_id", None),
"diagnostic-info": getattr(exc, "diagnostic_info", None),
}
new = cls(getattr(exc, "message", str(exc)), context)
message = getattr(exc, "message", str(exc))
if getattr(exc, "error_code", None) == "VOLUME_STORAGE_HTTP_ERROR":
cls = OperationalError
message = (
"Staging operation over HTTP was unsuccessful: "
f"{getattr(exc, 'http_status', None)}-{message}"
)
new = cls(message, context)

for attr in (
"code",
Expand Down
99 changes: 22 additions & 77 deletions src/databricks/sql/backend/kernel/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

- ``query_tags`` on execute is not supported (kernel exposes
``statement_conf`` but PyO3 doesn't surface it).
- Volume PUT/GET (staging operations): kernel has no Volume API
yet. Users on Thrift-only paths.
"""

from __future__ import annotations
Expand Down Expand Up @@ -84,41 +82,6 @@
# per-request skip-and-warn.
_KERNEL_MANAGED_HEADERS = frozenset({"authorization", "x-databricks-org-id"})

# Leading verbs of SQL volume/staging statements. Detected by the
# leading token (case-insensitive) so the kernel backend can fail loud
# on staging ops it can't service — see ``execute_command``.
_STAGING_VERBS = ("PUT", "GET", "REMOVE")


def _strip_leading_sql_comments(sql: str) -> str:
"""Strip leading whitespace and SQL comments (``-- …`` line and
``/* … */`` block, possibly several) from ``sql``, returning the
remainder.

Needed so staging detection sees the real leading verb: a
comment-prefixed staging op (``-- upload\\nPUT …`` or
``/* c */ PUT …``, common in ETL scripts) must still be classified
as staging, or it would slip past the guard into the silent-no-op
bug. Block comments do not nest in Databricks SQL, so a simple
scan-to-``*/`` is correct.
"""
i = 0
n = len(sql)
while i < n:
if sql[i].isspace():
i += 1
elif sql.startswith("--", i):
# Line comment: skip to end of line (or string).
nl = sql.find("\n", i)
i = n if nl == -1 else nl + 1
elif sql.startswith("/*", i):
# Block comment: skip to closing */ (or end if unterminated).
close = sql.find("*/", i + 2)
i = n if close == -1 else close + 2
else:
break
return sql[i:]


def _is_not_found(exc: BaseException) -> bool:
"""True iff ``exc`` is a kernel ``NotFound`` error (HTTP 404 /
Expand Down Expand Up @@ -155,21 +118,6 @@ def _catalog_or_none(value: Optional[str]) -> Optional[str]:
return value


def _is_staging_statement(operation: str) -> bool:
"""True iff ``operation`` is a volume/staging statement (PUT / GET /
REMOVE).

Strips leading whitespace + SQL comments first (so a comment-
prefixed staging op is still caught), then matches the leading token
only — so a normal query that merely *contains* the word (e.g.
``SELECT 'GET' AS x``) isn't misflagged.
"""
stripped = _strip_leading_sql_comments(operation)
# First whitespace-delimited token, uppercased.
verb = stripped.split(None, 1)[0].upper() if stripped.strip() else ""
return verb in _STAGING_VERBS


class _KernelSessionParameterSupport(NamedTuple):
session_type: Any
parameters: FrozenSet[str]
Expand Down Expand Up @@ -443,6 +391,9 @@ def __init__(
# Guarded by its own lock — cancel can race execute teardown.
self._sync_cancellers: Dict[int, Any] = {}
self._sync_cancellers_lock = threading.RLock()
# Cancellers for synchronous Volume statements, kept until the transfer
# ends so cursor.cancel() can stop it.
self._volume_cancellers: Dict[str, Any] = {}

# ── Session lifecycle ──────────────────────────────────────────

Expand Down Expand Up @@ -643,24 +594,6 @@ def execute_command(
# ``_async_statements`` and closed by ``close_command``); the sync
# path drops it in finally. ``close_stmt`` is the post-success
# decision flag — it stays True on sync, flips to False on async.
# Volume/staging (PUT/GET/REMOVE) is not supported on the kernel
# path: the kernel returns the staging control row as a normal
# result set (``KernelResultSet.is_staging_operation`` is always
# False), so the connector's ``_handle_staging_operation`` never
# fires and NO file is transferred. Rather than silently no-op
# (the Thrift path performs the presigned-URL upload/download),
# fail loud at the call site so ETL scripts don't ingest
# stale/missing data. Detected by the leading SQL verb — the
# only signal available pre-execute, since the kernel exposes no
# staging marker today.
if _is_staging_statement(operation):
raise NotSupportedError(
"Volume / staging operations (PUT / GET / REMOVE) are not "
"supported on the kernel backend (use_kernel=True); the file "
"transfer would silently not happen. Use the Thrift backend "
"for staging operations."
)

close_stmt = True
try:
try:
Expand Down Expand Up @@ -702,6 +635,12 @@ def execute_command(
# Canceller is best-effort; never block execute on it.
pass
executed = stmt.execute()
command_id = CommandId.from_sea_statement_id(executed.statement_id)
if executed.is_volume_operation:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High — pyproject.toml:73 still allows databricks-sql-kernel ^1.4.0, but the code now calls three kernel APIs that don't exist yet: ExecutedStatement.is_volume_operation (read here on every sync execute), kernel_handle.is_volume_operation (read in KernelResultSet.__init__ for every result, including metadata ResultStreams), and fetch_result() in place of await_result() for async results.

If the resolver installs any wheel in the allowed range that lacks them, this isn't limited to Volume ops. Every execute(), every metadata call and every get_async_execution_result() raises AttributeError, so ordinary SELECT 1 breaks on use_kernel=True. The PR description says the floor "has not been selected". This should block merge: bump the floor in the same change. Until then, reading is_volume_operation with getattr(..., False) would at least keep non-volume queries working.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional-canceller defect is corrected at ab1efce1: registration uses .get, the Statement remains retained, and cleanup skips absent cancellers. All 276 affected tests pass; final native live checks preserve lazy BinaryIO and one-read empty/nonempty streams.

The new Volume marker/completion API dependency is a valid merge prerequisite. The source build pins compatible 22f96fac; a compatible published native version/floor and installed-package proof remain explicitly open. This PR is not merge-ready, and no old-native fallback or invented release version was added.

The fetch_result subclaim is separate: released 1.4.0 exposes it, but the substitution is removed from this PR. Merged native #451 provides terminal-response reuse with the original await_result boundary. Actual public-cursor owner and reader/refetch tests show identical await/fetch requests, rows and metadata on the selected native; redundant #1056 is superseded without merge.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming the Volume-marker dependency is a merge prerequisite, and for dropping the fetch_result() substitution. That part of the finding is resolved. The core issue is still there, though. pyproject.toml:73 still says databricks-sql-kernel ^1.4.0. Line 641 still reads executed.is_volume_operation with no guard. KernelResultSet.__init__ still reads kernel_handle.is_volume_operation the same way. So if a published wheel in that range lacks the marker, ordinary sync executes and metadata calls fail with AttributeError before the code ever checks for a Volume op. A source build pinned to 22f96fac doesn't limit what the resolver installs. Leaving this open until the floor is raised to the first published wheel that ships the marker, or until both reads are guarded so non-volume queries keep working.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction on the release gate: kernel 1.5.0 was released on 2026-11-23 without the Volume API, and pyproject.toml:73 already reads ^1.5.0, so that floor does not meet the gate. Earlier replies on this PR that name 1.5.0 as the gate release are superseded. The gate is the first kernel release that includes databricks-sql-kernel#465; the floor and poetry.lock move to that release before merge. Keeping this thread open until then.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open at a9bb4d2: pyproject.toml floor ^1.5.0 predates databricks-sql-kernel#465, and client.py:639 reads is_volume_operation without a guard.

Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High — The code reads is_volume_operation and calls complete_volume_operation on every kernel result, but pyproject.toml still allows ^1.5.0. KERNEL_REV only changes the CI source, so a released wheel without these attributes would raise AttributeError on ordinary SELECTs. Bump the floor and lock to the kernel release that has the Volume API, or read the attribute with getattr(..., False).

🔀 Found by both reviewers · confirmed by the judge

with self._sync_cancellers_lock:
self._volume_cancellers[command_id.guid] = (
self._sync_cancellers.get(id(cursor))
)
# Execute succeeded: the kernel now owns the statement
# lifecycle. It auto-closes the server statement when the
# result stream is fully drained (``ExecutedStatement::
Expand Down Expand Up @@ -751,7 +690,6 @@ def execute_command(
except Exception:
pass

command_id = CommandId.from_sea_statement_id(executed.statement_id)
# Surface the affected-row count for DML (INSERT/UPDATE/DELETE/
# MERGE) as ``cursor.rowcount`` instead of the hardcoded ``-1``.
# ``num_modified_rows`` is ``None`` for SELECT (and warehouses
Expand All @@ -774,16 +712,21 @@ def execute_command(
try:
return self._make_result_set(executed, cursor, command_id)
except Exception as exc:
self.finish_volume_operation(command_id)
raise _wrap_kernel_exception("execute_command", exc) from exc

def finish_volume_operation(self, command_id: CommandId) -> None:
with self._sync_cancellers_lock:
self._volume_cancellers.pop(command_id.guid, None)

def cancel_command(self, command_id: CommandId) -> None:
with self._async_handles_lock:
handle = self._async_handles.get(command_id.guid)
with self._sync_cancellers_lock:
handle = self._volume_cancellers.get(command_id.guid)
if handle is None:
# Sync-execute paths fully materialise the result before
# ``execute_command`` returns, so by the time
# cancel_command can fire there's nothing in flight.
# Match the Thrift backend's tolerant behaviour.
with self._async_handles_lock:
handle = self._async_handles.get(command_id.guid)
if handle is None:
# Completed synchronous operations have no retained canceller.
logger.debug("cancel_command: no in-flight async handle for %s", command_id)
return
try:
Expand Down Expand Up @@ -832,6 +775,8 @@ def cancel_running_cursor(self, cursor: "Cursor") -> bool:
return True

def close_command(self, command_id: CommandId) -> None:
with self._sync_cancellers_lock:
self._volume_cancellers.pop(command_id.guid, None)
with self._async_handles_lock:
handle = self._async_handles.pop(command_id.guid, None)
stmt = self._async_statements.pop(command_id.guid, None)
Expand Down
Loading
Loading