News for hackers. Stuff that matters.
Re:Things that surprised me while running SQLite in production by nullcipher on Tuesday July 04, 2023 @05:30AM (#36584232)
Can SQLite have multiple processes writing to the same database? Is this safe?
Re:Things that surprised me while running SQLite in production by ilyt on Tuesday July 04, 2023 @06:10AM (#36584586)
Yes, just not at the same time. If you can you want to enable WAL (that requires some shared memory primitives, so same machine generally), because otherwise writes block reads

https://www.sqlite.org/wal.html

Re:Things that surprised me while running SQLite in production by nullcipher on Tuesday July 04, 2023 @06:16AM (#36584618)
> Yes, just not at the same time.

Does this mean that my processes need some synchronization primitive of their own to not to concurrent writes?

Re:Things that surprised me while running SQLite in production by joseferben on Tuesday July 04, 2023 @06:30AM (#36584717)
Afaik SQLite in WAL mode takes your writes but still serializes the commits, so no SQLite-specific synchronization primitives needed. You might run into SQLITE_BUSY, in which case you can play with the timeout https://www.sqlite.org/c3ref/busy_timeout.html