Repository navigation
Conversation
`table_names()` lists any `<name>.lance` directory without validating it, while `open_table()` maps every `lance::Error::DatasetNotFound` to `Error::TableNotFound`. A directory left behind by an interrupted drop and re-create is therefore listed as a table but reported as missing when opened, and callers cannot tell "never existed" from "exists but is unreadable". On `DatasetNotFound`, check whether a `<name>.lance` entry is actually present in the parent directory — the same predicate `table_names()` uses — and return the new `Error::TableCorrupted` when it is. The check only runs on the error path, and listing the parent (rather than probing the table path) is the one form that works for both local filesystems and object stores, which have no empty directories. Closes lancedb#3127
wjones127
self-requested a review
July 28, 2026 20:35
wjones127
approved these changes
Jul 28, 2026
wjones127
left a comment
Contributor
There was a problem hiding this comment.
This makes sense, although perhaps you want to take it a step further and map it to a good error in Python? If not, we can file a follow up issue.
This also makes me think we should create a repair command on databases.
Comment on lines
+21
to
+24
| #[snafu(display( | ||
| "Table '{name}' exists but could not be loaded (it may be corrupt or incomplete): {source}" | ||
| ))] | ||
| TableCorrupted { name: String, source: BoxError }, |
Contributor
There was a problem hiding this comment.
suggestion: it would be nice to map this error to a nice error in Python. Right now, they will just be converted to RuntimeError:
Line 105 in 98a5226
BubbleCal
added a commit
that referenced
this pull request
Aug 13, 2026
## What is the bug? #3731 tries to distinguish a missing table from a corrupt table after Lance returns `DatasetNotFound`. It does that by listing the database parent and treating a physical `<name>.lance` entry as evidence that the table exists. That premise is not sound for a listing database. Table creation writes data before atomically committing the first manifest, so the same physical prefix can represent a live concurrent create, abandoned uncommitted data, or an old empty directory. It is not evidence of a committed table. The parent listing also makes every missing-table open, including the create-on-miss path, perform work proportional to the number of sibling tables. Cloud `list_with_delimiter` exhausts all pages before returning. ## How does this PR fix the problem? This PR makes the committed Lance manifest the sole table-existence authority for listing-database opens: - `DatasetNotFound` maps directly to `TableNotFound`; no parent or target storage probe runs. - Other Lance load errors continue to propagate unchanged. - A physical directory, object prefix, or uncommitted data file alone does not block `Create`. - Concurrent `Create` requests are arbitrated by the conditional version-1 manifest commit: one succeeds and the loser receives `TableAlreadyExists`. - `table_names` is documented as physical discovery, not an atomic table-existence check. Its snapshot can contain an entry that is still being created, has only uncommitted storage, or is concurrently dropped. This removes the need for a new Lance object-store capability. LanceDB remains on the official Lance `v11.0.0-beta.6` dependency from `main`; the merge commit for lance-format/lance#7722 is an ancestor of that tag, so the ambiguous-GCS-500 corruption-prevention fix is retained. ## Performance evidence Lower is better. The benchmark uses real `.lance` directories with marker objects on the local filesystem; fixture creation and teardown are outside the timed region. Baseline is `origin/main` at `6fb976cf`, candidate is `e1240751`. Both were built from the same lockfile on the same macOS arm64 machine with the repository's `release` profile (fat LTO), then executed in alternating baseline/candidate order for three pairs. Each run used 10 warmups and 100 distinct missing-table opens per scale. The table reports the median of the three run-level percentiles. | Scenario / metric | Baseline | This PR | Benefit | | --- | ---: | ---: | ---: | | 1,000 real sibling directories, p50 | 11.905 ms | 21.042 us | 566x speedup | | 10,000 real sibling directories, p50 | 143.630 ms | 18.375 us | 7,817x speedup | | 100,000 real sibling directories, p50 | 1.991 s | 19.917 us | 99,984x speedup | | 100,000 real sibling directories, p95 | 2.346 s | 25.792 us | 90,965x speedup | These results validate removal of the sibling-cardinality dependency in this local-filesystem workload; they are not an extrapolation to production GCS latency. A structural object-store regression test separately asserts that opening one missing table performs zero parent-scoped `list`, `list_with_offset`, or `list_with_delimiter` calls. Run with: ```bash BENCH_SIBLINGS=1000,10000,100000 BENCH_WARMUPS=10 BENCH_TRIALS=100 \ cargo run --locked --release --quiet -p lancedb --example bench_open_missing_table ``` ## Correctness and compatibility boundaries - An empty `.lance` directory or orphan data without a committed manifest now opens as `TableNotFound` and may be replaced by a successful `Create`. - Two synchronized creators sharing one object store deterministically produce one success and one conditional-manifest conflict mapped to `TableAlreadyExists`. - A readable manifest remains authoritative; non-`DatasetNotFound` corruption, external-manifest, authorization, and object-store errors are not folded into `TableNotFound`. - `TableCorrupted` remains in the public error enum for compatibility, but this listing-database fallback no longer synthesizes it from an ambiguous physical footprint. - Reliably distinguishing `Missing`, `Creating`, and `Corrupt` would require explicit authoritative lifecycle/catalog metadata (for example a leased creation record). It cannot be inferred from a directory or prefix, and is outside this incident fix. ## Validation - `cargo fmt --all -- --check` - `cargo check --quiet --locked -p lancedb --features remote --tests --examples` - `cargo clippy --quiet --locked -p lancedb --features remote --tests --examples -- -D warnings` - `cargo test --quiet --locked -p lancedb --features remote --tests` - library: 843 passed, 1 ignored - integration groups: 39 passed, 6 passed, 5 passed - focused coverage for empty directories, orphan data, physical listing snapshots, zero parent listings, and concurrent manifest arbitration
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.
table_names()lists any*.lancedirectory, butopen_table()maps everyDatasetNotFoundtoTableNotFound, so a corrupt or partially-written table looks identical to one that never existed (#3127). This takes the issue's Option 2: onDatasetNotFound, check the parent listing for the table's.lanceentry — the same predicatetable_names()uses — and return a newTableCorruptederror when the directory is present. The check runs only on the error path, and any failure in the recheck falls back to the previousTableNotFoundbehavior.Tests cover the reporter's empty-dir repro, a deleted-manifest case, true absence (still
TableNotFound), and an end-to-end list-then-open assertion; the three new corrupt-case tests fail without the src change.cargo test -p lancedb --lib732 passed, clippy/fmt clean,cargo check --workspace --all-targetsclean (both language bindings end in wildcard error arms).Two notes for review:
Errorisn't#[non_exhaustive], so the new variant is technically semver-breaking for exhaustive matchers (pre-1.0, and the alternative — changingTableNotFound's shape — breaks more); and on the Python side corrupt tables now surface asRuntimeErrorrather thanValueError, which is the intended distinction but worth a maintainer's eye.open_from_namespacewas left unchanged since namespace listings come from a server-side registry, not directory globbing.Closes #3127