Files
glpi-neural-brain/CHANGELOG-SQLITE-STARTUP-FIX.md
jbergner b4388d1ebc
All checks were successful
release-tag / release-image (push) Successful in 2m30s
Update 6 SQLite
2026-08-05 05:23:43 +02:00

1.6 KiB

SQLite startup fix

Problem

Some installations aborted during graph.Open with an opaque modernc SQLite error similar to:

SQL logic error: out of memory (1)

The original startup path applied a 64 MiB SQLite page cache, a 256 MiB mmap window and temp_store=MEMORY while the connection was being opened. Those settings are unnecessary because the live graph and embeddings already reside in Go memory. The DSN-based PRAGMA list also made it impossible to identify which startup step failed.

Changes

  • Open SQLite using a plain absolute filename.
  • Verify that BRAIN_DATA_DIR exists, is a directory and is writable before opening SQLite.
  • Reject a graph.db path that is accidentally a directory.
  • Apply PRAGMAs individually with step-specific error messages.
  • Use conservative storage defaults:
    • cache_size=-8192 (approximately 8 MiB)
    • mmap_size=0
    • temp_store=FILE
    • WAL, synchronous=NORMAL, foreign keys and a 5-second busy timeout remain enabled.
  • Persist and report the journal mode actually selected by SQLite.
  • Add the dependency checksums to go.sum and copy both go.mod and go.sum in the Docker dependency layer.

Recovery

Because this is a staging-only database, remove files left by a failed first start before rebuilding:

docker compose stop brain
docker compose run --rm --no-deps --entrypoint sh brain -c '
  rm -f /app/data/graph.db /app/data/graph.db-wal /app/data/graph.db-shm
'
docker compose up -d --build --force-recreate brain

If startup still fails, the new error includes the exact phase, for example an unwritable data directory or a failed WAL configuration.