Skip to content

feat(volume): complete Volume PUT, GET and REMOVE in the kernel core - #520

Merged
aakash-saravanan-db merged 43 commits into
mainfrom
aakash-saravanan_data/feat/volume-core-rebuild-20261201
Dec 3, 2026
Merged

aakash-saravanan-db merged 43 commits into
mainfrom
aakash-saravanan_data/feat/volume-core-rebuild-20261201

Conversation

@aakash-saravanan-db

@aakash-saravanan-db aakash-saravanan-db commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds Volume file transfers to the kernel.

SQL PUT, GET and REMOVE on a Unity Catalog Volume return a one-row instruction: a presigned storage URL, request headers and, for PUT and GET, a local path. Today the kernel returns that row and moves no file, so every driver has to make the storage request itself. With StatementSpec::volume set, executing the statement now also runs that request: a PUT uploads the local file, a GET downloads into it and a REMOVE deletes the object.

statement
    .spec()
    .sql("GET '/Volumes/main/default/files/data.csv' TO '/tmp/data.csv'")
    .volume(Some(VolumeOptions::new(vec!["/tmp".into()], false)));
statement.execute().await?; // /tmp/data.csv now holds the object
  • Local paths, with symlinks resolved, must be inside VolumeOptions::allowed_paths.
  • PUT '__input_stream__' uploads VolumeOptions::input_bytes.
  • A failed transfer fails the execution. Local file errors carry the OS error and the path in Error::local_error.
  • Transient storage failures are retried with the session's retry settings. For a transfer, HttpConfig::request_timeout is an idle limit, not a total deadline.
  • Closing or cancelling the statement, its async handle or the session stops a running transfer, and so does dropping the owner's call. Dropping an AsyncStatementReader call leaves the transfer running.
  • A sync execute that fails after the statement ran, such as on a failed transfer, closes the server statement.
  • Without options, or on a handle from Session::attach_async_statement, the instruction row is returned and nothing moves, as today.

The VolumeOptions docs cover what a failed GET leaves behind, GET into pipes and character devices, and cancellation.

Binding APIs follow in #521. Supersedes #512.

Testing

cargo fmt --check, cargo clippy --all-targets -- -D warnings (default and tls-rustls) and cargo test pass: 1,419 passed and 67 ignored. New: 25 unit tests in src/volume.rs; 9 wiremock tests in tests/v0_volume_wiremock.rs that run transfers through execute, execute_direct and submit, stop them through each cancel, close and drop path, keep a reader's dropped call from stopping the owner's transfer, and check that a failed transfer closes the server statement; and 1 telemetry test.

Additional notes

  • Error and ResultManifest gain public fields (local_error, is_volume_operation), so code that builds them with struct literals must set them.
  • tempfile 3.27 or later becomes a regular dependency and is added to NOTICE. Every lockfile pins rustix 1.1.6, which fixes RUSTSEC-2026-0486.

This pull request and its description were written by Isaac.

@aakash-saravanan-db
aakash-saravanan-db marked this pull request as ready for review December 1, 2026 02:04
@aakash-saravanan-db
aakash-saravanan-db requested a review from a team as a code owner December 1, 2026 02:04
@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan_data/feat/volume-core-rebuild-20261201 branch from a427fd3 to 427de46 Compare December 1, 2026 02:16

@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: 2 High · 2 Medium · 3 Low

Overall the design is solid, but I found 2 medium and 2 low issues. Cancellation, at-most-once caching and path checks look correct. The main gaps are how the idle timeout treats in-memory uploads and an unrelated windows-sys downgrade in two lockfiles.

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

Comment thread src/volume.rs Resolved
Comment thread src/volume.rs Resolved
Comment thread Cargo.lock Resolved
Comment thread src/volume.rs Resolved
Comment thread src/volume.rs Resolved
Comment thread src/volume.rs Resolved
Comment thread src/client/http.rs Resolved
aakash-saravanan-db and others added 9 commits December 2, 2026 23:10
…m tests

- Dropping an `ExecutedAsyncStatement` no longer cancels a Volume
  transfer: a stream returned by `await_result` outlives the handle, as
  it already does for rows. Cancelling or closing the handle, the
  canceller, and session close still stop it. The canceller test now
  drops the handle before its transfer runs.
