claude-memory/graph/fixes/fix-document-sqlite-synchronous0-pragma-in-paper-dynasty-dat-8028ae.md

1.6 KiB

id type title tags importance confidence created updated relations
8028aeb5-d922-49aa-b0e6-fbc1cce35484 fix Fix: Document SQLite synchronous=0 pragma in paper-dynasty-database
paper-dynasty
sqlite
peewee
documentation
fix
python
db_engine
0.5 0.8 2026-03-04T01:32:49.610296+00:00 2026-03-04T01:32:51.174263+00:00
target type direction strength edge_id
04e57a23-0a20-49d6-8c5a-2fa5fc4e55b5 RELATED_TO outgoing 0.72 776cac00-9382-4283-a294-392d70259109
target type direction strength edge_id
d36a86f0-8183-4c94-8d63-0be65d3fd63a RELATED_TO outgoing 0.71 3aad9a04-dea1-4cf9-9c2d-51b794ee83df
target type direction strength edge_id
5ae1bf6e-1e1c-4486-8a4d-10afd9e42189 RELATED_TO outgoing 0.71 029ebb20-fd95-4b65-856b-e5492a6a755c

Problem

app/db_engine.py:36 had pragmas={"synchronous": 0} with no explanation. synchronous=0 (OFF) skips fsync on writes — fast but risks DB corruption on hard crash.

Context

  • SQLite branch is dev-only; production uses PostgreSQL (DATABASE_TYPE env var)
  • WAL journal mode (journal_mode=wal) partially mitigates the corruption window
  • Trade-off is acceptable in dev (data loss tolerable, write speed prioritised)

Solution

Added a block comment above the SQLite SqliteDatabase(...) call explaining:

  • synchronous=0 behaviour and crash-corruption risk
  • Why it's acceptable in dev (not used in production)
  • How WAL mode reduces (but doesn't eliminate) the risk

Files Changed

  • app/db_engine.py — comment at SQLite branch (line ~33)

PR

cal/paper-dynasty-database#49 (issue #20)