fix(prune): batch DELETE IN to stay under SQLite var limit (#43)#45
Merged
Conversation
An unbatched `DELETE FROM file_hashes WHERE file_path IN (?1..?N)` binds one variable per file. When a source with more than SQLITE_MAX_VARIABLE_NUMBER (32766) files is pruned in one pass, the statement exceeds the limit and aborts, leaving the index inconsistent until a --force reindex. Chunk the delete into batches of 30k ids, all within a single transaction so the prune stays atomic. Add a regression test that deletes 40k rows. Fixes #43 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VsuPDxSUjMYqHvQyPvSAPW
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.
Summary
Fixes #43.
delete_file_hashesbuilt a singleDELETE FROM file_hashes WHERE file_path IN (?1..?N)binding one variable per file. When a source with more thanSQLITE_MAX_VARIABLE_NUMBER(32766) files was pruned in one pass (source removed, repointed, or full reindex), the statement exceeded the limit and aborted, leaving the index inconsistent until a--forcereindex — silently degrading search coverage.Fix
SQLITE_MAX_BIND_VARS(30k) ids.Test
test_delete_file_hashes_exceeds_bind_var_limitinserts 40k rows and deletes them all; the old unbatched path fails this.test_delete_file_hashesstill passes.🤖 Generated with Claude Code