Skip to content
Fix SQLite database locking issue

In some busy workloads various SQLite operations would fail due to
"locked tables"; most of this is related to the session code:

- On every pageview a new session is either read (OK) or written (LOCK!)
- At the same time, the cron may be writing data to the db (LOCK!)

On smaller instances this isn't much of an issue since everything is
fast enough to not lock for too long, but on longer instances this can
be a problem.

Setting SetMaxOpenConns(1) solves this by limiting the connections
writing to the database.

Also set the default journal mode to WAL, which should give better
performance. Both of this is done in the zgo.at/zdb update.

Add "goatcounter help db" to document database usage a bit better.