Repository navigation
[PR] storage: durability trio — open-time quick_check + online VACUUM INTO backup + second-process lockfile (#4175) - #4177
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.5126-pr.4177.4c06d38This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4177.tgz
npm install -g packageInstall instructions are refreshed on each push. |
The new durability suite spawns short-lived child processes (the lockfile test drives a real sibling pid), which trips the SPAWN_RE tripwire in scripts/run-ci-tests.mjs: every process-spawning suite must be listed in LIVE_FILES or all test shards die at start with exit 1 (observed on head 7d6a6e4, #4177). Concurrency reviewed per #1248: at most two ~1s-lived 'node -e setTimeout' children per test, stdio ignore, mkdtemp isolation, no ports — safe under --test-concurrency 4.
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复,但强相关。#4175 本身(可靠性三件套)是独立立项,无重复项;实现面与在途 PR #3965(corrupt index.db 自动隔离,Closes #3959)重叠——两者都往 标签:pr + scope/storage + p2(已打;理由:可靠性能力 PR 非缺陷报告不打 bug,核心存储域,严重程度随源 issue #4175)。 总体判断方向对、实现扎实、测试有牙(stake-first、gate 双向钉住 #3617、lockfile 用真实子进程、NOTADB 降级路径按 #2771/#2781 原样钉死)。代码与回归我逐项过完,没有发现阻断性问题。CI 六条 test lane 全红——不是这个 PR 的代码问题,根因已钉死并本地复现,见下。 CI 红的根因(中间态 master 产物,本地字节级复现)
本地验证(定向跑,全量交给 CI)在「PR+当前 master」合并树上:tests/storage-durability.test.ts 7/7;storage 家族(storage-unified / archive-gc / full-flip / acp-status / engine-bootstrap / web-sessions / reap-journal / maintenance-cli)113 过 / 0 挂;golden-storage-render 5/5。 协调请求:与 #3965 的顺序(owner 拍板)冲突面:同一 try 块 + 重复的文件组改名逻辑,应收敛成一个公共 helper。两个选项:
无论选哪个,垃圾头文件目前在本 PR 里走 legacy-only 降级(有意为之、测试已钉),只有并入 #3965 的被动分支后才进隔离路径——这点要在最终形态里确认一次。 小发现(非阻断,可顺手修或后续跟)
结构化八问
判定Hold,等两件事:(A) 分支更新到当前 master 重跑 CI 转绿(本次红与 PR 代码无关,rebase 即清);(B) owner 拍板与 #3965 的协调顺序(推荐 A:先合 #3965,本 PR rebase 复用其隔离 helper)。小发现 1–4 非阻断,可在 rebase 时顺手修或另行跟踪。 |
23c1d05 to
08b9795
Compare
…econd-process lockfile (#4175) The unified store is the single source of truth but shipped none of the reliability trio. quick_check runs BEFORE migrations (a corrupt file is never migrated against); on failure the shadow quarantines the file set (.corrupt-<ts>) and reopens fresh. backupInto produces a consistent online snapshot (VACUUM INTO — safe under active WAL writers) exposed via unifiedBackup + POST /__bili/storage/backup. A <db>.lock lockfile surfaces a live foreign pid (error log + wire + web banner, never a hard block); stale locks are taken over; close() releases the lock.
08b9795 to
1da8eca
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.738-master.aa198fe # this exact build
npm install -g billion-context@master # always the newest merged build
|
CI red found while verifying this PR: master merge aa198fe (#4177) added tests/storage-durability.test.ts without registering it in the process-spawning LIVE_FILES table, so the SPAWN_RE tripwire in scripts/run-ci-tests.mjs fails every test shard on any PR whose checkout includes current master (and master itself). Append at the end of the array: slot = index drives each file's zone port band, so mid-list insertion would renumber every later band.
#4177 landed the storage durability trio but its new suite spawns child processes without registering in scripts/live-files.mjs, so the #1248 SPAWN_RE tripwire fails every CI run — master aa198fe is red and every branch rebased onto it inherits the failure. Concurrency review: the suite only spawns `node -e setTimeout` probes (no port binding) and isolates data in mkdtempSync dirs; slot 31 / zone band 19811 is free. Fixes #4333. (cherry picked from commit 9759e3e)
Since #4177 the storage contract suites transitively import acp-kernel at runtime (backend -> store -> runtime-status -> knobs -> config), and tsx resolves it to kernel/dist — which this job never built. Mirror the prerequisite the main test matrix (run-ci-tests pretest parity) and ci-e2e-dsh.yml already carry. Fixes #4336.
Since #4177 the storage contract suites transitively import acp-kernel at runtime (backend -> store -> runtime-status -> knobs -> config), and tsx resolves it to kernel/dist — which this job never built. Mirror the prerequisite the main test matrix (run-ci-tests pretest parity) and ci-e2e-dsh.yml already carry. Fixes #4336. (cherry picked from commit 0f21448)
The lane installs with --ignore-scripts and runs the storage-backend suites directly, never building the in-repo components. Since the in-repo kernel (#2092), node_modules/acp-kernel/dist only exists after 'npm --prefix kernel run build'. #4177 (aa198fe) added a store.ts -> runtime-status.ts import that pulls the acp-kernel runtime chain into these tests' import graph via src/config.ts, so the lane has failed with ERR_MODULE_NOT_FOUND since its first run after that merge (master CI run 39803248052 at 2026-10-22T15:16Z; last green master run 399c8bc at 12:55Z). Reproduced locally: identical command passes on c1d7eab and fails identically on aa198fe. The main test job never hit this because scripts/run-ci-tests.mjs runs the pretest build first; mirror that build step here. Pre-existing master breakage, unrelated to this PR's diff.
) Since ranxianglei#4177 the storage suites transitively import acp-kernel at runtime (store.ts -> runtime-status -> knobs -> config); tsx resolves it to the built dist, so the mysql-contract job dies with ERR_MODULE_NOT_FOUND on a fresh runner. Same prerequisite the main test matrix already has via run-ci-tests' pretest step. Cherry-picked from ranxianglei#4334.
…tion alarm (Follows #4614) e83fc64 (#4685) rewrote this alarm line for the #4392 digest-shape-first wording and dropped the #4614 clause in the same edit, so every test lane failed tests/issue4323-drift-escalation.test.ts:193 ('alarm also names the single-writer repeating-rewrite producer') from the merge onward. Restore both producers in one line — digest-shape mismatch first (#4392), then the writer side: a second bili instance on one sessions dir (#394/#4177) or ONE host re-writing history slots below the ingest watermark (#4614).
What
Fixes #4175 — the unified store is the single source of truth but shipped none of the reliability trio: no corruption self-check, no online backup, no second-process detection (#3959/#3923 were exactly this class, with "delete index.db" as the only recovery).
1. Integrity self-check at open (
PRAGMA quick_check)UnifiedStore.openbeforemigrateSchema— a corrupt file is never migrated against.StorageIntegrityError; the shadow layer catches it, quarantines the file set (index.db/-wal/-shm→.corrupt-<ts>, same suffix discipline as session envelopes), and reopens fresh — JSON envelopes remain the recovery source (full mode re-imports organically).BILI_STORAGE_QUICK_CHECK=0for boot-time-sensitive huge deployments.integrityon the wire).2. Online backup (
VACUUM INTO)UnifiedStore.backupInto(dst)— SQLite's native consistent-snapshot backup, safe while WAL writers are active; refuses an existing target (a backup path is produced exactly once).SessionStore.unifiedBackup(dst?)→POST /__bili/storage/backup {dst?}(defaultsessionsDir/backups/index-<timestamp>.db);backuprecorded on the wire.3. Second-process-on-the-same-db detection
<db>.locklockfile (pid + boot time). A live foreign pid at open → one loud error log + wiresecondProcess+ web banner (zh/en); never a hard block — blocking would brick the second lane; the documented posture stays one instance per session dir (Multi-instance posture is undocumented, and "/__bili/replicas" means session checkpoints — not pod replicas #3633).close()releases the lock; same-process multi-store (test shape) never false-positives.Verification
tests/storage-durability.test.ts5/5: corrupt db → typed error; shadow open → quarantine + fresh reopen + post-quarantine ingest works; backup opens as a store with identical sessions + refuses overwrite; live foreign pid (real child process) reported / stale takeover / close removes lock; wire surfaces integrity/secondProcess/backup.BILI_STORAGE_QUICK_CHECKregistered), gen-config-docs coverage (env-only seed + regenerated docs), tsc 0.kernel-change: none