SQLite Forum

PRAGMA wal_checkpoint(RESTART) unexpectedly returning SQLITE_BUSY immediately

I have a busy, very concurrent SQLite database: 36 connections open from the same process, about 1000 writes per second. As is apparently expected, the WAL file is growing without bound. To counter this, I am attempting to deliberately insert a periodic "stop-the-world" style event by calling:

    PRAGMA wal_checkpoint(RESTART);

As I understand it, this will grab an exclusive lock, invoking the busy handler.

All of these connections are configured with a busy_timeout of 10 seconds. But the `PRAGMA wal_checkpoint(RESTART)` returns busy within a microsecond. Similarly, `sqlite3_wal_checkpoint_v2` returns `SQLITE_BUSY` within a microsecond.

Am I misunderstanding the documentation of sqlite3_wal_checkpoint?

Thank you,