Repository navigation
Conversation
…p rules Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t is empty (#10107) Closes #10097. When every segment of an index has empty live coverage, `retain_relevant_indices` keeps a single segment as the index definition. It picked the lowest `dataset_version`, but that's a watermark rather than a creation time (merges take the minimum of their sources, remaps raise it), so it could keep a newer segment and lose the earliest `created_at`. This sorts the all-empty segments by `created_at` instead, as #10097 / #10090 describe: segments without a `created_at` go after those with one, and ties fall back to the lowest `dataset_version`. Segments that all lack `created_at` behave exactly as before. Testing: added `test_retain_multiple_empty_indices_keeps_earliest_created` (fails on main, passes here). `cargo test -p lance-table --lib` passes, and `cargo fmt` / `cargo clippy -p lance-table --tests` show nothing new. I used an AI coding assistant to help write this change and the test; I reviewed the diff and ran the tests above.
…lay compaction (#10109) Closes #10091. On a table without stable row ids, a compaction with `defer_index_remap: true` that folds a data overlay on an indexed field left the index covering the compacted rows with their pre-overlay values. `prune_overlay_stale_fields_from_indices` only removed the group's new fragment ids from a stale index's bitmap, but on the deferred path the bitmap still holds the old ids (the fragment reuse index translates them at load time), so nothing was removed and `val = <old value>` kept matching. This removes both the old and the new fragment ids of the group from stale indices, which is the second option the issue gives (per #10090). On the eager path the old ids are already gone, so that path behaves as before. Tagged FRI tables still refuse this compaction, so they aren't affected. Testing: `test_overlay_compaction_reconciles_stale_index` now runs with both eager and deferred remap; the deferred case fails on main (the index still covers the compacted fragment) and passes here. `test_prune_overlay_stale_fields_from_indices` gained a stale index that still covers the old fragment id. `cargo test -p lance-table --lib` passes, as do the `overlay`, `dataset::optimize` and `dataset::index::frag_reuse` tests in `lance`. `cargo fmt --all` is clean and `cargo clippy -p lance -p lance-table --lib --tests -- -D warnings` passes; I didn't run the full-workspace clippy. This touches the same function as #10108 (which changes how stale fields are matched, not which fragment ids are removed), so whichever lands second needs a small rebase. I used an AI coding assistant to help write this change and the tests; I reviewed the diff and ran the checks above. Co-authored-by: ump45nose <[email protected]>
Closes #10092. Three index maintenance paths decided whether an index depends on a field by exact field id: the overlay check in `remap_index` / `remap_index_tagged`, `prune_overlay_stale_fields_from_indices`, and the untagged branch of `withdraw_in_place_rewrites`. A change reported against a struct `s` then left coverage on an index over `s.x` (and a change to `s.y` left an index over `s` alone), so the index could keep serving the old values. These paths now use `field_affects_index`, the same subtree rule `fresh_fragments` and the overlay staleness checks already use: - the remap overlay checks call `overlay_affects_index`; - `prune_overlay_stale_fields_from_indices` takes the schema and matches overlaid fields by subtree; - the untagged branch of `withdraw_in_place_rewrites` drops the rewritten fragment from every index that depends on a rewritten field. The tagged branch is unchanged. `IndexMetadata.fields` already holds the covering fields, so this matches the `fields ∪ covering_fields` subtree rule from #10090. Like the issue says, I haven't confirmed that a current writer reports only the parent id; this just makes the three paths agree with the rest. Testing: added `test_prune_overlay_stale_fields_matches_nested_fields` and `test_untagged_in_place_rewrite_withdraws_nested_fields` (parent change vs. child index, child change vs. parent index, unrelated field). `cargo test -p lance-table --lib` passes, as do the `dataset::optimize::remapping` (49) and `overlay` (206) tests in `lance`. `cargo fmt --all` is clean, `cargo clippy -p lance --lib -- -D warnings` is clean, and `cargo clippy -p lance-table --tests` shows nothing in the touched code (with `-D warnings` it stops on existing dead-code warnings in `lance-io`'s throttle module). I didn't run the full-workspace clippy. I used an AI coding assistant to help write this change and the tests; I reviewed the diff and ran the checks above. --------- Co-authored-by: ump45nose <[email protected]>
| fragment as of this dataset version. For indices whose results are row addresses, that includes | ||
| row addresses. A consequence is that the bitmap does not determine which address space the index |
There was a problem hiding this comment.
issue: I find this sentence confusing:
For indices whose results are row addresses, that includes row addresses.
Could you describe more concretely what this means? Does it just mean the row_addresses recorded in the index are what the rows addresses were at that dataset version, and if they've been moved they need to be remapped by the FRI?
There was a problem hiding this comment.
Yes, that's what it meant. Reworded: the stored row addresses are the ones the rows had at dataset_version, and if a later compaction moved them they must be remapped through the FRI entries that record it.
| fragment as of this dataset version. For indices whose results are row addresses, that includes | ||
| row addresses. A consequence is that the bitmap does not determine which address space the index |
There was a problem hiding this comment.
issue: this is also confusing.
consequence is that the bitmap does not determine which address space the index
data is in;dataset_versiondoes...
What does "address space" mean here? I would have guessed it's _rowid vs _rowaddr, but that's not determined by dataset_version, so I think you mean something else.
There was a problem hiding this comment.
I meant whether the stored addresses are pre- or post-compaction, not _rowid vs _rowaddr. Dropped the term; it now says the bitmap can't tell a reader whether the stored row addresses still need FRI remapping, and only dataset_version can.
| - the `dataset_version` of each FRI version entry added after B whose old or new fragments | ||
| intersect the segment's `fragment_bitmap`. | ||
|
|
||
| If there are none, W is the current dataset version. A segment's `dataset_version` must never |
There was a problem hiding this comment.
question: "If there are none" what? FRI? Overlays? Either? Could you be more specific here?
There was a problem hiding this comment.
Now reads "If no such merge-on-read update or FRI version entry exists".
| entries the segment still needs. Any value at or below B is valid. A lower value may cause more | ||
| rows to be treated as stale, but never yields wrong results. |
There was a problem hiding this comment.
suggestion: is there a mermaid diagram we could put here that would illustrate the concept?
There was a problem hiding this comment.
Added a mermaid version timeline with a worked example (B=3, overlay at v5, compaction at v7 with FRI stamp 6, so W=4), marking valid and invalid stamps.
| - **Keep a conservative version.** Use a value no greater than the B of every source segment the | ||
| new segment's data came from. |
There was a problem hiding this comment.
suggestion: no one who skipped to this section will no what B is here. Redefine it.
Also, is this a min of all source segments? Or max? Maybe give an example.
There was a problem hiding this comment.
Redefined B and R at the top of the section. It's the min: a conservative stamp must be at or below the smallest B among the sources. Added an example: merging segments built from v5 and v9 may keep any value up to 5.
| - Each overlay on an indexed field is either folded into the index data or its fragment is | ||
| removed from the `fragment_bitmap`. Folding must be idempotent: applying an overlay the | ||
| index already reflects must leave the index unchanged. | ||
| - Each FRI version entry is applied to the index data. |
There was a problem hiding this comment.
thought: I wonder if we can come up with a term for fragment data updates that captures the overlays and similar merge-on-read changes.
There was a problem hiding this comment.
Adopted "merge-on-read update", defined in the coverage section with data overlays as the current kind, and used it throughout the write and compaction rules and the proto comment.
| when it was built separately and committed later. The manifest at that `dataset_version` need not | ||
| be an ancestor of the version the commit is built on, for example after a restore. Before |
There was a problem hiding this comment.
question: This is strange fact, and I almost want to leave it out and unintended. There a reason to keep this?
The manifest at that
dataset_versionneed not be an ancestor of the version the commit is built on, for example after a restore.
There was a problem hiding this comment.
No strong reason, since the diff rule that follows already covers a restore. Removed the sentence and kept the rule.
Define merge-on-read updates, explain row-address remapping without the "address space" term, add a version timeline example, redefine B in the write rules, and drop the restore ancestry note. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The index spec never defined
IndexMetadata.dataset_version, andfragment_bitmapwas described only as "fragments covered". Different code paths treat them inconsistently: as build version or remap watermark, and as old or new fragment ids under a fragment reuse index (FRI). This PR writes down the contract:dataset_versionis a watermark. Overlays committed after it, and FRI entries stamped at or after it, are not reflected in the segment's data. It must never exceed W, the version just before the first such change to a covered fragment. Any value at or below the version the data was read from is valid.fragment_bitmapmay hold old or new fragment ids under an FRI. Released writers already persist FRI-mapped bitmaps on every commit.dataset_version, not the bitmap, decides the address space of the index data.table.protocomment updates forIndexMetadata.dataset_version,fragment_bitmap, and the FRIVersion.dataset_versionstamp. No wire changes.This describes the intended contract. Known places where the code diverges: #9861, #10091, #10092, #10093, #10094, #10095, #10096, #10097, #10098.
Merge Risk
Door: two-way. Documentation and proto comments only; no wire or behavior change.
Blast Radius: format spec (requires a PMC vote).
🤖 Generated with Claude Code