fix(backends/chroma): release SQLite file lock on close_palace/close (#1067)#1105
Merged
igorls merged 1 commit intoMemPalace:developfrom May 6, 2026
Merged
Conversation
c8a6938 to
195eed2
Compare
4 tasks
195eed2 to
4260706
Compare
…emPalace#1067) ChromaBackend.close_palace() and close() evicted cached PersistentClients from self._clients without calling client.close(), so chromadb 1.5.x kept the rust-side SQLite file lock until GC. Reopening the same palace path after shutil.rmtree + re-create within one process then failed with SQLITE_READONLY_DBMOVED (SQLite code 1032). Add _close_client() helper with a try/except fallback for older chromadb, and route close_palace(), close(), and the DB-file-missing invalidation branch of _client() through it. The mtime/inode auto-invalidation branch is left as-is: callers there may still hold a live ChromaCollection handle, and closing out from under them clears the rust bindings mid-use. Regression tests cover close_palace reopen-same-path and whole-backend close for multiple palaces.
d5a5daf to
45df1a2
Compare
2 tasks
4 tasks
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.
Problem
ChromaBackend.close_palace()andclose()evict cachedPersistentClients fromself._clientswithout callingclient.close(). chromadb 1.5.x retains the rust-side SQLite file lock until GC, so reopening the same palace path aftershutil.rmtree+ re-create within one process fails:SQLite code 1032 is
SQLITE_READONLY_DBMOVED. Reported and diagnosed in #1067.Fix
_close_client()helper callsPersistentClient.close()with a try/except fallback for older chromadb that does not expose it. Three sites route through it:close_palace(palace): explicit per-palace teardownclose(): whole-backend shutdown, iterates cached clients before clearing_client()invalidation on missingchroma.sqlite3: palace rebuilt under usThe
_client()auto-invalidation branch onmtime/inodechange is left alone. Callers there may still hold a liveChromaCollectionbacked by the outgoing client; closing it would clear the rust bindings mid-use.Test plan
test_chroma_close_palace_releases_sqlite_lock_for_reopen: close, rmtree, reopen same pathtest_chroma_close_releases_all_cached_clients: two palaces, whole-backend close, each reopenabledevelopwith SQLite code 1032 and pass with the fixCredits @xelauvas for the diagnosis and proposed direction.
Fixes #1067.