- The rustix lockfile bump is reverted; tempfile works with main's
  versions.
- A single read or write is bounded by a plain timeout instead of a
  progress channel with no sender.
- `AsyncStatementCanceller` stops the transfer inside `cancel()` instead
  of through a separate public method.
- Tests: the size-less PUT test keeps only the procfs case, the
  root-dependent read-only case is gone, the cut-off test covers the
  file retry that nothing else does, and one test is renamed for what it
  checks.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
…dency

The kernel's direct tempfile dependency puts rustix in the shipped Linux
dependency graph, where before it came in only through native-tls on
macOS. The Security Scan reads that graph, so rustix 1.1.4 and 1.1.5 fail
it on RUSTSEC-2026-0486. 1.1.6 is the version the napi and pyo3 lockfiles
already use.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
The transfer task now spawns through the session's runtime handle, like the
kernel's other session work, instead of whichever runtime awaits the
completion. Its writes then always run on the session runtime's threads, so
a session on a kernel-owned runtime keeps SIGPIPE blocked for a GET into a
pipe wherever the caller awaits.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
An instruction whose headers column is an empty or blank string now sends
the storage request without extra headers instead of failing as an invalid
instruction. A blank string has no other meaning, and storage still rejects
a request that needed a header.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
…rrors

Volume options now go on `StatementSpec::volume`. Executing a statement the
server marks as a Volume operation runs the transfer before the result is
returned, on the sync, async and direct paths, and a failed transfer fails the
execution. Without options the instruction row is returned and nothing moves.
This removes `ResultStream::complete_volume_operation`, `VolumeCompletion` and
`StatementCanceller::cancel_volume_operation`; caller bytes for
`PUT '__input_stream__'` are `VolumeOptions::input_bytes` and apply to one
execution.

A cancel that arrives while a GET puts its download in place no longer reports
`Cancelled` while the file is still written: that step runs to the end and the
result reports it. A GET into a missing folder reports the folder's OS error
and the requested path, not the temporary file's name.

Tests use instruction rows shaped like the server's (headers as a map, no
`localFile` for REMOVE), check gzip decoding, and are split so each covers one
behavior.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
A GET into a new file creates its temporary file with its own open, so a
folder that refuses the file reports the OS code, and uses a fixed name
prefix, so a destination name near the OS limit still fits. A GET into an
existing file in a folder on a read-only filesystem stages in the system temp
directory, as one in a folder that denies permission already did.

Upload bytes are released once their transfer starts. Dropping the owning
async statement or the `Statement` stops a running transfer, as closing them
does, instead of letting a reader write the file and then report an invalid
handle.

Tests cover the direct path, a cancel while a download is put in place, the
retry budget running from the first failure, the system-temp fallback, a
refused new file, and each close and drop path; pipe tests wait for the
storage request instead of sleeping, and combined tests are split.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
A second call on an execution whose `PUT '__input_stream__'` is still
uploading shares that upload's outcome instead of failing for missing bytes:
whether the execution has bytes is decided once, when its transfer starts.
A pipe GET with no reader is checked to wait up to the idle limit, and the
retry tests share one cut-off peer.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
…rs in place

A PUT, GET or REMOVE executed with Volume options whose result the server
did not mark as a Volume operation, such as one with bound parameters, now
fails instead of succeeding with no file moved.

A GET into an existing file whose folder refuses a temporary file writes
into the file directly, as the Thrift drivers do, instead of staging the
whole download in the system temp directory. Local file errors no longer
carry SQLSTATE HY000, which belongs to the ODBC mapping. `VolumeOptions`
prints the length of its input bytes, not their content.

Tests drop the cases that only re-checked fixes to earlier commits of this
change (the concurrent input-stream caller, the retry budget, the
system-temp fallback).

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
A Volume command the server left unmarked now finalizes its statement with
the error, as a failed transfer does, instead of recording success. The
command check compares the whole first word, so a SQL script label such as
`get_rows:` is not taken for a GET. The test of an existing file in a folder
that refuses temporary files is restored; it covers the in-place write.

Co-authored-by: Isaac <no-reply@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 · 1 Low

