Checkpoint starvation
What happened?
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:
https://www.sqlite.org/pragma.html#pragma_wal_checkpoint
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.
Syncthing version
v2.0.14
Platform & operating system
Linux
Browser version
No response
Relevant log output
Source: syncthing/syncthing