fix(storage): initialize vacuum mode for concurrently created databases #6136
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 306 lines diff across 3 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.343
Real PR Conversation Timeline
1 comments
"Review active on #6136"
general
weight: 0.35
Astro-Han
Summary
When two processes open a new SQLite database, one can create its empty file before either creates the schema. The other opener previously treated file existence as proof of initialization and skipped incremental auto-vacuum, allowing the database to be created with the wrong reclamation mode.
Inspect SQLite's
page_countbefore schema creation instead, and configure lock waiting before this inspection in the standalone runtime opener. Already initialized databases keep their existing mode, includingNONEdatabases without application tables. Both runtime and operational-state openers are covered.Extracted from #6091 so the storage fix can be reviewed independently of the usage heatmap.
Verification
@maka/coreand@maka/storage; storage typecheck passed.MAKA_STORAGE_STRESS=1: 13 passed, including 12 rounds of fresh-database concurrent initialization.auto_vacuum = 0instead of2; all three focused cases pass with this fix, including the initialized-NONEpreservation case.AI use
Tool(s) and scope: OpenAI Codex extracted the existing fix from #6091, verified it against current main, ran validation, and prepared this PR. The commit retains its
Generated-by: OpenAI Codextrailer.Checklist
Does this PR entail a change in behavior?
<details>
<summary>点击展开中文</summary>
概要
多个进程同时打开新的 SQLite 数据库时,一个进程可能先创建了空文件,但还没有建立数据库结构。另一个进程过去会根据“文件已经存在”跳过增量回收模式的初始化,导致新库使用错误的空间回收模式。
现在在创建结构之前检查 SQLite 的
page_count,并让独立 runtime 打开入口先配置锁等待。已经初始化的数据库继续保留原有模式,包括没有业务表但已经初始化为NONE的数据库。回归测试覆盖 runtime 和 operational-state 两个入口。此修复从 #6091 拆出,便于独立审查,与使用统计热力图无功能依赖。
验证
NONE模式的用例。</details>