Skip to content

Background TRUNCATE checkpoint blocks live state writes behind old readers #1275

Closed

Description

@frahlg

On v3.5.3-beta.1 (8650c58), Store.CheckpointWAL uses wal_checkpoint(TRUNCATE) against state.db and cache.db after hourly maintenance. TRUNCATE waits for old read snapshots while holding SQLite's writer lock. The five-second busy timeout is long enough to delay durable charging goals and model saves.

Local reproduction uses a temporary SQLite database: hold a read transaction, commit a newer config value from another connection, then call CheckpointWAL. TestCheckpointWALDoesNotWaitForReaders fails on the release code because the checkpoint does not return within one second. The reader stays open throughout the test; no hardware or household data is needed.

Use bounded PASSIVE checkpoints for the running service. Preserve synchronous durability and let SQLite reuse WAL pages after readers finish. Test that the checkpoint returns while the reader remains open and that a durable config write still succeeds. Keep offline truncation separate.

Related: #1149, #1246. This proves a lock problem in code, not the sole cause of every observed storage timeout. Fix before promoting this beta line to stable.

Activity

  1. frahlg commented on Sep 24, 2026

    @frahlg
    MemberAuthor

    This is in the code that v0.132.0-beta.1 is running.

    CheckpointWAL uses PRAGMA wal_checkpoint(PASSIVE) with a one-second budget, and truncation stays on the offline VACUUM path. TestCheckpointWALDoesNotWaitForReaders passes: the checkpoint returns while a read transaction is still open, and a durable config write succeeds after it.

    Closing. The separate Pi measurement for backup IO is #1246.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions