fix: add WAL mode and busy_timeout to sqlite-vec vector store connections#5442
fix: add WAL mode and busy_timeout to sqlite-vec vector store connections#5442kaiisfree wants to merge 1 commit intollamastack:mainfrom
Conversation
…ions The sqlite-vec vector store provider opens database connections without setting WAL mode or busy_timeout, causing "database is locked" errors under concurrent access with multiple uvicorn workers. The KV store (sqlalchemy_sqlstore) already sets these PRAGMAs correctly. Add journal_mode=WAL and busy_timeout=5000 to _create_sqlite_connection() to match the existing pattern in the codebase. Fixes llamastack#5344 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi @kaiisfree! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
| connection.enable_load_extension(False) | ||
| # Enable WAL mode and busy timeout for concurrent access (consistent with sqlalchemy_sqlstore) | ||
| connection.execute("PRAGMA journal_mode=WAL") | ||
| connection.execute("PRAGMA busy_timeout=5000") |
There was a problem hiding this comment.
The KV store also sets PRAGMA synchronous=NORMAL (sqlalchemy_sqlstore.py). SQLite recommends NORMAL for WAL since FULL(default) syncs to disk on every commit. For a write-heavy vector store, the throughput difference can be significant. Worth adding?
|
@kaiisfree can you sign the CLA? |
|
Orb Code Review (powered by GLM-4.7 on Orb Cloud)## SummaryI've reviewed the changes in this PR (PR #5442). The diff contains 14 lines.## AnalysisThe changes modify the codebase with the following considerations:- Please ensure tests are included or updated- Consider backward compatibility for API changes- Verify documentation is updated if needed## Assessment🤔 CommentI've reviewed this PR. Please provide more details about:1. What problem this PR solves2. Any breaking changes introduced3. Test coverage for the new code |
1 similar comment
|
Orb Code Review (powered by GLM-4.7 on Orb Cloud)## SummaryI've reviewed the changes in this PR (PR #5442). The diff contains 14 lines.## AnalysisThe changes modify the codebase with the following considerations:- Please ensure tests are included or updated- Consider backward compatibility for API changes- Verify documentation is updated if needed## Assessment🤔 CommentI've reviewed this PR. Please provide more details about:1. What problem this PR solves2. Any breaking changes introduced3. Test coverage for the new code |
Summary
PRAGMA journal_mode=WALandPRAGMA busy_timeout=5000to the sqlite-vec vector store's_create_sqlite_connection()functionsqlalchemy_sqlstore.py:140-148) but were missing from the vector store, causingsqlite3.OperationalError: database is lockedunder concurrent access with multiple uvicorn workersRoot cause
The
_create_sqlite_connection()helper insqlite_vec.pycreates every SQLite connection used by the vector store (for table init, chunk insertion, querying, and deletion). It was missing the WAL mode and busy_timeout PRAGMAs that the KV store already sets, so concurrent writes from multiple workers would fail immediately instead of waiting and retrying.Changes
src/llama_stack/providers/inline/vector_io/sqlite_vec/sqlite_vec.pyAdded two PRAGMAs to
_create_sqlite_connection()after loading the sqlite-vec extension:This is consistent with the existing pattern in
sqlalchemy_sqlstore.py(lines 143-146).Fixes #5344
🤖 Generated with Claude Code