Skip to content

fix(server): enable checkpoint_fullfsync for SQLite WAL checkpoints on macOS - #47

Open
macodev00 wants to merge 1 commit into
mainfrom
cursor/macos-checkpoint-fullfsync-redo2-043c
Open

macodev00 wants to merge 1 commit into
mainfrom
cursor/macos-checkpoint-fullfsync-redo2-043c

Conversation

@macodev00

Copy link
Copy Markdown
Owner

What Changed

After enabling WAL on the server SQLite connection, setup now runs PRAGMA checkpoint_fullfsync = ON. WAL checkpoints on macOS then request F_FULLFSYNC. Ordinary commits keep using plain fsync(): PRAGMA fullfsync stays off.

The same per-connection pragma is set on the t3-sqlite-state and migrate-dev-db writer connections that bypass Sqlite.ts and can checkpoint state.sqlite, including the migration liveness probe that runs wal_checkpoint(TRUNCATE).

Tests read the pragmas back on the persistence layer and the state script: checkpoint_fullfsync = 1, fullfsync = 0.

Why

Issue pingdotgg#13544 is an accepted bug. A hard shutdown on macOS can corrupt state.sqlite because WAL checkpoints sync with fsync(), which does not flush the drive cache. Julius prescribed this fix in triage: after WAL, run PRAGMA checkpoint_fullfsync = ON, and leave ordinary fullfsync off.

This is not a broad product persistence default change. It only makes checkpoint sync durable on the connections that already checkpoint state.sqlite. Per-commit sync is unchanged because fullfsync stays off. Where F_FULLFSYNC is absent, the pragma is a no-op.

Fixes pingdotgg#13544

UI Changes

None.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes
Open in Web Open in Cursor 

A hard shutdown on macOS can corrupt state.sqlite because checkpoint syncs
use fsync(), which does not flush the drive cache. Set checkpoint_fullfsync
after WAL setup and on the other state.sqlite writers. Leave fullfsync off.

Fixes pingdotgg#13544

Co-authored-by: maco <macodev00@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS labels Sep 25, 2026

This branch has not been deployed

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

Labels

size:XS vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hard shutdown on macOS corrupts state.sqlite: SQLite never uses F_FULLFSYNC

1 participant