Repository navigation
fix(mem-wal): carry fragments through UpdateMemWalState - #8438
Merged
jackye1995 merged 1 commit intoAug 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The focused carry-forward restores the metadata-only transaction invariant at the manifest boundary and is preferable to changing Manifest::new_from_previous, where an empty fragment list can be intentional. The regression test covers both fragment and row visibility.
xuanyu-z
force-pushed
the
fix/memwal-state-preserves-fragments
branch
from
August 10, 2026 17:43
dee21d3 to
b61bb56
Compare
xuanyu-z
force-pushed
the
fix/memwal-state-preserves-fragments
branch
from
August 10, 2026 17:48
b61bb56 to
e791287
Compare
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The focused carry-forward restores the metadata-only transaction invariant at the manifest boundary and is preferable to changing Manifest::new_from_previous, where an empty fragment list can be intentional. The regression test covers both fragment and row visibility.
wkalt
approved these changes
Aug 11, 2026
UpdateMemWalState builds its manifest from scratch and never populated final_fragments, so the commit published an empty fragment list, dropping every row in the table. No conflict is raised: the operation touches indexes and is declared compatible with concurrent data commits.
xuanyu-z
force-pushed
the
fix/memwal-state-preserves-fragments
branch
from
August 11, 2026 04:36
e791287 to
7b44d7f
Compare
hamersaw
added a commit
to hamersaw/lance
that referenced
this pull request
Nov 25, 2026
The writer-version cutoff could not tell a genuinely emptied table from a pre-lance-format#8438 one: every commit restamps the writer version, so a metadata-only commit carried an untrusted empty fragment list past the check. Drop the empty-fragments guard instead. Within the RTE path the table is emptied by the compaction merge_insert itself, so its catch-up always reads an empty table and must be credited. The pre-lance-format#8438 state requires a standalone UpdateMemWalState from Lance <= 10.x, which no production table carries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Xuanwo
pushed a commit
that referenced
this pull request
Nov 25, 2026
…version proves (#10140) MemWAL index catch-up coverage is derived at commit time as "the index spans every fragment of the read version". An empty fragment list was refused outright, because a manifest written before #8438 (where `UpdateMemWalState` published no fragments) looks identical, and there the SSTables are the last copy of the rows. The cost of that refusal: a table emptied by deletes never credits any index. `trim_eligible_generation` on the WAL side then never sees catch-up for the maintained indexes, so the compacted SSTables are never trimmed, and the catch-up planner reschedules a no-op job every few seconds, indefinitely. `optimize_indices` returns early because `mem_wal_catch_up_would_advance` is false. A checkpoint waiting on the trim never returns. It un-wedges only when a later write adds a fragment. It reproduces deterministically: empty base, enable MemWAL, upsert some keys, delete them all, checkpoint. It also hits a table that started with rows once the compaction deletes the last one. This is reachable on the normal RTE path, not only through out-of-band deletes. The compaction `merge_insert` applies the WAL's delete tombstones and drops fully deleted fragments in the same commit that advances `compacted_sstables`. The catch-up for that generation therefore always reads an empty table, even with compaction and catch-up strictly serialized. The fix removes the empty-fragments guard, so an empty read version is trivially covered and credited. The state the guard protected requires a standalone `UpdateMemWalState` committed by Lance <= 10.x: the first in-repo caller (#8263) and the fix (#8438) both first shipped in v11.0.0. No production table was written that way. An earlier revision trusted empty manifests by writer version instead. That does not work: every commit restamps `writer_version`, so a metadata-only commit such as `UpdateConfig` carries an untrusted empty fragment list past the check. Tests: `an_emptied_table_is_credited` in `mem_wal_index_coverage` replaces the writer-version cases; `cargo test -p lance-table --lib mem_wal_index_coverage` (30 passed); `cargo clippy --all --tests --benches -- -D warnings` clean. The end-to-end repro (checkpoint returns, SSTables trim) was verified against the earlier revision, which credited the same case. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Daniel Rammer <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Operation::UpdateMemWalStatebuilds its manifest from scratch and never populatesfinal_fragments, so the commit publishes a manifest with no fragments. Every row in the table disappears.Nothing errors. The operation touches indexes rather than data, so it is declared compatible with concurrent
Append/CreateIndexand no conflict is raised — the commit succeeds and the data is gone.Compare
UpdateBases, the arm immediately below: also index/metadata-only, and it does carry the fragment list forward.Fix
Reachability
No caller in this repo commits a standalone
UpdateMemWalStatetoday. MemWAL compaction progress is recorded byMergeInsertBuilder::mark_sstables_as_compacted, which rides anOperation::Update— a data operation that populates fragments normally. So the bug is latent here, not active.It becomes reachable the moment anything commits the operation on its own, which the MemWAL index catch-up work (#8263) does.
Tests
test_update_mem_wal_state_preserves_fragments: commitUpdateMemWalStateon a dataset with rows, assert the fragment list and row count are unchanged. Verified it fails without the fix (left: [],right: [0]).The existing tests in
index/mem_wal.rsalready commit this operation against a dataset holding 10 rows — they pass because none of them read the rows afterwards, asserting only on conflict behavior andcompacted_sstables.cargo test -p lance --lib -- mem_wal transaction— 636 passed.