fix(vector_io): set WAL mode and busy_timeout on sqlite-vec connections#5428
fix(vector_io): set WAL mode and busy_timeout on sqlite-vec connections#5428extrasmall0 wants to merge 1 commit intollamastack:mainfrom
Conversation
The inline::sqlite-vec provider opens database connections without setting WAL mode or busy_timeout. With multiple uvicorn workers, concurrent writes fail with 'database is locked' instead of retrying. Apply the same pragmas already used by the SQL store backend: - journal_mode=WAL for concurrent reader/writer support - busy_timeout=5000 to retry instead of failing immediately - synchronous=NORMAL for better performance (safe with WAL) - timeout=5.0 on connect() as a Python-level fallback Fixes llamastack#5344
|
Hi @extrasmall0! 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! |
The inline
sqlite-vecprovider opens database connections without setting WAL mode orbusy_timeout. When running with multiple uvicorn workers (server.workers > 1), concurrent writes fail immediately withsqlite3.OperationalError: database is lockedinstead of waiting and retrying.The SQL store backend (
sqlalchemy_sqlstore.py) already handles this correctly by settingjournal_mode=WAL,busy_timeout=5000, andsynchronous=NORMAL. This patch applies the same pragmas to the shared_create_sqlite_connection()helper used by the vector store.Changes:
timeout=5.0onsqlite3.connect()as a Python-level busy waitPRAGMA journal_mode=WALfor concurrent reader/writer supportPRAGMA busy_timeout=5000so SQLite retries instead of raising immediatelyPRAGMA synchronous=NORMALfor better write throughput (still safe with WAL)Fixes #5344