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

If this is Go and database/sql (as the modernc tidbit points to) this comment is ill advised.

Go database/sql handles ensuring each actual database connection is only by a single goroutine at a time (before being put back into the pool for reuse), and no sane SQLite driver should have issues with this.

If you're working in Go with database/sql you're meant to not have to worry about goroutines or mutexes. The API you're using (database/sql) is goroutine safe (unless the driver author really messed things up).

To be clear: each database/sql "connection" is actually a "pool of connections", that are already handed out (and returned) in goroutine safe way. The advise is to use two connection pools: a read-only one of size N, and a read-write one of size 1.

Regardless, mutexes are not needed.



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

Search: