Skip to content

A pinned full read in scan_for_materialize_stream returns a commit prefix: the per-pass row budget cuts it #2160

Closed

Description

@bplatz

FlureeR2rmlProvider::scan_for_materialize_stream takes an optional to_snapshot_id. Its own comment says a pin is honoured: "A pinned read is a point-in-time consumer's and is read exactly as asked" (fluree-db-api/src/graph_source/r2rml.rs:2091). Only the incremental-window cap actually checks for a pin (if !pinned && incremental, :2092). The full-read branch applies the per-pass row budget (pass_row_budget(), :2072) whether or not the read is pinned:

  • with from_sequence set, sequence_prefix_cut (:2246) keeps only a prefix above the cursor;
  • otherwise full_read_prefix (:2279) cuts at a commit boundary once the plan exceeds the budget.

A pinned caller gets a prefix back in one of two shapes. Neither is the snapshot it asked for:

  • Checkpoint route (:2315). to_snapshot_id is replaced by an earlier retained snapshot, and to_sequence is None. A caller that checks to_sequence reads this as a complete pass.
  • Cursor route (:2333). to_snapshot_id is still the pin, and to_sequence = Some(cut).

A point-in-time consumer has no use for either. It asked for a snapshot, not a resumable pass.

Reported impact: a consumer that pins each table's snapshot at the start of a run and full-reads it at that pin was missing ~1.2% of rows at 5M source rows, and ~26% at a nominal 10M. The loss grows with table size because the budget is fixed: it is derived from reindex_max_bytes / 4 / FLUREE_MATERIALIZE_FLAKE_BYTES_PER_ROW, and the table is not.

Neither built-in path is affected. The tracking materializer always passes to = None (r2rml_materialize.rs:283), and fluree materialize reads through scan_table. The code is identical on next.

Line numbers are on main at aa9aa7acd.

Fix

Disable the budget for a pinned read, as the incremental cap already does:

let budget_rows = if pinned { 0 } else { self.pass_row_budget() };

A budget of 0 makes full_read_prefix return Disabled and sequence_prefix_cut return Complete. A from_sequence cursor still filters, but nothing is cut. Every pinned read then returns to_snapshot_id == pin and to_sequence == None. State that contract on MaterializeScan as well.

Test

fluree-db-api/tests/it_iceberg_local_fs.rs already has what is needed:

  • the 3,000-row, five-commit backlog fixture (backlog_table_location());
  • a builder whose ceiling puts the budget between 601 and 1,200 rows (an_expired_history_table_drains_in_bounded_passes).

On that setup, a full read pinned at the head must yield 3,000 rows, with to_snapshot_id == head and to_sequence == None. Today it yields 1,200. Revert the fix to confirm the test fails without it.

Activity

  1. added
    bug
    P1
    area:iceberg
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:icebergbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions