Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That is because the default SQLite mode is journal, but for concurrent reads and writes you need to switch it to WAL.


I use WAL basically everywhere. I thought that would fix my problem some time ago, but it didn't


Are you seeing SQLITE_BUSY errors?

Those are a nasty trap. The solution is non-obvious: you have to use BEGIN IMMEDIATE on any transaction that performs at least one write: https://simonwillison.net/tags/sqlite-busy/


This is correct, and one of the things I tell anybody who is considering using SQLite to watch out for. The busy timeout and deferred write transactions interact in a really non intuitive way, and you have to use BEGIN IMMEDIATE for any transaction that performs any writes at all, otherwise SQLite gives up and throws an error without waiting if another traction is writing when your traction attempts to upgrade from a read to a write.


Thanks for the direction. I thought SQLite was limited in how multiple processes can access the db files, but now I see the problem is on my end. Btw. I'm a fan of your AI/LLM articles, thanks for your awesome work.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: