Repository navigation
fix(iceberg): read pinned materialize scans whole; pin Delta tables the same way - #2165
Conversation
…t prefix scan_for_materialize_stream applied the per-pass row budget to every full read, pinned or not. A pinned read of a table larger than the budget came back as a commit prefix: with history retained it reported an earlier snapshot as its `to` and no sequence, indistinguishable from a whole read; with history expired it reported the pin and a sequence cursor. The budget paces the tracking worker's unpinned passes. A pinned read now runs with it disabled on every path, so it returns the pinned snapshot whole, reports the pin, and never carries a sequence.
…zation current_snapshot_id and scan_for_materialize_stream refused Delta sources, so a consumer that pins every table at the start of a run and reads each at its pin could do that for Iceberg only. A Delta source now answers both: the latest version is the pin, and a scan reads the version it is given (or the latest) whole, with no sequence. There is no incremental Delta read yet, so a window start is ignored; a full read is correct for any window. Each read resolves its own version rather than going through the per-query memo the query path keeps, which would answer every later pin with the first version resolved. Materialization and tracking still refuse Delta: without incremental reads every poll would be a full read that cannot be cut at a commit boundary.
aaj3f
left a comment
There was a problem hiding this comment.
@bplatz this is a clean fix at the right altitude. Turning the budget off for a pin, rather than adding a pinned-only path, makes both cut shapes unreachable with one line, and MaterializeScan now says so.
The one headline note is that this is another instance of a class we keep running into: a rule one path honors and a sibling path re-derives without it (#2022, #2042, #2126, #2133). Here the incremental cap already exempted pins and the two full-read cuts didn't. The point fix is right for this, and the two exemptions now agree. #2166 derives the same rule a third time at the Delta dispatch, which I've noted over there.
Claude-assisted review below:
✅ Approve with nits.
The fix holds up on both shapes the issue describes. With budget_rows = 0, full_read_prefix returns Disabled (r2rml.rs:627-629) and sequence_prefix_cut returns Complete (r2rml.rs:748), so a pin can no longer report an earlier checkpoint as its to, and can no longer carry a to_sequence. The incremental cap was already skipped for a pin. Unpinned passes still take pass_row_budget(), and the tracking worker never pins (scan_window passes to = None), so the worker's pacing doesn't move. The Delta half is small, and bypassing the per-query memo is the right call: one provider reading several versions of one table would otherwise get the first version back every time, and the new test walks exactly that.
One small doc note inline: a pinned read is never cut, but it's only the whole snapshot when there's no window start.
Worth saying for whoever next bumps a pin downstream: an embedded consumer that pins every table and full-reads it now gets the whole snapshot (that's the fix), so its wall-clock grows with the table instead of stopping at the budget. The read is still a stream, so memory stays flat; a host with a hard execution ceiling just sees the true cost now.
Adherence to repo commitments:
- Patterns/abstractions: ✔ reuses the disabled-budget value (
0) that both full-read cuts already honor, instead of a new pinned branch; the Delta dispatch is the sameif let Some(…) = self.delta_source(…)early return the query paths already use for SQL and Delta. - Performance (speed first, memory second): ✔ no hot-path change, one branch at scan setup. Pinned reads now read more rows by design (they were silently short). No performance-degradation risk.
- Deployment targets: ✔ the change is in
fluree-db-api, so it reaches every embedding host; the result stays a stream, so no memory fence is newly at risk. The only host-visible effect is the one above: a pinned whole read under a 15-minute ceiling now costs what the table costs. - Testing: ✔
a_pinned_full_read_is_never_cut_by_the_row_budgetcrosses the checkpoint route, the cursor route and a pinned read resuming from a cursor;a_delta_table_is_pinned_and_read_wholereads four versions through one provider. Both are[[test]]targets withrequired-features, and thetestjob ran them green at6914f7f9f. - Conventions: ✔ multi-line commit bodies;
iceberg.md,delta.mdandconfiguration.mdupdated; and thank you for moving the two stranded doc comments back ontoconfig_fingerprintandmapping_source_of.
Verified locally at 6914f7f9f: both new tests pass by name. Reverting the pinned-budget line turned a_pinned_full_read_is_never_cut_by_the_row_budget red (an earlier checkpoint reported as the to), and making the Delta read ignore its version turned a_delta_table_is_pinned_and_read_whole red (pin Some(0): got Some(2)); both restored.
Approving so you can merge when ready. The doc nit is a two-line fold-in if you agree with it.
| // A pinned read is read whole, on every path. `0` is the disabled budget: | ||
| // neither full-read cut below takes a prefix under it, and the | ||
| // incremental cap is skipped for a pin outright. | ||
| let budget_rows = if pinned { 0 } else { self.pass_row_budget() }; |
There was a problem hiding this comment.
👍 One line, and it closes both cut routes. Under 0, full_read_prefix returns Disabled and sequence_prefix_cut returns Complete, so a pin can't come back as an earlier checkpoint or with a to_sequence.
I reverted this line to self.pass_row_budget() and a_pinned_full_read_is_never_cut_by_the_row_budget went red on the first fixture with exactly the #2160 shape: the pinned read reported an earlier checkpoint snapshot as its to instead of the pin. Restored, it passes.
| - **A pinned read is never cut.** Both bounds pace the tracking worker, which | ||
| reads to the head. A read pinned to a snapshot — in Rust, | ||
| `FlureeR2rmlProvider::scan_for_materialize_stream` with an explicit `to`, after | ||
| `current_snapshot_id` — returns that snapshot whole and reports the pin as its |
There was a problem hiding this comment.
🟡 Optional / nit: a pinned read is never cut, but it's only "that snapshot whole" when there's no window start.
With a from_snapshot_id and an incremental-safe window, a pinned read is the added-files window (from, to]; with a from_sequence it's every commit above the cursor (your new test reads 1,800 of the 3,000 rows that way). A consumer that passes both ends could read "returns that snapshot whole" as a promise of a full read.
Maybe something like: "A read pinned to a snapshot is never cut by either bound: a pinned full read returns that snapshot whole, and a pinned window returns the whole window." The same sentence is in the FLUREE_MATERIALIZE_MAX_ROWS_PER_PASS row of configuration.md. Minor and non-blocking, but if you agree it's right, I'd rather see it folded in now than lost in the backlog.
…shot A read pinned to a snapshot is never cut by the row budget, but it is that snapshot whole only when no window start is given. With a from snapshot or a cursor it is the whole window up to the pin. The guide, the configuration row and the budget comment now say so.
Brings #2142, #2144, #2154, #2155, #2156, #2158, #2159, #2165, #2166 and #2167 into next. Where main's RDF lists (#2159) meet next's RDF 1.2 links: - The list view walks an EdgeAnnotation's body; next has no AnnotationTarget. - Export marks annotated edges skipping list rows, and writes an rdf:reifies row as next's @reifies block through main's JsonLdNode, untranslated rows included. - The JSON-LD and import readers keep next's graph argument and triple-term spool records beside main's gap-free list positions and list chunking. - One collection writer: main's shared module, which both JSON-LD and Turtle use, replaces next's Turtle-only one, and now also keeps the labels of blank nodes inside triple terms, of reifiers, and of blank graph names. A reified cell keeps its triples while the well-formed tail after it folds, as JSON-LD's list conversion does; next's writer test now says so. - Hiding list members also turns off next's wildcard lane, which reads leaflets directly, and next's independent-scan count builds its right scan with the same hiding. Elsewhere: - List-predicate discovery opens a leaf ranged unless the store cannot read ranges, which next fetches whole. - GC reports main's walk stop reason without next's removed artifact cache directory. - Tests from main await next's async genesis_ledger, reload with without_storage_lock, and build stores without a cache directory.
Iceberg: pinned reads are read whole
Fixes #2160.
FlureeR2rmlProvider::scan_for_materialize_streamtakes an optionaltosnapshot. When it falls back to a full read, the per-pass row budget cut that read to a commit prefix even whentowas a pin. The budget paces the tracking worker's unpinned passes. It should never apply to a pin, and the incremental cap already exempted pins.A cut pinned read reached callers in one of two shapes:
to_snapshot_id, withto_sequence: None. The caller could not tell it from a whole read.to_snapshot_idwas the pin, andto_sequencewas set.A pinned read now runs with the budget disabled on every path. It always returns
to_snapshot_id == pinandto_sequence == None. Neither the tracking worker norfluree materializepins, so neither changes.Delta: a table can be pinned and read whole
Partially addresses #2161.
current_snapshot_idreturns a Delta table's latest version.scan_for_materialize_streamreads the version it is given, or the latest, and reads it whole:incrementalisfalseandto_sequenceisNone;from_snapshot_idandfrom_sequenceare ignored, because a full read is correct for any window.Still open on #2161: materialization and tracking of Delta sources.
materialize_r2rml_graph_source, the tracking worker andfluree materializestill refuse Delta. Without incremental reads, every poll would be a full read. A Delta full read also can't be cut at a commit boundary, because the file listing doesn't record which version added each file. That is the never-committing loop the Iceberg budget exists to break, so it waits on incremental reads.Follow-up: #2162.
Tests
it_iceberg_local_fs::a_pinned_full_read_is_never_cut_by_the_row_budget. The budget is sized to cut a 3,000-row table inside its second commit. The test covers:people_window, which takes the checkpoint route;people_backlog, which takes the cursor route;it_delta_local_fs::a_delta_table_is_pinned_and_read_whole. The test covers:SnapshotNotFound.Also
Three doc comments had piled up above
require_iceberg_backed. Two of them belonged toconfig_fingerprintandmapping_source_of, and are back on those functions.