Repository navigation
Complete Volume file operations through the kernel backend - #1057
aakash-saravanan-db wants to merge 57 commits into
Conversation
There was a problem hiding this comment.
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_operationreturn 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 andinput_stream) and a rejected symlink outside the allowed root, so a mismatch with the kernel contract fails the build.
There was a problem hiding this comment.
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_commandfirst, then_kernel_handle.close()) now applies to every kernel result set, not only Volume ones. For async results,close_commandcloses the retained owning handle and the parentStatement(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_sessionnow cancels all in-flight sync cancellers and retained Volume cancellers, andclose_commandcancels a pending Volume canceller (client.py:784-790). The only Volume backend test coverscancel_commandandfinish_volume_operation.test_volume_close_signals_backend_before_native_lockuses a mocked backend, so it doesn't exercise the realclose_commandlogic. Add tests that (a)close_commandon a registered Volume id callscancel()and removes the entry, and (b)close_sessioncancels and clears both maps, even whencancel()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>
There was a problem hiding this comment.
🔀 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>
There was a problem hiding this comment.
🔀 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>
There was a problem hiding this comment.
🔀 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_ALLOWEDmessage 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, |
There was a problem hiding this comment.
🟠 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>
There was a problem hiding this comment.
🔀 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) |
There was a problem hiding this comment.
🔵 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, |
There was a problem hiding this comment.
🟠 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": |
There was a problem hiding this comment.
🔵 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
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_REVselects 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.