FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(db): WAL friendly vacuum by bt90 · Pull Request #10556 · syncthing/syncthing · GitHub

fix(db): WAL friendly vacuum - #10556

Draft
bt90 wants to merge 1 commit into
syncthing:mainfrom
bt90:wal_friendly_vaccum
Draft

fix(db): WAL friendly vacuum#10556
bt90 wants to merge 1 commit into
syncthing:mainfrom
bt90:wal_friendly_vaccum

Conversation

bt90 commented Feb 4, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Purpose

Fixes #10554

Previously, we used to perform a full incremental vacuum run as part of our periodic clean-up. This is problematic for two reasons:

  • we had no heuristic in place to determine whether the vacuum run was even necessary. Vacuuming a large database is costly and may also result in fragmentation, so the reduction in size must be substantial enough to justify it. It is also good for performance to have a reasonable number of free pages in the database, as SQLite can recycle them instead of having to grow the database file.
  • The database file modifications must pass through the WAL. As this a single implicit transaction, it is not possible to complete a checkpoint until it is finished. see Checkpoint starvation #10559

This PR causes vacuum to be skipped if the number of free pages is less than 1k or 10% of the database size. If the freelist exceeds this threshold, an incremental vacuum is invoked in a loop, with a limit of 1k pages per execution. To avoid uncontrolled WAL growth, a passive checkpoint is attempted every fourth invocation. If multiple passive checkpoints fail to complete, we switch to a restart checkpoint for the next iteration.

Testing

TBD

Authorship

Your name and email will be added automatically to the AUTHORS file
based on the commit metadata.

bt90 changed the title WAL friendly vaccum WAL friendly vacuum Feb 4, 2026
bt90 changed the title WAL friendly vacuum fix(db): WAL friendly vacuum Feb 4, 2026
github-actions Bot added the bug A problem with current functionality, as opposed to missing functionality (enhancement) label Feb 4, 2026
bt90 force-pushed the wal_friendly_vaccum branch 3 times, most recently from 6e6705f to f33e4cb Compare February 7, 2026 21:59
Signed-off-by: bt90 <btom1990@googlemail.com>

Copy link
Copy Markdown
Contributor

Good direction with splitting incremental_vacuum into bounded chunks. However, as #10559 suggests checkpoint starvation is caused by frequent readers rather than simply excess freelist growth, is there a risk of tying checkpoint attempts too closely to vacuum triggering here?

Also, if WAL growth happens independently of freelist thresholds (as it seems to), should checkpoint escalation (PASSIVE -> FULL/RESTART) be driven by WAL conditions rather than vacuum conditions?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A problem with current functionality, as opposed to missing functionality (enhancement)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Break up incremental vacuum

2 participants


Back | FazBrowse Home | New Git URL