Skip to content

fix(core): avoid correlated sqlite-vec orphan cleanup - #1584

Closed
mikemikimike wants to merge 1 commit into
basicmachines-co:mainfrom
mikemikimike:fix/sqlite-vec-delete-orphans-1581
Closed

mikemikimike wants to merge 1 commit into
basicmachines-co:mainfrom
mikemikimike:fix/sqlite-vec-delete-orphans-1581

Conversation

@mikemikimike

Copy link
Copy Markdown
Contributor

Avoid correlated sqlite-vec orphan cleanup

Why

Issue: #1581

Fixes #1581

Correlated orphan cleanup can fail on SQLite vector-backed deletion paths.

What Changed

Replaced the correlated orphan cleanup query with a JOIN-based deletion so orphaned sqlite-vec rows are removed reliably.

Testing

Focused regression test: uv run pytest tests/repository/test_sqlite_vector_search_repository.py -q — 27 passed.

@phernandez

Copy link
Copy Markdown
Member

Thank you @mikemikimike for the detailed report in #1581 and for this fix. Fork PRs don't get CI in this repo, so I've carried your commit, with your authorship and sign-off, into #1612. It will be rebase-merged so the commit stays yours. I added a query-plan regression test on top, since the row-level test passes on the old SQL too. I also benchmarked the fix on the new partitioned vec0 schema: the old query took over 30s on 5k rows, and yours took 0.026s. Closing this in favor of #1612.

@phernandez phernandez closed this Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] sqlite-vec delete_orphans uses a correlated DELETE that stalls cleanup and blocks writers

2 participants