Good overall, with one high concern about semver compatibility. The transfer, cancellation, retry and path-checking logic holds up when read closely, and the wiremock tests cover every cancel and close route.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🟡 Medium src/volume.rs:336 — The retry budget only gates scheduling, so an attempt started just before overall_timeout expires can run indefinitely when storage_read_timeout is disabled, or
    Judge's evidence: // The retry budget runs from the first failure, so a long transfer that // is still making progress keeps the whole bud…

Comment thread src/volume.rs Resolved
Comment thread src/kernel_error.rs Resolved
aakash-saravanan-db and others added 8 commits December 3, 2026 00:34
Only a result the server marks as a Volume operation runs a transfer
again; an unmarked one returns its row and moves no file. Removes
is_volume_command, the per-execution flag and VolumeState::unmarked,
with the telemetry case and wiremock rows that covered them.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Removes doc comments on private helpers and test helpers whose name and
body already say what they do, comments that repeat the VolumeOptions
contract elsewhere, and a stale Destination summary. Contracts, caveats
and non-obvious reasons stay.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
is_volume_operation, SessionInner::storage and ExecutedAsyncStatement::volume
move to the end of their structs. VolumeOptions now says a transfer runs
for a result the server marks as a Volume operation. Drops four more
comments that restate the code.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Presigned storage URLs name the exact regional endpoint, and S3 answers
a wrong-region request with a 301 that has no Location, so the manual
redirect loop never had a redirect to follow. Any 3xx now fails the
transfer with its HTTP status. Removes the loop, redirect_target and
three redirect tests; one test pins that a 303 to a PUT is not followed.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
A GET into a new file now creates the file right after the path check
and writes into it, and removes it unless the download completes. A
cancel waits for the aborted transfer to drop, so the file is gone
before the call reports Cancelled. This replaces the temporary file, the
no-replace rename, its copy fallback, the file mode and name-prefix
handling and the second path check.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Removes HttpConfig::storage_read_timeout. A transfer now fails after the
session's request_timeout passes without progress, so the setting every
binding already maps its socket timeout to also bounds transfers, with
no separate knob.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Drops the whole read for files that report size 0, which only mattered
for procfs sources.

Co-authored-by: Isaac <no-reply@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: 3 Low

Mostly solid, with one medium semver concern and one low test-coverage gap. Cancellation, retries, the idle limit and local-path containment are carefully handled and well tested against mocks; no live-warehouse test confirms the instruction-row format.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🟡 Medium src/volume.rs:296 — The retry budget is checked only after an attempt fails, so a retry started just before budget expiry can run indefinitely while making progress despite the con
    Judge's evidence: // The retry budget runs from the first failure, so a long transfer that // is still making progress keeps the whole bud…

Comment thread src/volume.rs Resolved
Comment thread src/kernel_error.rs Resolved
Comment thread tests/v0_volume_wiremock.rs Resolved
Co-authored-by: Isaac <no-reply@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 Low

Looks solid, with 1 medium and 1 low concern. Path confinement, cancellation wiring, retries and cleanup of a new GET destination all check out. The open risks are matching the server's real output: the instruction column names have no live-warehouse test, and the manifest fails to parse if the server sends is_volume_operation as null.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.

🔀 3 findings considered and dismissed by the judge
  • 🟡 Medium src/volume.rs:414 — Timing out the entire write_all treats a slowly draining pipe as stalled even when partial writes keep making progress, so a valid GET can fail after delivering
    Judge's evidence: self.bounded(async { sink.write_all(&chunk).await.map_err(local_error) })
  • 🟡 Medium src/volume.rs:578 — The instruction row is read by column name (operation, presignedUrl, headers, localFile), and the only tests are wiremock fixtures that use those same n
    Judge's evidence: url: text("presignedUrl")?,
  • 🟡 Medium tests/v0_volume_wiremock.rs:179 — The transfer tests use synthetic instruction rows and placeholder SQL, so they cannot establish that real warehouse PUT, GET and REMOVE responses satisfy the ne
    Judge's evidence: async fn mount_volume_result(server: &MockServer, operation: &str, local: &str, marked: bool) {

