fix(cli): remove orphan SQLite sidecars on index deletion (#2054) - #2137
Merged
Conversation
cbm_remove_indexes unlinked each *.db and *.db.tmp but never the SQLite sidecars (<db>-wal/-shm/-journal), so `cbm update`, `cbm uninstall`, and `install --reset-indexes` (the four callers of the single deletion chokepoint) left orphan -wal/-shm files behind. Call the existing wide-path-safe cbm_remove_db_sidecars() helper on both the live and staged db paths after the .db unlink; it is idempotent and ENOENT-tolerant, so an orphan -wal that outlived its .db is still cleaned. Sidecars are not indexes, so the removed-count is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
DeusData
enabled auto-merge
September 11, 2026 23:29
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.
What
cbm_remove_indexes()— the single deletion chokepoint behindcbm update,cbm uninstall, andinstall --reset-indexes— unlinked each index*.db(and its*.db.tmp) but never the SQLite sidecar files<db>-wal/<db>-shm/<db>-journal. Every explicit index removal therefore left orphan-wal/-shmfiles behind (the residue of #2054, after theupdate-deletes-indexes bug itself was fixed by 9ecabe0).Fix
Call the existing wide-path-safe
cbm_remove_db_sidecars()helper (src/foundation/compat_fs.c) on both the live and staged db paths right after the.dbunlink. It is idempotent and ENOENT-tolerant, so an orphan-walthat outlived its.dbis cleaned too. Sidecars are not indexes, so the removed-count is unchanged. No pre-existing-orphan sweep (out of scope).Test
New
cli_remove_indexes_deletes_orphan_sqlite_sidecars(tests/test_cli.c, cross-platform): createsproj.db+proj.db-wal+proj.db-shm, callscbm_remove_indexes, asserts all three are gone. RED-on-revert verified — reverting the two helper calls re-leaves the sidecars (309/1, sole failure on the new test); with the fix, 310/0. ASan/UBSan clean.