Skip to content

Complete Volume file operations through the kernel backend - #1057

Open
aakash-saravanan-db wants to merge 57 commits into
mainfrom
aakash-saravanan_data/feat/volume-restart-20261113
Open

aakash-saravanan-db wants to merge 57 commits into
mainfrom
aakash-saravanan_data/feat/volume-restart-20261113

Conversation

@aakash-saravanan-db

@aakash-saravanan-db aakash-saravanan-db commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Feature or gap

Kernel-backed cursors need to complete server-marked Volume transfers through the Python staging API.

What this PR addresses

Complete file PUT, GET, REMOVE and BinaryIO PUT through the native core. Keep the mutable statement owner and detached canceller available during synchronous transfer, consume instruction rows on completion, and preserve Python filesystem and HTTP exception mapping. Async execution completes through its retained result stream. Cancelling or closing the cursor stops a running transfer; the Thrift backend lets it finish. Resolved symlink targets must stay within staging_allowed_local_path.

Dependencies

Requires the kernel Volume APIs in databricks/databricks-sql-kernel#513 and a compatible coordinated native release. The package floor and lock must select that release, with clean installed-driver validation before merge.

Kernel version

The compatible kernel release has not been selected. When it is available, update the dependency floor and lockfile in this PR and validate a clean installation before merge. KERNEL_REV selects source for local and CI builds only.

Tests and validation

The focused client and result-set suites pass. Local validation uses source-built native inputs; package installation and scheduled activation remain separate gates.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 High · 1 Medium · 1 Low

Needs changes. The main blocker is that the code relies on new kernel APIs while the dependency floor still allows older wheels, which would break every kernel query, not only Volume operations. There is also a KeyError crash when the best-effort canceller is missing.

Other findings

  • 🔵 Low — This PR deletes the kernel e2e tests for staging and adds no replacements. All new coverage uses mocks that invent is_volume_operation, complete_volume_operation return strings ("needs_input_stream", "completed", "not_volume") and exception attributes (local_os_error, http_status, local_path). Nothing in CI checks that the real kernel binding actually has these names and values. Please add kernel e2e cases, such as PUT→GET→REMOVE round trips (file and input_stream) and a rejected symlink outside the allowed root, so a mismatch with the kernel contract fails the build.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 High · 1 Medium · 2 Nit

Needs changes: 1 high, 1 medium and 2 low findings. The high one: the new is_volume_operation attribute is read unconditionally on every execute, but the kernel floor is still ^1.4.0, so released wheels would break all kernel queries. The medium one: any kernel error with an HTTP status is turned into a generic staging OperationalError. Follow-up already noted in the PR: Windows and installed released-package validation are still open.

Other findings

  • ⚪ Nit — The new ordering (backend close_command first, then _kernel_handle.close()) now applies to every kernel result set, not only Volume ones. For async results, close_command closes the retained owning handle and the parent Statement (client.py ~800-820) while the result stream taken from them is still open. Before this change the stream was closed first. Any error from closing the stream afterwards is logged and swallowed, but this changes the teardown order for all async results to work around a lock that only Volume transfers hold. Consider cancelling only the Volume canceller first and keeping the old order for everything else.
  • ⚪ Nit — Several new cancellation paths have no unit tests: close_session now cancels all in-flight sync cancellers and retained Volume cancellers, and close_command cancels a pending Volume canceller (client.py:784-790). The only Volume backend test covers cancel_command and finish_volume_operation. test_volume_close_signals_backend_before_native_lock uses a mocked backend, so it doesn't exercise the real close_command logic. Add tests that (a) close_command on a registered Volume id calls cancel() and removes the entry, and (b) close_session cancels and clears both maps, even when cancel() raises.

Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High

One high concern: the kernel floor isn't bumped. With a supported 1.5.x wheel, every kernel statement breaks, not only Volume ones. The rest of the cancellation, completion and error-mapping wiring looks consistent and has tests.

Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High

Needs changes: 1 high concern. The Volume completion and cancel wiring looks sound. However, the unconditional reads of the new kernel attribute break every kernel query on wheels the current ^1.5.0 floor still allows.

Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Nit

Needs changes — 1 high, 1 low. The Volume wiring, canceller lifetime and error mapping look right, but this can't merge until the kernel dependency floor is raised. Doc nit: the client.py comment says a positive _socket_timeout is the idle limit for Volume transfers, while CONNECTION_PARAMETERS.md says a redirected PUT resend has no idle bound.

Other findings

  • ⚪ Nit — The VOLUME_PATH_NOT_ALLOWED message literals in result_set.py are well over the repo's 100-character line limit. Split them into implicitly concatenated string pieces. (Found by Claude Opus 5.5 · confirmed by the judge)

results_queue=None,
description=description_from_arrow_schema(schema),
is_staging_operation=False,
is_staging_operation=kernel_handle.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 — KernelResultSet.__init__ and execute_command now read is_volume_operation unconditionally. pyproject allows ^1.5.0 and poetry.lock pins 1.5.0, and only KERNEL_REV (a CI source) changed. Wheels without the Volume API would raise AttributeError on every query. Raise the kernel floor in pyproject, regenerate the lock, and release the kernel wheel before merging.

🔀 Found by both reviewers · confirmed by the judge

Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 2 Low

Looks reasonable: 2 low concerns. Merge gate: KernelResultSet now reads kernel_handle.is_volume_operation unconditionally, so every query breaks on older kernel wheels until the dependency floor and lock are updated. Nit: the ProgrammingError message lines in result_set.py go over the 100-char limit.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

except BaseException:
self.close()
raise
outcome = self._complete_volume_operation(paths, data)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — If cursor.close() runs on another thread while input_stream.read() is in progress, close() sets _kernel_handle to None. The second _complete_volume_operation call then hits AttributeError, which is wrapped as a generic error. Capture the handle locally, or check for a closed handle and raise a clear cancelled/closed error.

🔀 Found by Claude Opus 5.5 · confirmed by the judge

results_queue=None,
description=description_from_arrow_schema(schema),
is_staging_operation=False,
is_staging_operation=kernel_handle.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 — KernelResultSet now reads kernel_handle.is_volume_operation for every result, but pyproject still allows kernel ^1.5.0, which lacks the Volume APIs. Ordinary SELECTs could fail with an installed release. Raise the floor and lock to the kernel release that ships the Volume API, and test a clean install.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

paths or [], remove_not_found_is_success=False, input_bytes=input_bytes
)
except Exception as exc:
if getattr(exc, "error_code", None) == "VOLUME_PATH_NOT_ALLOWED":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — No test covers the VOLUME_PATH_NOT_ALLOWED to ProgrammingError mapping or its two messages, one for paths outside the roots and one for no configured roots. Add a parametrized test for paths=None and paths=['/allowed'] that asserts the class, the message and cause.

🔀 Found by Claude Opus 5.5 · confirmed by the judge

This branch was previously deployed

1 inactive deployment
azure-prod — 74d858de Deployed Nov 30, 2026 by oss-reviewer-bot[bot] via followup #2694
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