Repository navigation
Conversation
macOS fsync() does not flush the drive cache, so a power loss during a WAL checkpoint can persist b-tree pages that point at pages that never reached disk. Enable checkpoint_fullfsync in the shared persistence setup and on the direct state.sqlite connection in t3-sqlite-state, so checkpoint syncs use F_FULLFSYNC. Per-commit fullfsync stays off. Fixes pingdotgg#13544 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR changes SQLite checkpoint synchronization defaults for shared server persistence and the direct state CLI, improving macOS durability while potentially affecting checkpoint performance. The implementation is small and test-covered, but the product-default behavior change warrants human review. Notes:
You can add or adjust custom eligibility rules. Learn more. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pingdotgg/t3code/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughSQLite setup now enables ChangesSQLite checkpoint synchronization
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The durable-state connection paths enable full-sync checkpoints, and the other identified writers use disposable databases; no material user-data durability gap remains. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change requests stronger checkpoint durability without expanding database access or changing transaction boundaries. Risk is low, although actual power-loss protection depends on platform and filesystem behavior that was not validated here. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
What Changed
PRAGMA checkpoint_fullfsync = ONis now set, before any migrations or writes, in two places:apps/server/src/persistence/Layers/Sqlite.ts), right after WAL mode.state.sqliteconnection inapps/server/scripts/t3-sqlite-state.ts, which bypasses that setup.The pragma is per connection, so each path needs its own.
PRAGMA fullfsyncstays off.Why
On macOS,
fsync()does not flush the drive's write cache, and WAL checkpoints currently sync with plainfsync(). The maintainer triage on #13544 identified this missing checkpoint barrier as a corruption risk on power loss or hard reset.With the pragma on, SQLite uses
F_FULLFSYNCfor checkpoint syncs where the platform supports it. This is the fix requested there:fullfsync. It isn't needed for the checkpoint barrier, and it made commits about 28× slower in the reporter's disk-backed benchmark.F_FULLFSYNCdoesn't exist.F_FULLFSYNC, SQLite falls back to a plainfsync()(os_unix.c).migrate-dev-db.tsis unchanged, because it only rebuilds a throwaway worktree dev database.Fixes #13544.
Tests
Run on Windows 11 with Node 24.13.1:
vp test run src/persistence/Layers/Sqlite.test.ts scripts/t3-sqlite-state.test.tsinapps/server, 8 passed.PRAGMA checkpoint_fullfsyncback as1through the real initialized connections.0.vp lintandvp fmt --checkon the changed files, pluspnpm --filter t3 typecheck, pass.These tests only confirm the setting is applied. They don't exercise macOS
F_FULLFSYNCor reproduce power-loss corruption, and this change doesn't repair an already-corrupt database.Checklist
Written by Claude (Opus 5.5) in Claude Code and reviewed with Codex, directed by @SoroushRF.
🤖 Generated with Claude Code