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
Our current database maintenance logic is prone to checkpoint starvation. The problem is that there's no guarantee that readers are active during the maintenance window. While wal_checkpoint(TRUNCATE) blocks other writers, there is no such thing for readers:
The result of this is a WAL that will keep its size or even grow further until a checkpoint without an active reader transaction can be executed. For long running scans and transfers, this might never happen.
As the WAL size has a negative impact on reader performance, we end up with a positive feedback loop. The readers execute slower with a growing WAL and the chances of a successful checkpoint vanish.
This mode blocks (it invokes the busy-handler callback) until there is no database writer and all readers are reading from the most recent database snapshot.
RESTART:
This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition that after checkpointing the log file it blocks (calls the busy-handler callback) until all readers are reading from the database file only
If I'm interpreting this correctly, a checkpoint would fail while there's an active reader transaction based on an older snapshot of the database.
While we took checkpoint handling into our own hands, we didn't disable the auto mechanism.
All calls obtain an exclusive "checkpoint" lock on the database file. If any other process is running a checkpoint operation at the same time, the lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a busy-handler configured, it will not be invoked in this case.
Given a large WAL, all readers would trigger a PASSIVE checkpoint on commit. If such a checkpoint is executing our manual checkpoints would instantly fail.
I don't follow your analysis. The sequence will update on any insert or change. If the disk is full and everything is stopped it may indeed not run, but also would likely not succeed since I'm sure the compaction requires additional space for temp files.
Activity
dmih commentedon Feb 4, 2026
as it seems that it will require isolation readers from checkpoint, the fix to this bug will probably also fix this: #10529
bt90 commentedon Feb 4, 2026
https://sqlite.org/c3ref/wal_checkpoint_v2.html has a bit more details.
FULL:
RESTART:
If I'm interpreting this correctly, a checkpoint would fail while there's an active reader transaction based on an older snapshot of the database.
bt90 commentedon Feb 4, 2026
https://forum.syncthing.net/t/is-syncthing-v2-with-very-large-folders-possible/26082/38 shows that we're constantly moving pages from the WAL to the database(albeit slower than the WAL is growing). This means that it's not caused by a read transaction that is running for hours/days.
The problem is that those reads are in quick succession. Our checkpointer routine is never able to hit a gap.
bt90 commentedon Feb 5, 2026
The rabbit hole goes even deeper. Readers might trip the autocheckpointer threshold:
https://sqlite.org/pragma.html#pragma_wal_autocheckpoint
While we took checkpoint handling into our own hands, we didn't disable the auto mechanism.
Given a large WAL, all readers would trigger a PASSIVE checkpoint on commit. If such a checkpoint is executing our manual checkpoints would instantly fail.
schaurian commentedon Sep 12, 2026
calmh commentedon Sep 12, 2026
I don't follow your analysis. The sequence will update on any insert or change. If the disk is full and everything is stopped it may indeed not run, but also would likely not succeed since I'm sure the compaction requires additional space for temp files.
schaurian commentedon Sep 13, 2026
docs: PATCHES.md/ISSUES.md currency pass
docs: PATCHES.md/ISSUES.md currency pass
docs: PATCHES.md/ISSUES.md currency pass
docs: PATCHES.md/ISSUES.md currency pass