Repository navigation
next-plaid: drop the cached metadata reader when recreating a deleted index - #198
Open
jipeng6036-del wants to merge 1 commit into
Open
jipeng6036-del wants to merge 1 commit into
jipeng6036-del wants to merge 1 commit into
Conversation
… index
create() and create_with_fixed_columns() only invalidated the cached
read-only SQLite connection when metadata.db still existed. When the
index directory had been removed first (DELETE /indices/{name}), the
cached connection kept reading the old, unlinked database, so count()
and metadata reads on a recreated index of the same name returned the
old rows.
Invalidate the cached reader unconditionally before recreating the
database, and add a regression test that warms the reader, removes the
directory and recreates the index.
Fixes lightonai#197
This branch has not been deployed
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.
Fixes #197.
Problem
filtering::create()andcreate_with_fixed_columns()only drop the cached read-only SQLite connection (DB_READ_CONNECTIONS) insideif db_path.exists(). When an index is deleted withDELETE /indices/{name}, the whole directory is removed, so on recreationmetadata.dbno longer exists and the cached reader is never invalidated. It still points at the old, unlinked database, socount()and metadata reads on the recreated index return the old generation's rows. This matches the "index still has 50 documents but DB has 580 records" sync-repair error in the issue.Change
Call
invalidate_read_connection(&db_path)unconditionally before recreating the database in both create paths. Removing a key that isn't in the cache is a no-op, so the existing behavior when the file exists stays the same.Verification
test_create_after_directory_removal_drops_cached_reader. It creates 5 rows, warms the reader withcount(), runsfs::remove_dir_all, then recreates the index with 2 rows. Onmainit fails withleft: 5, right: 2. With the fix it passes.cargo test -p next-plaid(no BLAS features): all pass (159 lib tests plus the integration tests).cargo clippy -p next-plaid --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.Not run: the
openblas/acceleratefeature builds, the next-plaid-api end-to-end delete/recreate flow from the issue, the ONNX and colgrep crates.This change was prepared with an AI coding assistant. The reproduction and the checks listed above were actually run.