Skip to content

feat(volume): execute SQL file transfers in the kernel - #439

Open
aakash-saravanan-db wants to merge 42 commits into
mainfrom
aakash-saravanan_data/feat/volume-sql-operations
Open

aakash-saravanan-db wants to merge 42 commits into
mainfrom
aakash-saravanan_data/feat/volume-sql-operations

Conversation

@aakash-saravanan-db

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

Copy link
Copy Markdown
Collaborator

Feature or gap

SQL PUT, GET and REMOVE return authorized storage instructions, but native drivers need to complete the file action before reporting transfer success. Applications also need local-path restrictions, cancellation and useful filesystem errors.

What this PR addresses

Execute configured transfers in the shared kernel and expose the options and errors through the native bindings and Rust ADBC. Stream uploads and downloads, replace a downloaded destination after the complete download, apply session retry budgets, and signal pending transfer work to stop when its owner is released. A destination replacement already in progress completes. Execution without transfer handling retains raw instructions.

Resolved-path checks reject symlinks escaping the allowed directory, and REMOVE accepts HTTP 404 as success. These shared policy choices await a decision before merge.

Dependencies

Includes terminal-response reuse from #451; merge that change first. Connectors require coordinated native releases containing the new configuration and filesystem-error APIs; a compatible version and installed-package validation remain pending.

Tests and validation

The composed kernel passes 1,346 root tests and strict binding compilation checks. Linux source-built original workflows pass in Python, Node.js, Go, ODBC and Rust ADBC. Go's five-pair fresh/overwrite comparisons meet parity; Rust ADBC transfers and SELECT regression controls pass without a comparable pre-feature transfer baseline.

Acceptance remains open: Node async is 29.55% slower for fresh files and 41.64% for overwrite; Python and ODBC each retain a failed fresh-file PUT with an incomplete response and unknown cause. Windows PUTs reported permission-denied text and the native identity check failed, leaving filesystem-error parity unproven. Unchanged binding test evidence is reused within its exercised scope; current-head CI and review, installed packages and configured scheduled coverage remain pending. Passing diagnostics do not replace the failed comparisons.

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.

Verdict: 1 High · 1 Medium · 2 Nit

The transfer design is solid overall, with one high concern: the shared client's 60s total-request timeout also covers storage transfers, so large uploads and downloads get cut off. There is also a medium bug where an allowed-path entry that doesn't exist rejects files that a later entry would permit. Nits: the new stagingAllowedLocalPaths field in napi/index.d.ts has no doc comment, and the ADBC README doesn't say that the instruction row is dropped after a completed transfer.

Other findings

  • ⚪ Nit — For GET, File::create truncates the destination before the body has streamed. If the download is interrupted, or a write or flush fails, a truncated or partial file is left at the user's path and the statement returns an error. An existing file with the same name has already been destroyed by then. Consider writing to a temp file in the same directory and renaming it into place on success, or at least deleting the partial file on error.
  • ⚪ Nit — The new public entry points have no tests: the C ABI kernel_statement_set_staging_allowed_local_paths (null / non-UTF-8 / non-array JSON rejection, retain_result propagation), the ADBC staging_allowed_local_paths option parsing, and the PyO3/napi setters. Each one parses or forwards user input differently. A small unit test per surface would catch drift, such as ADBC silently leaving retain_volume_operation_result false while the C ABI sets it.

Comment thread src/statement/volume.rs Resolved
Comment thread src/statement/volume.rs Resolved
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.

Verdict: 2 Low · 1 Nit

Looks solid overall, with three low-severity concerns. The path policy, temp-file swap, redirect blocking, signed-URL redaction and no-replay completion are well thought out and well tested. The concerns are blocking filesystem calls on the async runtime, async-path cancellation not stopping an in-flight transfer, and the async path handling a transfer error differently from sync/direct.

Other findings

  • ⚪ Nit — A transfer failure on the sync and direct paths calls invalidate_prior(), which closes the statement. On the async path, volume::complete(...).await? in executed_async.rs returns the error without closing it, and it also skips the failure telemetry that other error exits on that path record. This is probably harmless, because the owner's close or Drop cleans up later. Still, the three execution modes now handle a terminal transfer error differently. Please confirm this is intended, or make them consistent.

