Repository navigation
[PR] fix(storage): close the sqlite handle when quick_check throws on a corrupt header (#4357) - #4358
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.5247-pr.4358.3b8edacThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4358.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 与已关闭的 #4347 / #4338 同症状家族(Windows 上 corrupt-db 测试 teardown EBUSY unlink),但机制不同:#4347/#4338 假设是外部 AV/锁 flake(已由 #4350 有界重试覆盖),本 PR 是 bili 进程自身在 quick_check 抛错路径泄漏 sqlite 句柄——同一 runner 确定性复现、Linux 侧 fd 可钉,与外部锁无关。两者并存不冲突。 标签: 审核进展(进行中):
稍后补完整八问结论。 |
d8352db to
c71a93c
Compare
…rrupt header (#4357) #4175 put PRAGMA quick_check between openSqliteDatabase() and the existing close-on-error catches. On a corrupt header the constructor succeeds (handle open) and quick_check .all() throws 'file is not a database' from the statement itself — a path with no db.close(). The #2771 degrade then stays functionally correct but leaks the handle: Linux unlink-open masks it, while Windows deterministically burns the whole tmp-rm retry ladder on unlink EBUSY (every windows CI leg since #4175, root cause of the corrupt-db sub-family of #4347, reproduced via /proc/self/fd on Linux). Rebased onto current master (replaces d8352db): the corrupt-index proof now runs in a spawned child (#4338, tests/corrupt-index-child.ts), so the portable fd guard lands there as a named check (fdGuard): after the degraded construction and final close, no open fd may reference the index dir on Linux (/proc/self/fd). The rename guards are POSIX no-ops, so this is the only deterministic detector on Linux; Windows is covered end-to-end by the teardown rmrf no longer hitting EBUSY. Negative control verified: reverting the store.ts fix makes fdGuard fail naming the leaked index.db.
c71a93c to
1369811
Compare
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决,rebase 到最新 master 并验证后推回本分支。 新 head
结构化八问(独立审核,非复读 issue):
验证(本地定向跑,全量交 CI):
判定:根因成立、修复打到核心、双向回归钉住、diff 干净(2 文件 +43/-2,每行相关)——可合,等新 head |
(ai: vllm-qwen/qwen3.8-27b) 补一条状态:新 head |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.763-master.389de69 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Fixes #4357
一句话:损坏头的 index.db 在 quick_check 抛错路径上泄漏 sqlite 句柄——Windows 上删不掉该文件(CI 全部 windows 车道确定性红 + 用户无法按 #2771 指引重置索引),Linux 被 unlink-open 语义掩盖。
改动(已 rebase 到当前 master,替代原 head d8352db)
src/storage/store.ts:quick_check 的 prepare/all 包上 try/catch,抛错时recordIntegrityOutcome(false)+db.close()后原样 rethrow。降级行为([Bug][storage] corrupt index.db bricks SessionStore construction in shadow/full mode (violates the sidecar never-breaks-legacy policy) #2771)零变化,只是不再漏句柄。tests/corrupt-index-child.ts:corrupt-index proof 现已在子进程中运行(Windows CI lane stuck red: corrupt-index.db tests cannot delete their temp dirs (EBUSY) — blocks every PR merge #4338),可移植 fd 守卫以命名 check(fdGuard)落在子进程内——降级构造+最终 close 后,Linux 下/proc/self/fd里不允许有任何指向 index 目录的打开句柄。rename guard 在 POSIX 上是 no-op,fd 守卫是 Linux 侧唯一的确定性检测器;Windows 由 teardown rmrf 端到端覆盖。验证(rebase 后的 head 本地定向跑)
index.dbfd;修复后 0 个。fdGuard精确失败(open handle(s) into the corrupt index dir after close: .../index.db);带修复tests/storage-engine-proofs.test.ts12/12 绿。tests/web-storage-banner.test.ts5/5 绿(另一条 CI 失败测试,同一根因自愈)。npm run typecheck干净。时间线:399c8bc66d(最后绿)无 quick_check → 1da8eca(#4175)引入 → 9e2d217 起所有 windows 车道红。该子家族与 #4347 的 AV/外部锁 flake 是两回事;#4350 的有界重试机制保留,继续服务真 flake。