Repository navigation
feat(frag-reuse): add LANCE_FRAG_REUSE_REMAP_MODE=assert(<mode>) - #47
Merged
Merged
Conversation
A deployment that has committed to the compact reuse-remap form still has no way to tell whether some code path quietly falls back to the direct one -- it finds out as the memory blowup the compact form exists to avoid, long after the call that chose it. `LANCE_FRAG_REUSE_REMAP_MODE=assert(compact)` selects the compact form as the process default and turns every other form into a panic, so the offending call site shows up as a backtrace instead. The assert is a plain `assert!`, not `debug_assert!`, because the deployments that need it run release builds. Three sites cover the ways a form is chosen: `Dataset::checkout_manifest` (every dataset open, whichever path built the mode), `open_frag_reuse_index_with_mode` (callers that pass a mode not coming from a `Dataset`), and `commit_compaction` (`CompactionOptions::index_remap_mode`). The compaction one is gated on `needs_remapping`, since a stable-row-id or deferred compaction never consults the mode and asserting there would report configuration that costs nothing. Arming it warns once, on the read that fixes the setting for the process, so an operator can tell a later panic apart from an unrelated crash. The plain `direct`/`compact` spellings are unchanged, and an unparseable `assert(...)` falls back to the existing warn-and-use-direct behaviour rather than failing an open. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
amunra
force-pushed
the
adam/assert_compact_fri
branch
from
August 24, 2026 09:51
876a5d8 to
f1a8116
Compare
zehiko
approved these changes
Aug 24, 2026
This was referenced Aug 28, 2026
amunra
added a commit
that referenced
this pull request
Sep 10, 2026
A deployment that has committed to the compact reuse-remap form still has no way to tell whether some code path quietly falls back to the direct one -- it finds out as the memory blowup the compact form exists to avoid, long after the call that chose it. `LANCE_FRAG_REUSE_REMAP_MODE=assert(compact)` selects the compact form as the process default and turns every other form into a panic, so the offending call site shows up as a backtrace instead. The assert is a plain `assert!`, not `debug_assert!`, because the deployments that need it run release builds. Three sites cover the ways a form is chosen: `Dataset::checkout_manifest` (every dataset open, whichever path built the mode), `open_frag_reuse_index_with_mode` (callers that pass a mode not coming from a `Dataset`), and `commit_compaction` (`CompactionOptions::index_remap_mode`). The compaction one is gated on `needs_remapping`, since a stable-row-id or deferred compaction never consults the mode and asserting there would report configuration that costs nothing. Arming it warns once, on the read that fixes the setting for the process, so an operator can tell a later panic apart from an unrelated crash. The plain `direct`/`compact` spellings are unchanged, and an unparsable `assert(...)` falls back to the existing warn-and-use-direct behaviour rather than failing an open. The production change applies unchanged: release-10.0.0 already carries `parse_frag_reuse_remap_mode` and `default_frag_reuse_remap_mode` from #59. The one conflict was the `#[case]` list of `test_parse_frag_reuse_remap_mode`, resolved to the source's cases and its `expected_asserted` column while keeping this branch's `unparsable` spelling, which is what the typos hook and the rest of the tree use. Co-authored-by: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 49d9a40)
amunra
added a commit
that referenced
this pull request
Sep 10, 2026
#79) A deployment that has committed to the compact reuse-remap form still has no way to tell whether some code path quietly falls back to the direct one -- it finds out as the memory blowup the compact form exists to avoid, long after the call that chose it. `LANCE_FRAG_REUSE_REMAP_MODE=assert(compact)` selects the compact form as the process default and turns every other form into a panic, so the offending call site shows up as a backtrace instead. The assert is a plain `assert!`, not `debug_assert!`, because the deployments that need it run release builds. Three sites cover the ways a form is chosen: `Dataset::checkout_manifest` (every dataset open, whichever path built the mode), `open_frag_reuse_index_with_mode` (callers that pass a mode not coming from a `Dataset`), and `commit_compaction` (`CompactionOptions::index_remap_mode`). The compaction one is gated on `needs_remapping`, since a stable-row-id or deferred compaction never consults the mode and asserting there would report configuration that costs nothing. Arming it warns once, on the read that fixes the setting for the process, so an operator can tell a later panic apart from an unrelated crash. The plain `direct`/`compact` spellings are unchanged, and an unparsable `assert(...)` falls back to the existing warn-and-use-direct behaviour rather than failing an open. The production change applies unchanged: release-10.0.0 already carries `parse_frag_reuse_remap_mode` and `default_frag_reuse_remap_mode` from #59. The one conflict was the `#[case]` list of `test_parse_frag_reuse_remap_mode`, resolved to the source's cases and its `expected_asserted` column while keeping this branch's `unparsable` spelling, which is what the typos hook and the rest of the tree use. (cherry picked from commit 49d9a40) Co-authored-by: Claude Opus 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.
Why
A deployment that has committed to the compact reuse-remap form still has no way to tell whether some code path quietly falls back to the direct one. It finds out as the memory blowup the compact form exists to avoid, long after the call that chose it.
What
LANCE_FRAG_REUSE_REMAP_MODEgains anassert(<mode>)spelling:This selects the compact form as the process default and turns every other form into a panic, so the offending call site shows up as a backtrace:
It is a plain
assert!, notdebug_assert!, because the deployments that need it run release builds.Three assert sites cover the ways a form gets chosen:
Dataset::checkout_manifestopen_frag_reuse_index_with_modeDatasetcommit_compactionCompactionOptions::index_remap_mode, gated onneeds_remappingThe compaction assert is gated on
needs_remappingon purpose: a stable-row-id or deferred compaction never consultsindex_remap_mode, so asserting there would report configuration that costs nothing and would drown the real hits.Arming it emits one
warn!on the read that fixes the setting for the process, so an operator can tell a later panic apart from an unrelated crash:Everything else is unchanged: the plain
direct/compactspellings behave exactly as before, and an unparseableassert(...)falls back to the existing warn-and-use-direct path rather than failing an open. With the env var unset there is no behavioural change at all.Also adds
IndexRemapMode::as_str(), the inverse of the existingTryFrom<&str>, so both messages name a form in the same lowercase spelling the env var uses.It already found something
Running
cargo test -p lance --lib optimize::testsunderassert(compact)gives 64 passed / 39 failed. Seven of the 39 are cases that deliberately exercise the direct form (test_catch_up_rewrites_the_index_under_either_form::case_1_direct, thecase_2arms of the btree/ivf_pq/inverted remap families,test_frag_reuse_remap_mode_end_to_end::case_1_direct, both arms oftest_shared_session_serves_both_forms) — those are the assert working as designed, not findings.The other 32 are the forgotten path. They call
compact_fileswithCompactionOptions { ..Default::default() }on non-stable-row-id datasets, never mention a remap form, and — becauseCompactionOptions::default().index_remap_modeisDirectand is not wired toLANCE_FRAG_REUSE_REMAP_MODE— build the per-rowHashMap<u64, Option<u64>>remap anyway. That is the writer-side instance of exactly the growth the compact form exists to avoid. Examples:Wiring
CompactionOptionsto the env var is a behaviour change beyond the scope of this PR, so it is left for a follow-up.Testing
parse_frag_reuse_remap_modegains 6 cases for the new grammar (assert(compact),assert(direct),ASSERT(COMPACT), padded, unparseable inner mode, unterminated) alongside the 7 existing ones — 13 pass.frag_reuseand 103optimize::testspass, i.e. no change to existing behaviour.assert(compact)set:test_both_modes_agree_on_a_real_payload::case_1_compactpasses andcase_2_directpanics, confirming the assert fires only on the other form;test_catch_up_rewrites_the_index_under_either_form::case_2_compactpasses, confirming theneeds_remappinggate keeps inert configuration quiet.warn!was verified with a throwaway capturing subscriber (emitted exactly once across twoReadParams::default()calls); that scratch test was deleted.cargo fmt --allandcargo clippy -p lance --tests -- -D warningsare clean.🤖 Generated with Claude Code