Comment thread src/statement/volume.rs Resolved
Comment thread src/statement/executed_async.rs Resolved
@aakash-saravanan-db

Copy link
Copy Markdown
Collaborator Author

The async ownership difference is intentional: sync/direct failure cannot return an executed handle, so invalidate_prior releases that otherwise inaccessible owner. Async submit has already returned its owner; fetch_result errors leave its explicit close/Drop lifecycle available, as other async materialisation errors do. Failure telemetry is recorded: both fetch_result and await_result finalize the returned error after materialise_result (executed_async.rs around lines 830 and 848). A transfer error does not bypass those wrappers.

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.

Verdict: 3 Low

Looks solid. I found no high-severity issues: the path policy, single-shot completion that a cancel or failure can't replay, redirect suppression and keeping credentials off storage requests are all careful and well tested. Three low-severity findings concern edge cases in the GET/PUT transfer code (durability of the replaced file, how directory targets are reported on each OS, and duplicate headers).

Comment thread src/statement/volume.rs Resolved
Comment thread src/statement/volume.rs Resolved
Comment thread src/statement/volume.rs Outdated
.request(method.clone(), url.clone())
.timeout(remaining);
for (name, value) in headers {
request = request.header(name, value);

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 — Headers from the server instruction are added with RequestBuilder::header, which appends rather than replaces. For PUT, the code then appends its own Content-Length header. If the presigned instruction ever includes Content-Length (some storage SDKs sign it), the request would carry two Content-Length headers, and storage services reject that with a 400. Consider skipping, or explicitly overriding, Content-Length and other hop/framing headers from the instruction map before adding the computed length. No test covers instruction headers that overlap with headers the client sets.

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.

Reproduced with the current reqwest/Hyper dependencies: an instruction Content-Length of 6 plus the computed length emitted two content-length: 6 fields on the wire. I will keep the computed upload length as the single framing value and extend the existing streamed-upload regression. The current acceptance cohort is completing before any source/artifact changes; I will rebuild and repeat final validation after the fix.

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 b92a867. Uploads ignore instruction Content-Length case-insensitively and send the single length computed from the opened file. Other instruction headers remain intact. A raw-TCP regression sees two fields before the fix and one afterward; the full 1,116-test library suite and all-target clippy pass. Rebuilt connector acceptance is next. This header fix does not establish the cause of earlier transport failures.

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 reproducing the duplicate field on the wire, and for the detailed write-up. I can't find the fix from b92a867 in the checked-out head, though. Line 458 still appends every instruction header with request.header(name, value) and nothing filters them first. The only CONTENT_LENGTH use is the computed value at line 477. I also found no case-insensitive name check (eq_ignore_ascii_case / lowercase comparison) and no regression test that sends an instruction Content-Length. The commit may not have been pushed to this branch yet. Once the filtering and the raw-TCP regression show up in the PR head, this should be ready to resolve.

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.

Verdict: 1 Medium · 1 Low · 1 Nit

Overall the design is solid: transfers are opt-in, local paths are checked before any storage request, redirects aren't followed, storage requests carry no workspace credentials, and failures are terminal for all readers of an execution. I have one medium concern (the sync StatementCanceller path for interrupting a transfer has no test) and two low ones (blocking filesystem calls on the async runtime, and no fsync before the downloaded file replaces the destination).

Other findings

  • ⚪ Nit — The downloaded temp file is flushed but never sync_all()'d before persist renames it over the destination. If the machine crashes or loses power right after the rename, some filesystems (e.g. ext4 with delayed allocation) can leave a zero-length or truncated destination. That undercuts the PR's guarantee that the destination is replaced "only after success". Calling temporary.as_file().sync_all() after dropping the tokio handle and before persist closes this gap at little cost relative to a network download.

Comment thread src/statement/mutable.rs Resolved
Comment thread src/statement/volume.rs Resolved
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.

Verdict: 1 Low

Looks good, with one low-severity error-classification issue: a GET whose destination is a directory reports an internal or permission error instead of an invalid-argument error. The path policy, retry behaviour for non-idempotent uploads, cancellation shared by every reader, and the temp-file-then-rename download handling look sound and have thorough tests.

Comment thread src/statement/volume.rs Resolved

@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: 2 Low

Looks solid overall, with two low-severity concerns: blocking filesystem syscalls run on the async runtime, and a failed volume HTTP client build is cached for the whole session. Cancellation sharing, path-policy resolution, Content-Length handling, keeping PUT from retrying, and the error-context mapping all look correct and well covered by tests. Nit: the ADBC option key adbc.databricks.statement.staging_allowed_local_paths is repeated as a string literal in set/get instead of a named constant like its sibling options.

Comment thread src/statement/volume.rs Resolved
Comment thread src/client/http.rs Resolved
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.

Verdict: 1 Low

The design looks solid, with one low-severity finding: a directory given as the GET destination is classified differently on Windows and Unix. I checked transfer cancellation (sync, direct, async owner, detached), the terminal one-shot result, the redirect and credential isolation on the storage client, the allowed-path policy (component-wise starts_with, missing parents only classify a denial and never authorize), the temp-file write then atomic replace, and the C ABI and ADBC option handling. I found no correctness problems in any of those.

Comment thread src/statement/volume.rs Resolved

@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: 2 Low

The PR looks solid, with two low-severity findings: path-resolution errors bypass the allow-list check, and blocking filesystem calls run on the async runtime. Cancellation, terminal completion and the atomic GET replacement are handled carefully, and wiremock, raw-socket and C ABI tests cover them well.

Comment thread src/statement/volume.rs Resolved
Comment thread src/statement/volume.rs Resolved
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.

Verdict: 1 Low · 1 Nit

Looks good overall, with two low-severity concerns: blocking filesystem calls on the async runtime, and a PyO3 setter that silently clears the stream token. Policy enforcement, cancellation sharing, storage retry and deadline behaviour, and cleanup of the GET temporary file are well structured and covered by tests at the right tiers.

Other findings

  • ⚪ Nit — set_staging_allowed_local_paths always overwrites staging_stream_token, so a call like stmt.set_staging_allowed_local_paths(["/tmp"]) without input_stream_token= silently clears a sentinel set by an earlier call. The kernel then treats the connector's stream sentinel as an ordinary local path: if a file with that name exists under an allowed root, PUT uploads it from disk instead of failing with FILE_TRANSFER_UNSUPPORTED_STREAM. If wrappers are expected to always pass both values, document that in the docstring. Otherwise, set the token only when it is passed (or expose a separate setter).

Comment thread src/statement/volume.rs Outdated
})?;
let builder = tempfile::Builder::new();
#[cfg(unix)]
let builder = {

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 — The GET path runs several synchronous filesystem calls inside an async fn on the shared Tokio runtime: std::fs::metadata(destination) (twice), builder.tempfile_in(parent), try_clone, set_permissions and temporary.persist(destination). allowed_path → canonicalize() also runs synchronously from transfer. On a slow or network filesystem (NFS, SMB, FUSE), these block a worker thread, which stalls other sessions' polling and CloudFetch on the same runtime. That matters most for the C ABI and napi consumers, which share one runtime. The rest of the function already uses tokio::fs. Wrapping the temp-file create/persist and path resolution in tokio::task::spawn_blocking (or using tokio::fs equivalents) would keep the runtime responsive.

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.

Tracked with the earlier filesystem finding in #442 and #445. Slow mounted-filesystem behavior is unmeasured; direct five-run comparisons pass but cannot establish mount responsiveness. Proposed work measures resolution, metadata, creation and replacement separately with concurrent-session control, then offloads read-only operations if warranted. Replacement must preserve cancellation semantics; simply detaching persist can overwrite after a cancellation result. The follow-up remains open.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Deferring this to #442/#445 is reasonable for a Low finding, and you're right that detaching persist into spawn_blocking would break cancellation: a dropped future could still overwrite the destination after the caller has seen a cancellation result. The code at this location is unchanged, though, so I'll leave the thread open until the follow-up lands. One suggestion for that work: canonicalize, both metadata calls and tempfile_in are side-effect-free or only touch the temp file, so they can move to spawn_blocking or tokio::fs without changing semantics. That leaves persist as the only step that needs a cancellation-aware design.

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.

Verdict: 1 Low

Looks good, with one low-severity finding about synchronous filesystem calls in the async GET path. I traced the path policy (including symlink, .. and missing-ancestor cases), terminal and cancellation state shared by readers, PUT Content-Length handling, redirect and credential stripping, and the C ABI, ADBC and PyO3 option surfaces. They all behave as the PR description says, and tests cover them.

Comment thread src/statement/volume.rs
|| !name.eq_ignore_ascii_case(reqwest::header::CONTENT_LENGTH.as_str())
{
request = request.header(name, value);
}

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 — The GET path makes several synchronous filesystem calls inside async fn transfer: std::fs::metadata(destination) (twice), tempfile::Builder::tempfile_in, try_clone, set_permissions and persist (a rename). allowed_path/resolved_path also call canonicalize synchronously for every root. All of these run on a Tokio worker thread. On a slow or network filesystem (NFS, SMB, FUSE-mounted volumes), they stall the executor thread that also drives SEA polling, CloudFetch and cancellation. The rest of the function already uses tokio::fs. Wrapping the temp-file creation, persist and canonicalization steps in tokio::task::spawn_blocking (or using the tokio::fs equivalents) would keep the runtime responsive. Each call is short on a local disk, so this is low severity.

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.

Acknowledged as an unmeasured mounted-filesystem limitation, with the concrete diagnostic and cancellation-safe proposal in #442 (linked by #445). The current direct five-run cohort has no >10% median regression, but that is not mounted-filesystem evidence. The follow-up first measures resolution, metadata, temporary creation and replacement under concurrent session load, then offloads read-only work as justified. Final persist needs a commit design that cannot overwrite after a cancellation result; a detached spawn_blocking rename would weaken that guarantee. No NFS/SMB/FUSE responsiveness claim or resolved status is asserted for this finding.

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 tracking this in #442. Your point about the final persist is fair: a detached spawn_blocking rename could still commit after a cancellation result has been returned, so that step needs its own commit design. The read-only steps (canonicalize in allowed_path/resolved_path and the metadata checks) don't carry that risk, so they could be offloaded now. The current code still runs these calls synchronously on the worker thread, so I'm leaving the thread open until the follow-up lands or someone decides to accept the limitation for this PR.

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.

Verdict: 1 Medium · 3 Nit

The transfer implementation looks solid: it streams data, checks local paths against the allow list, retries uploads only when that is safe, writes downloads to a temp file before replacing, and handles cancellation. I have one medium finding and three low ones. Two refusal paths return the generic error code instead of the permission code, a directory destination returns an unclear Internal error, and two tests have assertions that can't fail.

Other findings

  • ⚪ Nit — The guard is meant to reject destinations that aren't files, but !metadata.is_file() && !metadata.is_dir() lets directories through. A directory destination then fails when it is opened with .write(true). The caller gets ErrorCode::Internal with a raw EISDIR OS error instead of the intended InvalidArgument "Download destination must be a file". download_preserves_file_permissions_and_rejects_root currently pins the Internal result. If the OS error is meant to be kept for Python's IsADirectoryError, a comment saying so would help. Otherwise, use !metadata.is_file() here so the user gets the clear argument error.
  • ⚪ Nit — The check that a rejected value leaves the option unchanged can't fail. The loop ends by setting "null", so the option is already None when "{}" is rejected. The assertion that it is still None passes whether the failed set_option left the state alone or cleared it. Set a non-null value (e.g. ["/tmp/files"]) before the invalid input so the test catches a regression. The paths assertion in the C ABI test at src/c_abi/statement.rs:1329 has the same problem; its retain check does work.
  • ⚪ Nit — When headers arrive as a JSON string, they are parsed straight into HashMap<String, String>. A header value sent as a JSON number or boolean (e.g. {"x-ms-blob-size": 123}) makes the whole transfer fail with "Invalid file transfer headers". The Map-typed path can't hit this because Arrow forces string values. If the server's JSON form can carry non-string scalars, consider parsing into serde_json::Value and converting scalars to strings.

Comment thread src/statement/volume.rs Resolved
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.

Verdict: 2 Low

Looks solid overall: path policy, redirect and credential stripping, single-completion and cancellation semantics, and binding wiring are all well covered by tests. Two low-severity robustness notes: blocking filesystem calls inside the async transfer, and no fsync before the atomic rename.

Comment thread src/statement/volume.rs Outdated
let local = if operation == "REMOVE" {
None
} else {
Some(allowed_path(local_file, paths)?)

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 — Several synchronous filesystem calls run inside the async transfer future on the caller's Tokio worker:

  • allowed_path → canonicalize / std::path::absolute (here)
  • std::fs::metadata(destination) (L386 and again after the body is written)
  • tempfile::Builder::tempfile_in(parent)
  • temporary.persist(destination) (a rename)

On a local disk these finish in microseconds. On the slow or mounted filesystems the PR says are untested (NFS, SMB, FUSE), each one can stall the worker thread for a long time. That also stalls other tasks on that worker, including the cancellation select! arm that is supposed to interrupt the transfer. Consider wrapping path resolution and the tempfile create/persist steps in tokio::task::spawn_blocking, or switching to tokio::fs equivalents where they exist.

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.

Acknowledged. Slow or mounted filesystems remain unmeasured, and the scheduling/cancellation concern is retained in #442. This is not counted as resolved. The follow-up first measures resolution/metadata/temp-file costs and then moves blocking work as warranted, preserving cancellation semantics. In particular, detaching persist/rename can overwrite the destination after cancellation, so wrapping the entire sequence in spawn_blocking without that design would be unsafe. The current simplicity changes affect only tests and comments.

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 tracking this in #442. Your point about persist is right: moving the rename into a detached spawn_blocking could overwrite the destination after cancellation, so the fix needs a design that keeps cancellation working. Measuring first is a good plan. The GET pre-check at L347 now uses tokio::fs::metadata, but allowed_path (canonicalize/absolute), the tempfile create, and persist still run synchronously on the worker. No fix is in this PR, so I'm leaving the thread open as an outstanding item for #442 rather than marking it resolved.

Comment thread src/statement/volume.rs Resolved
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>
Consume a handle's observed successful response once when constructing its reader, and materialise terminal polls without another status request. Clear saved responses at fresh observations and owner release, including late replies, while retaining existing metadata and lifecycle behavior.

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.

Verdict: 1 Low · 1 Nit

Looks solid overall. Two low-severity issues: the download replacement isn't durable before the rename, and fetch_result has some redundant pending-slot clears. Path policy, retry/redirect handling, cancellation latching and FFI error getters all hold up against the code I checked. The PR description already flags the unresolved policy choices (404-on-REMOVE, symlink rejection).

Other findings

  • ⚪ Nit — In fetch_result, the None arm of take_pending_result() calls clear_pending_result() right after take has already left the slot empty. The call after statement_status returns repeats it, and the error path then clears a third time. If these exist to throw away a response that a concurrent status() published in the meantime, a short comment saying so would help. Otherwise the first call can go, so readers don't assume the slot can hold something here.

Comment thread src/statement/volume.rs
let message = format!("{message}: {}", transport_reason(&error));
Error::new(code, message.clone()).with_cause(Error::new(code, message))
}

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 — The GET commit renames the temp file over the destination (temporary.persist(destination)) without calling sync_all() on it first. tokio::fs::File::flush only waits for writes the runtime has queued. It does not make the data durable. On many filesystems (ext4 with delalloc, XFS), a crash or power loss right after the rename can leave the destination truncated or zero-length, and the original contents are already gone. That breaks the PR's promise that the destination is replaced only after the complete download. Calling temporary.as_file().sync_all() (mapped through file_error(Some("fsync"), ..)) before persist would make the atomic replace crash-safe. Optionally, fsync the parent directory after the rename on Unix as well.

This branch was previously deployed

1 inactive deployment
azure-prod — 69b2998e Deployed Nov 13, 2026 by oss-reviewer-bot[bot] via followup #2708
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