Skip to content

[Bug]: macOS SQLite WAL checkpoints skip fullfsync barriers #99066

Description

@ooiuuii

Summary

OpenClaw configures SQLite databases for WAL mode and periodic checkpoints, but macOS connections do not enable SQLite's checkpoint fullfsync barrier. On macOS, that leaves WAL checkpoint durability weaker than it needs to be during local store checkpointing.

Real environment observed

  • Repository: openclaw/openclaw
  • Branch/version inspected: main at 5bcd25f0fb
  • Source path: src/infra/sqlite-wal.ts
  • Environment used for focused proof: Windows 11 dev checkout with mocked process.platform branches in Vitest

User-visible symptom

Users are unlikely to see a normal runtime error. The impact is durability: on macOS, SQLite WAL checkpoints can run without the platform-specific fullfsync barrier, increasing the risk that recently checkpointed local state is less durable across abrupt power loss or OS crashes.

Source-level repro on current main

  1. Inspect configureSqliteWalMaintenance.
  2. It enables PRAGMA journal_mode = WAL; and PRAGMA wal_autocheckpoint = ...;.
  3. There is no macOS branch that enables PRAGMA checkpoint_fullfsync = 1; before automatic or explicit WAL checkpoints are configured.

Expected behavior

On macOS, WAL setup should enable SQLite checkpoint fullfsync so checkpoints use the stronger macOS flush barrier when SQLite supports it.

Actual behavior

WAL setup configures journal mode and checkpoint cadence, but skips the macOS checkpoint fullfsync PRAGMA.

Scope / non-goals

This is scoped to SQLite WAL maintenance setup. It does not change transaction retry logic, checkpoint cadence, rollback mode on unsupported filesystems, or non-macOS behavior.

Proposed fix

After enabling WAL mode, set PRAGMA checkpoint_fullfsync = 1; only on macOS. Treat unsupported PRAGMA errors as non-fatal so older SQLite builds or unusual environments still proceed with normal WAL setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions