Conversation
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>
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
After enabling WAL on the server SQLite connection, setup now runs
PRAGMA checkpoint_fullfsync = ON. WAL checkpoints on macOS then requestF_FULLFSYNC. Ordinary commits keep using plainfsync():PRAGMA fullfsyncstays off.The same per-connection pragma is set on the
t3-sqlite-stateandmigrate-dev-dbwriter connections that bypassSqlite.tsand can checkpointstate.sqlite, including the migration liveness probe that runswal_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.sqlitebecause WAL checkpoints sync withfsync(), which does not flush the drive cache. Julius prescribed this fix in triage: after WAL, runPRAGMA checkpoint_fullfsync = ON, and leave ordinaryfullfsyncoff.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 becausefullfsyncstays off. WhereF_FULLFSYNCis absent, the pragma is a no-op.Fixes pingdotgg#13544
UI Changes
None.
Checklist