You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know your example shows that if you configure go-sqlite3 correctly (with things like SetMaxOpenConns(1) and WAL mode), you can squeeze out better throughput in controlled scenarios. In my day-to-day, though, I’ve often run into intermittent “database is locked” errors when juggling multiple goroutines in a more complex setup—especially in the pub/sub workflows I use with Watermill.
The goal of comfylite3 isn’t to magically give SQLite full multi-writer capabilities. Rather, it’s a convenience wrapper that automatically handles those occasional lock errors by queuing and retrying operations. This means you don’t have to sprinkle your code with manual retry logic every time you hit a lock, which can be a real nuisance in side projects and tests.
I totally agree that for a production system with heavy concurrent writes, relying solely on SQLite (or abstracting its limitations) isn’t ideal. In those cases, using patterns like the outbox or even switching to PostgreSQL is the way to go. My PR is aimed at scenarios where SQLite’s simplicity is a plus and where you’d prefer not to write extra boilerplate to handle its quirks.
I’ll definitely beef up the docs to clearly state these trade-offs. Let me know if you have any more thoughts or questions!
Continuing our discussion from ThreeDotsLabs/watermill-sql#31
Can you provide an example, where concurrent (multiple goroutines) sqlite3 code is truly problematic?
I modified your example, to only use the stdlib and go-sqlite3, but I cannot spot any concurrency problems:
When I modify your example to run the inserts truly concurrent, the throughput increases by factor 4x:
The text was updated successfully, but these errors were encountered: