Skip to content

fix(mem-wal): resolve writer shard spec identity - #8112

Open
u70b3 wants to merge 2 commits into
lance-format:mainfrom
u70b3:feat/memwal-shard-spec-id-allocation
Open

fix(mem-wal): resolve writer shard spec identity#8112
u70b3 wants to merge 2 commits into
lance-format:mainfrom
u70b3:feat/memwal-shard-spec-id-allocation

Conversation

@u70b3

@u70b3 u70b3 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve the default dataset-writer shard_spec_id (0) to the MemWAL index's sole automatic sharding spec before creating or claiming a shard manifest
  • accept an explicit id only when it matches that sole spec, and require manually sharded indexes to keep id 0
  • reject metadata with multiple automatic specs because the current writer model supports at most one
  • cover the original fresh-shard bug at the public Dataset::mem_wal_writer boundary plus invalid manual, mismatched, and multiple-spec inputs

Scope

This PR fixes the current writer path only. MemWAL initialization already creates either no spec (manual sharding) or one automatic spec with id 1; the writer must record that same identity instead of its unresolved default 0.

It does not add monotonic allocation, spec revisions, activation semantics, metadata validation for hypothetical producers, or a file-format change. Those require a separate end-to-end design if a re-shard API is introduced.

This PR complements but is not a prerequisite for #7949: this PR resolves the table identity before a fresh manifest is created, while #7949 defensively rejects changing an identity already stored in a manifest.

Testing

  • cargo fmt --all -- --check
  • cargo test -p lance --lib test_writer_shard_spec_resolution_rejects_invalid_identity -- --nocapture
  • cargo test -p lance --lib test_mem_wal_writer_uses_automatic_sharding_spec -- --nocapture
  • cargo clippy --all --tests --benches -- -D warnings

@github-actions github-actions Bot added the enhancement New feature or request label Jul 31, 2026
@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch 5 times, most recently from a82f42f to 9c6f90d Compare August 2, 2026 08:12
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Important

This PR touches the Lance format specification.

Substantive changes to the format specification — the .proto definitions
and the spec docs under docs/src/format/ — require a PMC vote before merge.
Minor edits such as typo fixes, wording, or formatting are excluded; use your
judgment.

If this is a meaningful format change:

  • Start a vote following the Lance community voting process.
    Format specification modifications need 3 binding +1 votes (excluding the
    proposer), held on GitHub Discussions, with a minimum voting period of 1 week.
  • Once the vote passes, link the completed vote in this PR. It should not be
    merged until the vote is linked.

@github-actions github-actions Bot added the A-format On-disk format: protos and format spec docs label Aug 2, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 9c6f90d to dbb9b85 Compare August 3, 2026 06:55
lance-gatekeeper[bot]

This comment was marked as outdated.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 0c3ae83 to 369c3ae Compare August 3, 2026 10:05
@u70b3 u70b3 changed the title feat(mem-wal): allocate monotonic sharding spec ids fix(mem-wal): resolve writer shard spec identity Aug 3, 2026
@github-actions github-actions Bot added the bug Something isn't working label Aug 3, 2026
@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 369c3ae to ef2336f Compare August 3, 2026 10:20
@u70b3

u70b3 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Scope reset completed and force-pushed on latest main.

The PR is now one commit / one file (+96) instead of 8 files (+541/-20). It fixes only the current public writer path: initialization records automatic spec 1, while ShardWriterConfig::default() supplies unresolved 0; Dataset::mem_wal_writer now resolves that default to the sole stored spec before creating the manifest and rejects explicit mismatches.

Removed: monotonic allocation, multi-revision/activation semantics, metadata-boundary validation, format docs, and all format-change claims. The original boundary regression failed with manifest spec 0 vs expected 1 before the fix and now passes. Full workspace clippy and the focused cases pass after the latest-main rebase.

This is complementary to, but not a prerequisite for, #7949. Please re-review the reduced current-path fix.

lance-gatekeeper[bot]

This comment was marked as outdated.

@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from ef2336f to c79ab2b Compare August 3, 2026 11:18
lance-gatekeeper[bot]

This comment was marked as outdated.

@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from c79ab2b to 5278607 Compare August 3, 2026 13:49
lance-gatekeeper[bot]

This comment was marked as outdated.

@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 5278607 to 5d3435a Compare August 3, 2026 16:56
lance-gatekeeper[bot]

This comment was marked as outdated.

@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 5d3435a to 4e1861b Compare August 4, 2026 11:04
lance-gatekeeper[bot]

This comment was marked as outdated.

@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 4e1861b to 02a0404 Compare August 4, 2026 12:29
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 21, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 21, 2026
@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 1b2c5b5 to 9bf9f42 Compare August 26, 2026 09:07
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 26, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 26, 2026
@u70b3

u70b3 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the current failures are runner-environment flakes unrelated to this change (which touches only mem_wal/api.rs): uring::tests::test_read_range died with io_uring ENOMEM ("no io_uring worker threads are available: Cannot allocate memory"), and test_torch_index_with_nans[Legacy] hit StopIteration — main's own Python workflow is red with vector-test flakes at the same time. Retriggering via close/reopen.

@u70b3 u70b3 closed this Aug 26, 2026
@u70b3 u70b3 reopened this Aug 26, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Aug 26, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@u70b3

u70b3 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

The remaining CI failures here are tracked in #8789 — systematic main-level test failures (not caused by this PR). Will retrigger once main's own CI recovers.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Aug 26, 2026
@u70b3 u70b3 closed this Aug 26, 2026
@u70b3 u70b3 reopened this Aug 26, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Aug 26, 2026
@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from 006e024 to c831944 Compare September 7, 2026 02:12
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 7, 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.

The writer resolves shard identity before any claim side effect, and the success-path cases cover manual identity, automatic default resolution, and an explicit matching ID. Future spec revisions and activation semantics remain cleanly out of scope.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 7, 2026
@u70b3
u70b3 force-pushed the feat/memwal-shard-spec-id-allocation branch from c831944 to 20c81df Compare September 7, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-format On-disk format: protos and format spec docs bug Something isn't working enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants