Repository navigation
fix: backport Blob V2 direct reads to 0.42 - #5308
Conversation
## What
Add a capability-gated client path for large Blob V2 reads over LanceDB
Enterprise:
- A successful `describe` advertises `x-lancedb-blob-locations: 1`; the
SDK then resolves pinned row locations through `POST
/v1/table/{id}/blob_locations/`.
- Whole reads (`fetch_blobs`) and seekable handles (`fetch_blob_files` /
`open_blob_file`) read presigned object-store URLs directly for eligible
values and ranges at or above a provisional internal 10 MiB threshold.
- Small ranges and `fetch_blob_ranges` stay on the existing proxy path,
including aggregate batches whose total exceeds the proxy byte limit.
- Shared `Packed` / `Managed` sidecars translate logical ranges to
physical offsets and validate the full numeric `Content-Range` tuple,
not just its start or total.
- Presigned traffic uses a separate HTTP client with no Enterprise
default headers, so service credentials never reach object storage.
- The first resolver response must carry a valid query-snapshot
identity. That identity is then required on every later partition and
preserved through object-URL refresh, proxy fallback and oversized
whole-value recovery. A resolver `503` falls back once to the proxy path
using any version and identity already pinned; other resolver errors
propagate. Object-store `503`s do not masquerade as resolver
unavailability.
- A read that starts without the capability reuses its supplied
`ReadSnapshot` if a later describe enables direct opening mid-operation.
- Version and query-snapshot pinning, NULL/order alignment and empty
values are preserved.
## Client network requirement
On Enterprise clusters that enable direct Blob reads, large values and
individual ranges may be fetched from short-lived object-store URLs
instead of the LanceDB proxy. Clients then need network access to the
object-store endpoint, including private endpoint routing, DNS, TLS
trust and egress rules, in addition to the LanceDB endpoint. Small reads
stay on the LanceDB proxy.
## Why
Large Blob V2 reads currently stream every payload byte through `Object
Store -> Plan Executor -> Query Node -> client`. That consumes internal
bandwidth, inflates PE/QN memory use and pollutes executor caches with
low-locality `.blob` data. This is the SDK half of ENT-4358; the server
implementation is in Sophon.
## Compatibility
No public SDK signatures change. Old clusters omit the capability header
and keep the existing proxy behaviour with zero extra round trips. The
10 MiB threshold is an internal prototype choice pending the paired
acceptance measurement; it is not a public knob.
## Validation
- `cargo check -p lancedb --quiet --features remote --tests` passes.
- `cargo test -p lancedb --quiet --features remote --lib
remote::table::blobs::tests` passes: 65 tests.
- New coverage includes direct whole reads, shared-sidecar physical
offsets and Content-Range rejection, small-range proxy routing, mixed
large/small range batches, resolver `503` fallback with pinned state, no
second resolver after fallback, object-store `503` not triggering proxy
fallback, missing/mismatched resolver identity rejection, resolver
identity preservation through refresh/proxy/oversized recovery,
supplied-snapshot reuse on mid-operation capability refresh, and
NULL/order/null-preserving paths.
A real-QN acceptance run with the candidate SDK binary is separate and
still pending deployment of the candidate server image.
(cherry picked from commit 60519d4)
Add `Table.openBlobFile` and `Table.openBlobFiles` for source-bearing SQL `blob_descriptor` results, matching the existing Rust and Python APIs. The TypeScript methods forward the descriptor to the shared Rust opener instead of reimplementing routing. That keeps the 10 MiB direct-read threshold, pinned snapshot identity, resolver refresh, and 503 single-shot proxy fallback identical to `fetchBlobFiles` and the other public Blob V2 entries. Descriptor fields remain the snake_case shape returned by Arrow/SQL; the wrapper converts unsigned 64-bit values to `bigint` at the NAPI boundary and returns `null` for null descriptors. Existing custom `Table` subclasses keep working through a default "not supported" implementation. Validation: - `pnpm tsc` - `pnpm lint` - `pnpm test --runInBand __test__/blob_open.test.ts __test__/blob_ranges.test.ts __test__/remote_blob_snapshot.test.ts` — 65 passed - focused Rust core tests for direct opens, threshold routing, snapshot preservation, and 503 fallback — passed The docs also update the TypeScript cross-row range table and example; `fetchBlobRanges` was already implemented but was still documented as unavailable. (cherry picked from commit 1c01180)
Presigned Blob V2 reads retry an idempotent ranged GET once after a recognized disconnect or timeout before the complete response headers arrive. This includes an abrupt TLS EOF while receiving the headers. A retry preserves the physical Range and the still-valid URL. Expiry triggers resolution on the pinned snapshot. Once the complete headers arrive, the existing status and body paths handle the response. Enterprise connections default to a 300-second pool idle timeout and presigned object-store connections default to 30 seconds. The existing override applies to both pools. Loopback TCP tests exercise FIN and RST on a reused connection, both with zero response bytes and after a partial header. They verify the send count with retries enabled and disabled, the exact replayed Range and the payload digest. A truncated body after complete headers returns an error after one send. Direct reads over 16 MiB stream bounded physical ranges into their corresponding slices of the final buffer. The per-read fan-out uses Lance's `LANCE_IO_THREADS`, capped by the connection's existing `LANCE_CLIENT_BLOB_REQUEST_CONCURRENCY` limit (8 by default). Each request retains its permit through body consumption. The 10 MiB routing threshold continues to apply to the full logical read. The connection can reuse unexpired presigned locations for verified rows under the same table, column, snapshot and request credentials. Range offsets and sizes come from the resolver. The existing batch request covers the requested rows of a shared Packed or Managed sidecar. Reopening a verified row uses its prior resolution, and the first open of each unseen SQL descriptor still authorizes just that row. The public API and REST response format are unchanged. (cherry picked from commit 129028f)
Enterprise SDKs use an inclusive 32 MiB default for eligible Blob V2 direct reads. The paired field comparison with the 10 MiB SDK default measured higher direct-read latency at 10 and 16 MiB. At 32 MiB, the interval for the latency difference spanned zero. [SDK version used in the field comparison](#5247) The earlier mixed-load test measured lower Plan Executor cache pressure with direct reads enabled at the 10 MiB cutoff. That result covers the tested size mix. With the 32 MiB cutoff, reads from 10 MiB up to (but excluding) 32 MiB go through the proxy, so the impact on executor traffic and cache pressure depends on the workload's size distribution. The existing internal override still takes precedence. Direct reads keep the 16 MiB part size. The Node binding test verifies proxy routing one byte below the default and two contiguous object-store ranges with a matching SHA-256 at exactly 32 MiB. (cherry picked from commit e185dc8)
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
The monotonic-read regression is fixed. Resolver responses now advance the latest handle's watermark while preserving pinned-descriptor and checkout-generation isolation. The Rust regression suite and the original TypeScript reproducer pass.
Real Enterprise/object-store throughput remains unverified here, including the 32 MiB crossover. A bounded rollout comparing latency, throughput, and errors with proxy reads would reduce that uncertainty.
Backport presigned Blob V2 reads for Python and TypeScript, including signed URL reuse, retries, parallel ranged GETs, and the inclusive 32 MiB threshold. Direct reads require the server to advertise support. The backport includes the snapshot identity check on credential refresh that the transport changes build on.
Refs #5210, #5216, #5238, #5247, #5248.