libpod: switch sqlite state backend to WAL mode #29733
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 207 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.319
Real PR Conversation Timeline
1 comments
"Review active on #29733"
general
weight: 0.35
AboEl3iz
Fixes #29721
Under heavy container churn, the SQLite state DB can get corrupted with "database disk image is malformed" due to page 1 freelist header conflicts under the default rollback journal mode (#29721).
To address this:
Enable WAL Mode: Set _journal_mode=WAL in the SQLite connection string on local filesystems. This avoids writing directly to page 1 on every transaction and relies on SQLite's shared-memory locking.
Clean Truncation: Run a best-effort PRAGMA wal_checkpoint(TRUNCATE) on SQLiteState.Close().
Network Filesystem Detection: Added isNetworkFilesystem() pre-check. SQLite WAL mode requires POSIX mmap for -shm sidecar files, which network filesystems do not support. On Linux, we inspect unix.Statfs magic numbers (NFS, CIFS, SMB, AFS); on FreeBSD, we check unix.Statfs type prefixes (nfs, smbfs, afs). If a network filesystem is detected, WAL mode is bypassed automatically to keep the database fully operational.
Runtime Fallback Verification: Added verifyJournalMode() post-open query (PRAGMA journal_mode;). If WAL mode was requested but SQLite silently kept delete mode (e.g., FUSE-over-NFS mounts), log an informational warning and continue safely in rollback mode instead of failing.
Unit Tests: Added regression tests verifying WAL mode enablement (TestSqliteJournalModeWAL), silent fallback handling (TestSqliteVerifyJournalModeFallback), and local directory detection (TestIsNetworkFilesystemLocalReturnsFalse).
``
release-note``Switched SQLite state database to WAL (Write-Ahead Logging) mode to prevent database corruption under high concurrency, with automatic fallback for network filesystems.