← Back to Pull requests

fix(storage): initialize vacuum mode for concurrently created databases #6136

Open
unknown opened this pull request with 306 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 17, 2026 07:35 UTC
Author

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_count before schema creation instead, and configure lock waiting before this inspection in the standalone runtime opener. Already initialized databases keep their existing mode, including NONE databases 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

  • Built @maka/core and @maka/storage; storage typecheck passed.

  • Full storage test suite: 1,666 passed, 8 skipped, 0 failed (1,674 total).

  • SQLite recovery concurrency suite with MAKA_STORAGE_STRESS=1: 13 passed, including 12 rounds of fresh-database concurrent initialization.

  • Changed-file Biome lint/format checks, staged ASF header check, protocol guard, and diff whitespace check passed.

  • Regression control: both new empty-file cases fail against main with auto_vacuum = 0 instead of 2; all three focused cases pass with this fix, including the initialized-NONE preservation case.
  • AI use

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • 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 Codex trailer.

    Checklist

  • Tests cover the change and fail without it

  • Lint, format, typecheck and the affected suites pass locally
  • Does this PR entail a change in behavior?

  • Yes — described under Summary above

  • No
  • <details>
    <summary>点击展开中文</summary>

    概要

    多个进程同时打开新的 SQLite 数据库时,一个进程可能先创建了空文件,但还没有建立数据库结构。另一个进程过去会根据“文件已经存在”跳过增量回收模式的初始化,导致新库使用错误的空间回收模式。

    现在在创建结构之前检查 SQLite 的 page_count,并让独立 runtime 打开入口先配置锁等待。已经初始化的数据库继续保留原有模式,包括没有业务表但已经初始化为 NONE 的数据库。回归测试覆盖 runtime 和 operational-state 两个入口。

    此修复从 #6091 拆出,便于独立审查,与使用统计热力图无功能依赖。

    验证

  • core/storage 构建、storage 类型检查通过。

  • 完整 storage 套件:1,666 项通过、8 项跳过、0 项失败。

  • SQLite 多进程压力测试 13 项通过,其中新库并发初始化重复了 12 轮。

  • 两个空文件回归用例在 main 原实现上均复现错误;修复后三个聚焦用例全部通过,其中包含保留已有 NONE 模式的用例。

  • 变更文件的格式与 lint、许可证头、协议及空白检查通过。
  • </details>

    Diff: 306 lines (+229 / -77) across 3 files Reviewer: Astro-Han Review duration: 182m
    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
    0.40
    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%
    46%
    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.343
    Real PR Conversation Timeline
    1 comments
    "Review active on #6136"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.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: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    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: 46.7% · Lower = rushed or shallow review
    46.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: 21.4% · Safe to merge
    21.4%
    Repository