Skip to content

fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default - #11433

Merged
Xuanwo merged 4 commits into
mainfrom
xuanwo/zonemap-seed-compatibility
Nov 24, 2026
Merged

Xuanwo merged 4 commits into
mainfrom
xuanwo/zonemap-seed-compatibility

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 24, 2026

Copy link
Copy Markdown
Member

Summary

Fixes a cross-version compatibility break introduced by #10102 before releasing Lance v15.0.0.

Problem

Since Lance v10 (#7427), ZoneMap indices on string, binary, decimal, fixed-size binary (>8 bytes), and nested columns default to use_seeds = true. In #10102, any commit on a dataset carrying a use_seeds = true ZoneMap index automatically set FLAG_ZONE_WRITE_SEEDS (1 << 16) in both reader_feature_flags and writer_feature_flags.

Because v14.0.0 reserves bit 16 as unsupported and v15.0.0 is the first stable release able to read it, automatic activation breaks rolling upgrades: a single v15 writer performing any normal commit (Append, Update, Delete, DataReplacement, Compact, etc.) permanently (sticky bit) locks out all Lance < 15 readers with no rollout window. This also diverged from the zone write seeds format spec (#9564, docs/src/format/index/scalar/zone_write_seeds.md, "Activation is explicit, not triggered by opening a table") and from every other v15 reader feature flag (FLAG_MANAGED_BLOBS, FLAG_SPILLED_ROW_LINEAGE, FLAG_INLINE_DELETIONS), all of which require explicit opt-in.

Changes

  • Remove automatic activation: Remove apply_seed_feature_flags from the commit path (rust/lance/src/io/commit.rs, rust/lance/src/dataset/write/seeds.rs). Normal commits and CreateIndex no longer set FLAG_ZONE_WRITE_SEEDS.
  • Add explicit opt-in config: Add dataset config key lance.zone_write_seeds.version (valid values "0" and "1") validated when modified on both legacy (UpdateConfig, Overwrite) and composite transaction paths (rust/lance-table/src/feature_flags.rs, rust/lance-table/src/transaction/).
    • Absent or "0": FLAG_ZONE_WRITE_SEEDS stays unset; writers emit v0 seeds.
    • "1": Atomically sets FLAG_ZONE_WRITE_SEEDS in both reader_feature_flags and writer_feature_flags. Once set, the flag remains sticky across subsequent commits, index drops, restores, and clones; setting "0" pins future writes back to v0 while keeping the flag sticky.
    • Designed to live in the same lance.zone_write_seeds.* namespace as feat: collect zone map write seeds for unindexed columns from dataset config #11373.
  • Keep v0 write seeds by default: Add ZoneMapSeedVersion::{V0, V1} to ZoneMapSeedWriter (rust/lance-index/src/scalar/zonemap.rs). Tables that have not activated FLAG_ZONE_WRITE_SEEDS (or are pinned to "0") emit v0 seeds (no version metadata, no negative_nan_count, max = +NaN when nan_count > 0, required_feature_flags() == 0). This preserves Lance < 15 read/write compatibility without regressing optimize_indices performance (since feat(index): reuse zone map write seeds across zone sizes and make the null bitmap optional #10165 already reuses v0 seeds with nan_count == 0, covering all non-float and NaN-free float zones).
  • Binary-copy compaction: Carry v1 seeds when write_v1_zone_write_seeds is true; otherwise drop v0 seeds cleanly without activating FLAG_ZONE_WRITE_SEEDS (rust/lance/src/dataset/optimize/binary_copy.rs).
  • Tests:
    • Updated and expanded unit/integration tests across lance-table, lance-index, and lance covering v0 default writes, explicit v1 opt-in, sticky flag behavior, config validation, binary-copy compaction, and external scalar plugins.
    • Extended ZonemapBloomfilterIndex in python/python/tests/compat/test_scalar_indices.py with a string column (which defaults to use_seeds=True on Lance >= 10) so the compat matrix catches write-seed regressions going forward.

Verification

  • cargo test --profile ci -p lance-table --lib --doc
  • cargo test --profile ci -p lance-index --lib zonemap
  • cargo test --profile ci -p lance --lib -- seed / binary_copy / zone_map
  • cargo test --profile ci -p lance --test external_scalar_plugin
  • cargo fmt --all -- --check & cargo clippy --profile ci --all --tests --benches -- -D warnings
  • cd python && uv run make lint (ruff, pyright, cargo fmt, cargo clippy)
  • Smoke-tested ZonemapBloomfilterIndex locally against the built pylance wheel

…v0 writes by default

Previously, any commit on a table carrying a ZoneMap index with use_seeds=true automatically activated FLAG_ZONE_WRITE_SEEDS (1 << 16) in both reader_feature_flags and writer_feature_flags. Because string, binary, decimal, and nested ZoneMap indices default to use_seeds=true since Lance v10, upgrading a single writer to v15 immediately locked out all Lance < 15 readers without a rolling-upgrade window.

This change:
- Removes automatic FLAG_ZONE_WRITE_SEEDS activation during manifest commits.
- Adds dataset config key `lance.zone_write_seeds.version` ("0" or "1") to explicitly opt a table into v1 zone write seeds and atomically set the sticky FLAG_ZONE_WRITE_SEEDS bits across legacy and composite transaction paths.
- Keeps ZoneMapSeedWriter emitting v0 seeds by default when FLAG_ZONE_WRITE_SEEDS is not active (or when explicitly pinned to "0"), avoiding optimize_indices regressions while preserving full Lance < 15 compatibility.
- Drops v0 seeds cleanly during binary-copy compaction without setting FLAG_ZONE_WRITE_SEEDS, and carries v1 seeds when v1 is active.
- Extends ZonemapBloomfilterIndex compat test with a string column (use_seeds=true by default) alongside Rust unit/integration coverage.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added A-python Python bindings A-index Vector index, linalg, tokenizer bug Something isn't working labels Nov 24, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

Explicit opt-in restores the rolling-upgrade window while preserving default v0 seed reuse. No blocking issues found.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 24, 2026
A v14 writer can persist `lance.zone_write_seeds.version = "1"` through
its generic `update_config` without knowing `FLAG_ZONE_WRITE_SEEDS`.
Inferring activation from the resulting config let an ordinary v15
Append, Overwrite, or unrelated composite commit set bit 16 for such a
table, locking v14 out before any v1 seed was written.

Track whether this operation actually writes or deletes the key in both
the legacy manifest builder and the action path. Only that explicit
write validates the value and can activate the flag: writing "1" even
when it already says "1" is an opt-in, while "0" or deletion leaves the
sticky flag alone. Inherited values, including invalid ones, no longer
activate or block unrelated commits; explicitly rewriting an inherited
invalid value is still rejected.

Strengthen the ZONEMAP compat test so the previous version owns the
index update over a candidate append, and assert exact indexed and
unindexed IS NULL counts instead of accepting any non-empty result.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 24, 2026
@Xuanwo
Xuanwo merged commit 543df24 into main Nov 24, 2026
45 of 49 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/zonemap-seed-compatibility branch November 24, 2026 09:09
LuQQiu added a commit to LuQQiu/lance that referenced this pull request Nov 30, 2026
Resolve conflicts with the explicit opt-in for version 1 zone write seeds
(lance-format#11433) and the move of binary copy and the write seed collector to
lance-table-runtime, and keep zone write seed collection independent of
the seed format version:

- `lance.zone_write_seeds.enabled` no longer sets FLAG_ZONE_WRITE_SEEDS.
  Configured seeds use the same seed version as index-requested seeds:
  version 1 only when `write_v1_zone_write_seeds` holds, else version 0.
  `store_null_bitmap` applies at either version.
- The `lance.zone_write_seeds.` prefix validation accepts the `version` key
  and checks it with `validate_zone_write_seeds_version_config`; unknown
  keys under the prefix stay rejected.
- Binary copy carries configured seeds only inside the version 1 gate. The
  zone size declared for columns without a seeded index comes from the new
  `WriteSeedHook::unindexed_rows_per_zone`, and `index_rows_per_zone` only
  counts seeded ZoneMap indices, taking the finest.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer A-python Python bindings bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants