← Back to Pull requests

libpod: switch sqlite state backend to WAL mode #29733

Open
unknown opened this pull request with 207 lines diff across 2 files
View on GitHub
unknown unknown commented on Sep 08, 2026 10:30 UTC
Author

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.
``

Diff: 207 lines (+155 / -52) across 2 files Reviewer: AboEl3iz Review duration: 44762m
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
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
44%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 44.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 43.4% (MEDIUM) · Higher = larger blast radius
43.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 44.7% · Lower = rushed or shallow review
44.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 24.0% · Safe to merge
24.0%