Comment thread src/types/sea.rs Resolved
Comment thread src/volume.rs Outdated
.storage
.runtime
.spawn(async move { state.transfer(instruction, &options, input_bytes).await });
let _abort = AbortOnDrop(task.abort_handle());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A non-owning reader runs the shared transfer under AbortOnDrop, so dropping its future aborts the task and latches started. The owner's await_result() then returns Cancelled even though it never cancelled. Repro: submit a GET, take reader(), time the reader out after 300ms while storage holds its response for 2s; owner.await_result() gives Cancelled and no file. This contradicts the reader docs and the owning filter in cancel_volume. Could the spawned task own the outcome (transfer + publish, result stored in the cell), with waiters only awaiting it and abort only via the cancellation token?

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.

Fixed in c5e2b30, along the lines you suggested. The spawned task now owns the transfer and its publish, and every call waits on its shared outcome, so dropping a call no longer aborts it. Cancelling the execution stops it, with one addition: a dropped call from the owning handle also cancels, so Ctrl-C in PyO3 (which drops the future) and a timeout around execute() still stop the transfer. An AsyncStatementReader call never does. a_dropped_reader_call_leaves_the_transfer_to_the_owner is your repro: the reader's call is dropped mid-download, then the owner's await_result() succeeds and the object is fetched once. AbortOnDrop and the started flag are gone, and the VolumeOptions doc now says which dropped calls stop a transfer.

Comment thread Cargo.toml Outdated
rand = "0.10"

# Temporary files for Volume GET downloads
tempfile = "3"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

TempPath::try_from_path (volume.rs:779) first shipped in tempfile 3.27.0. With tempfile = "3", a consumer locked on 3.26 or older fails with E0599 (reproduced with cargo update -p tempfile --precise 3.26.0). Please require tempfile = "3.27"

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.

Fixed in 4eaeb61: tempfile = "3.27".

Comment thread src/statement/mutable.rs

let mut result_stream = ResultStream::from_reader(result.reader).await?;
result_stream.attach_telemetry(telemetry_for_body.clone());
result_stream

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

last_statement_id is set before complete_volume(...)?, so if the transfer fails after a SUCCEEDED execute, nothing owns the id and Statement::drop doesn't close it (the comment at 1145-1151 no longer holds). In a mock test, a failed transfer followed by drop sent 0 CloseStatement requests, against 1 for a successful execute followed by drop. Can we close the statement on this error path?

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.

Fixed in 8790496. execute and execute_direct now call invalidate_prior() when they fail, which closes a statement they already recorded unless the server reported it closed. That covers a failed transfer and the earlier stream and row-count failures. a_failed_transfer_closes_the_server_statement checks that each path sends one CloseStatement, and the Statement::drop comment now matches.

aakash-saravanan-db and others added 3 commits December 3, 2026 08:19
TempPath::try_from_path first shipped in tempfile 3.27.0, so a consumer
whose lockfile resolves an older 3.x failed to build with "tempfile = 3".

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
The transfer ran inside whichever call started it, so dropping a reader's
call aborted it, and the owner's await_result then reported Cancelled. The
spawned task now owns the transfer and its publish, and every call waits on
its shared outcome. Cancelling the execution stops it, and so does dropping
a call from the owning handle, so Ctrl-C and timeouts still stop a sync
execute. Dropping an AsyncStatementReader call leaves it running.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
execute and execute_direct record the statement id before building the
result stream, running a Volume transfer and reading the row count. When one
of those failed, no executed handle owned the id, so dropping the Statement
left the server statement open until session close. The failed execute now
closes it, as a failed batch already did.

Co-authored-by: Isaac <no-reply@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: 2 High · 2 Low

Solid implementation with thorough tests. One high-severity concern: the public field additions in this 1.x crate are a semver break. One low-severity retry edge case on REMOVE.

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

Other findings

  • 🟠 High — Appending storage-controlled XML Message text verbatim can expose echoed presigned URLs or query credentials in caller errors and retry logs, bypassing storage_error's URL redaction. Restrict diagnostics to safe codes and request IDs or redact credentialed values before storing them, and add an echoed-secret regression test. (Found by GPT-6.1 Sol · the judge couldn't confirm it)

Comment thread src/volume.rs Resolved
Comment thread src/kernel_error.rs Resolved
Comment thread src/volume.rs Resolved

This branch was successfully deployed

1 active deployment
azure-prod — 87904964 Deployed Dec 3, 2026 by aakash-saravanan-db via followup #5207
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.

2 participants