Skip to content

chore(db): enable auto-vacuum and add periodic maintenance#36851

Open
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:byk/db-auto-vacuum
Open

chore(db): enable auto-vacuum and add periodic maintenance#36851
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:byk/db-auto-vacuum

Conversation

@BYK

@BYK BYK commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Re-filed from #31528, which was auto-closed by the periodic PR-cleanup bot (age-based, not on technical grounds). Rebased onto latest dev.

Issue for this PR

Closes #31526

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Enables SQLite incremental auto-vacuum and adds maintenance utilities:

  1. One-time migration: detects auto_vacuum = 0 (NONE) and switches to INCREMENTAL. Runs a full VACUUM to apply the mode change. Subsequent database opens skip this since the mode persists.

  2. checkpoint(): runs PRAGMA wal_checkpoint(TRUNCATE) to flush the WAL file and reclaim disk space.

  3. vacuum(): runs PRAGMA incremental_vacuum to reclaim free pages from deleted rows.

These can be called periodically (e.g., on session idle) to keep database size in check.

Re-filing of #23053 which was auto-closed by the cleanup bot.

How did you verify your code works?

Tested locally by checking PRAGMA auto_vacuum before and after the migration. Verified the one-time VACUUM runs on first open and is skipped on subsequent opens. Tested checkpoint() and vacuum() functions directly.

Screenshots / recordings

N/A — database maintenance improvement.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@BYK
BYK force-pushed the byk/db-auto-vacuum branch from 91d2f96 to 3db2d6b Compare July 17, 2026 11:57
One-time migration: detect auto_vacuum = 0 (NONE) and switch to
INCREMENTAL. Run a full VACUUM to apply the mode change. Subsequent
database opens skip this since the mode persists.

This prevents the database file from growing indefinitely as deleted
rows leave behind free pages that are never reclaimed.
@BYK
BYK force-pushed the byk/db-auto-vacuum branch from 3db2d6b to 1c92d82 Compare July 17, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite auto_vacuum is disabled, database files grow indefinitely

1 participant