Repository navigation
[PR] fix(#5236): sessions rm must not full-VACUUM under a live foreign writer - #5330
ranxianglei wants to merge 4 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11039-pr.5330.d842c36This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5330.tgz
npm install -g packageInstall instructions are refreshed on each push. |
|
(ai: vllm-qwen/qwen3.8-27b) CI 状态说明:首跑三条红全部为继承性 master 失败,与本 PR diff 无关——
|
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——与 #4612/#5236 同属「活的外写者下 full-VACUUM 饿死共驻实例」机制家族,但 #4612 只覆盖了 gc 侧三个守卫位(runGc CLI 拒绝、admin 面板 409、store.gc 内部);本 PR 修的是 owner 裁决 3a6ab62 点位审计里唯一漏网的第四处 runRm,是本家族的收尾修复,跟踪 issue 即 #5236。 标签:bug、scope/storage、p2(存储车道 CLI 缺陷;特定并发条件下共驻实例写入被饿死,有 --no-vacuum 绕行,无数据丢失 → p2 非 p1)。 代码审查结论(独立重审,非复读 issue):
CI 现状(head f97b257,已 merge origin/ci-fixes 0371089):
八问:
收工判定:代码与测试达到可合并标准;当前两条红均为继承性 master 门禁失败(根因与修法证据已交 #4599 哨兵),待 ci-fixes 收敛后重跑转绿即可合并——本 PR 侧无需再做任何改动。 |
f97b257 to
24bfdb0
Compare
…ES (PR #5330 red CI) The suite spawns one bare `node -e` dummy child (live PID holder for the <db>.lock fixtures); SPAWN_RE matched it but it was never registered, so the pretest tripwire aborted all 11 test shards before any test ran (run 42962029584). Concurrency reviewed per #1248: no ports bound, no network I/O, mkdtemp-isolated per test — same shape as the #4612/#5046-B entries; appended last so existing slot indices are untouched.
(ai: vllm-qwen/qwen3.8-27b) CI lane attempt 1/3 — conflict resolved AND the red-CI root cause found and fixed this run. Summary of everything done: 1. Conflict resolution. The branch ( 2. Red-CI root cause (found while waiting for the rerun). All 11 3. Fix. Independent labeled commit Live status honestly stated: the mirror check-cache still reflects the previous head (poller lag); the fresh run on 八问(中文结构化结论)
判定:冲突已清( |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Status update (full run summary is in my previous comment above): conflict resolved via rebase onto master tip |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI lane run — verified live, no action was needed this time. The "merge state: dirty" in the trigger is stale mirror data predating last run's rebase; live sources say otherwise: Verified in THIS run (not from memory):
So this run: zero git operations, zero pushes, zero new commits — the blockers were already cleared by last run ( 八问(中文结构化结论)
判定:PR 当前唯一待办 = 最后一个 test 分片跑完出结果(0 failed / 1 in_progress);若绿即可合并,若红下轮按签名分账。本轮无需 owner 决策。 |
[ework] CI fix verified green ✓ |
2 similar comments
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
4932575 to
53f49f5
Compare
…ES (PR #5330 red CI) The suite spawns one bare `node -e` dummy child (live PID holder for the <db>.lock fixtures); SPAWN_RE matched it but it was never registered, so the pretest tripwire aborted all 11 test shards before any test ran (run 42962029584). Concurrency reviewed per #1248: no ports bound, no network I/O, mkdtemp-isolated per test — same shape as the #4612/#5046-B entries; appended last so existing slot indices are untouched.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI lane run — this time the dirty state was REAL and is now resolved. Summary of everything done: 1. Verified live (not from memory). GitHub API: 2. Rebase + conflict resolution. Rebased onto master tip 3. Verification on the rebased tree. LIVE_FILES: 67 entries, existence check OK, tripwire scan 0 offenders; 4. Push. Force-with-lease 5. Risk note, honestly stated. The previous head 八问(中文结构化结论)
判定:冲突已清( |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI lane run — the one red shard is a known flake, not a defect in this PR. Verified and handled: 1. Re-verified live first (per policy). Mirror cache was stale (snapshot taken at the job's start second), so I confirmed via a single job read: 2. Root cause from the job log (single fetch). Exactly 1 of 2740 tests failed: 3. Not this PR's fault. The PR diff touches 4. Action taken. Triggered Remaining / risk: the rerun verdict is outstanding (in flight now). Risk while waiting: none functional — the test asserts a real invariant, so if it reproduces deterministically the rerun will surface it and the escalation path is already defined. 八问(中文结构化结论)
判定:红项已定性为在档 flake 并触发重跑,等重跑判决;若同签名再红将按协议升级深挖,届时可能需要 owner 决策(测试预算/负载硬化)。本轮无需 owner 决策。 |
[ework] CI fix verified green ✓ |
53f49f5 to
98789cc
Compare
…ES (PR #5330 red CI) The suite spawns one bare `node -e` dummy child (live PID holder for the <db>.lock fixtures); SPAWN_RE matched it but it was never registered, so the pretest tripwire aborted all 11 test shards before any test ran (run 42962029584). Concurrency reviewed per #1248: no ports bound, no network I/O, mkdtemp-isolated per test — same shape as the #4612/#5046-B entries; appended last so existing slot indices are untouched.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Conflict resolved — branch rebased onto current master, force-pushed. This run, verified against live sources before touching anything:
(Operational note: the workdir had been reset, so my first rebase attempt was a no-op on a branch that never carried the PR commits; I reset the local branch to the remote PR head and redid the rebase properly.) 中文八问
判定:冲突已解,分支可合并;新 head 98789cc 的 CI 运行中,未断言绿;若红,下轮继续处理。 |
ranxianglei
left a comment
There was a problem hiding this comment.
APPROVE — correct, minimal, well-tested; closes the runRm gap left by #5236 / owner ruling 3a6ab62.
What it does
runRm(bili sessions rm) now checksstore.unifiedActiveWriter()before the shrink — the same source of truth asrunGc's refusal (#4612).- Live foreign writer ⇒ skip ONLY the shrink up front, with an actionable pid-named note; the deletion (short txn) still commits.
- No-writer and
--no-vacuumpaths unchanged; the JSON lane carriesvacuumed=false+vacuumNote.
Why it's correct
unifiedVacuum("full")(src/persist.ts:2456) has no internal guard, so the per-call-site guard is necessary, not redundant — consistent with the four full-VACUUM sites (runGc CLI, admin panel,store.gc, runRm).- The guard fires on
unifiedActiveWriter()(src/persist.ts:2357→src/storage/store.ts:786-802): the union of the open-timeforeignLockHolder(re-validated for liveness) and a fresh read of<db>.lockpointing at another live pid. - Deletion is committed BEFORE the vacuum block (
src/storage-maintenance.ts:125), so the rm always succeeds; only the expensive shrink is skipped.
Tests
tests/issue5236-rm-vacuum-writer-guard.test.ts(new): positive gate (live dummy writer ⇒ skip + pid note + deletion-committed proof + JSON honesty) and two negative gates (no writer ⇒ vacuum runs; dead holder ⇒ vacuum runs). Follows the #3617 both-directions discipline; meaningful assertions, not tautologies.scripts/live-files.mjs: registers the new suite for the SPAWN_RE tripwire (the test spawns a dummy child). Correct.
Behavior change (disclosed in PR body)
- OLD:
sessions rmwith a live foreign writer attempted a full VACUUM anyway → either won the lock and starved the co-resident proxy, or lost the race with SQLITE_BUSY. - NEW: deterministic up-front skip with an actionable pid-named note; deletion always commits.
No regressions
No-writer / --no-vacuum / legacy paths byte-identical. Single-module diff; no kernel/config/wire/version touch.
One pre-existing observation (raised separately as 🔶 需要决策, NOT a blocker on this PR)
The shared <db>.lock "last-opener-wins" discipline can be clobbered by an intermediate CLI invocation, defeating the unifiedActiveWriter() guard (and thus both runGc and runRm). Pre-existing (equally affects #4612's runGc), design-level, out of scope here — see the separate 🔶 需要决策 comment below.
8问
- 是什么问题:
bili sessions rm删除会话后会对 index.db 做全量 VACUUM;当另一进程(常驻代理)正写同一 index.db 时,全量 VACUUM 长时间持写锁,饿死共驻写者(#5236/#4612 同源)。runGc有守卫,runRm漏了。 - 什么原因导致的:
unifiedVacuum("full")(persist.ts:2456)无内部守卫,每个调用点须自查unifiedActiveWriter();runGc查了(#4612),runRm在 #5213 降级语义落地时漏查。 - 影响范围与严重程度:触发条件 = 同一 index.db 有活跃外部写者时执行
sessions rm;严重度 = 饿死共驻代理(特定条件下有问题),删除本身不受影响(短事务先提交)。 - 怎么修复的:
runRm在 shrink 前查unifiedActiveWriter()(与runGc同一事实源);活跃外部写者 ⇒ 只跳 shrink + 带 pid 可操作提示,删除照常提交;JSON 车道带vacuumed=false+vacuumNote。 - 是否有回归问题:无。无写者 /
--no-vacuum/ legacy 路径字节级不变;单模块 diff,不碰 kernel/配置/线协议/版本。 - 是否破坏缓存:不涉及(纯存储维护路径,不碰压缩/缓存/重试/去重)。
- 是否改了设计方向:不涉及(沿用 owner 裁决 3a6ab62「按操作守卫」防线,补齐
runRm这个漏掉的调用点)。 - 是否引入了新的配置:不涉及(无新 env/config/默认值)。
|
(ai: vllm-qwen/qwen3.8-27b) 🔶 需要决策 发现(非本 PR 引入,设计级,需 owner 拍板):共享的 机制(已逐行核对
关键事实:lockfile 只在 影响面:同时削弱 这是既有问题,非本 PR 引入:本 PR 是严格改进(在原本无守卫的 选项:
推荐:A(接受为已知局限)+ 文档注明。理由:本 PR 与 #4612 已覆盖「直接 代理→全量 VACUUM」的常见场景;中间 CLI 覆盖是较少见的时序,且 lockfile 本就是 fail-open 设计。B/C 是更大的设计改动,应独立立项、独立评估,不塞进本 PR。若 owner 认为该场景足够常见/严重,再拍板 B 或 C。 请 owner 拍板:A / B / C(或其它)。 |
|
(ai: vllm-qwen/qwen3.8-27b) Review 完成:结论 APPROVE(代码正确、测试到位、无回归;agent 不能自批自己的 PR,正式 approval 待 owner 点按)。另发现一处既有设计级弱点( |
(ai: vllm-qwen/qwen3.8-27b) 这条 🔶 需要决策 是我(review agent)上一条评论的回显,不是 owner 的新输入——A/B/C 仍等 @ranxianglei 明确拍板,我这边不代决、不预设。 重申推荐:A(接受为已知局限 + 文档注明)。理由一句话:该弱点是既有的(同样影响 #4612 已合入的 该弱点不阻塞本 PR:本 PR 是严格改进(给原本无守卫的 |
[ework] CI fix verified green ✓ |
…reign writer holds index.db After owner ruling 3a6ab62 (a live second writer never blocks startup), per-operation guards are the sole defense against an O(db-size) exclusive VACUUM starving a co-resident instance. storage gc kept its #4612 up-front refusal (CLI + panel endpoint); sessions rm's default full vacuum had none — while a proxy held index.db it could win the exclusive lock and starve that proxy's writes across the whole rewrite. runRm now checks store.unifiedActiveWriter() (same source of truth as runGc's refusal) before the shrink: a live foreign writer ⇒ skip ONLY the shrink with an actionable pid-named note; the deletion is a short transaction and stays committed (same graceful shape as the pre-existing SQLITE_BUSY path). No-writer and --no-vacuum paths unchanged. All four full-VACUUM sites are now guarded: runGc, runRm, admin.ts panel endpoint (#4612 409), store.gc.
…ES (PR #5330 red CI) The suite spawns one bare `node -e` dummy child (live PID holder for the <db>.lock fixtures); SPAWN_RE matched it but it was never registered, so the pretest tripwire aborted all 11 test shards before any test ran (run 42962029584). Concurrency reviewed per #1248: no ports bound, no network I/O, mkdtemp-isolated per test — same shape as the #4612/#5046-B entries; appended last so existing slot indices are untouched.
98789cc to
ad41155
Compare
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved — branch rebased onto current master, force-pushed. Verified against live sources before touching anything:
The prior head was fully green; the only delta is the union of the LIVE_FILES registrations plus master's own 139 commits, so the rerun is expected green — but I am not asserting green until the checks land. No design decisions needed, nothing escalated. 中文八问
判定:冲突已清( |
(ai: vllm-qwen/qwen3.8-27b) Red CI diagnosed — this is an inherited master-level Windows-specific regression, NOT this PR's diff. Escalated to #4599; not fixing in-branch per the CI-coordination policy. Re-verified live before acting: the failing check is What failed. The only failure in the whole phase (2256 tests / 2248 pass / 1 fail / 7 skip) is Why it's not this PR. This PR's diff is Action. Per the CI-coordination policy (owner 2026-10-24), an inherited master-level failure is not fixed in the PR branch ("禁止在自己分支重复修 master 级失败"). 中文八问
判定:红 CI 已定性为继承性 master 级 Windows 回归(非本 PR 所致),已上报 #4599;本分支无需改动,等 master 修复后重触发即绿。本轮无代码推送。 |
(ai: vllm-qwen/qwen3.8-27b) CI Lane — PR #5330 Red-CI Fix (attempt 1/6) What I did this run:
Expected outcome: the fix 中文八问
判定:修复已推送(merge commit |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Re-review after rebase — APPROVE (verdict stands).
The head moved 98789cc52 → d59f6ae55 solely because the branch was merged with current master (548e396022). The PR's own diff is byte-identical to the previously-reviewed head:
src/storage-maintenance.ts— identicaltests/issue5236-rm-vacuum-writer-guard.test.ts— identicalscripts/live-files.mjs— the PR's ownissue5236registration (line 157) is intact; the only delta vs the old head is master's unrelatedupstream-ca-default-trust.test.tsline pulled in by the rebase.
CI on the new head d59f6ae55 is now fully green: 18 success, 12 skipped, 0 fail (the test shards still queued at first review have completed).
No kernel/ change, no config surface, no wire, no version touch. The full correctness / registry / 8-question analysis from my first review (on 98789cc52) applies unchanged. The pre-existing <db>.lock last-opener-wins clobber gap remains a 🔶 需要决策 (options A/B/C) pending the owner's ruling — it is not a blocker on this PR.
8问(中文,复述判定,内容未变)
- 是什么问题:
bili sessions rm默认会做整库 full VACUUM,在长驻代理正持有index.db写锁时会长时间卡死(#5236/#4612)。 - 什么原因导致的:
runRm缺少runGc已有的unifiedActiveWriter()前置守卫(unifiedVacuum内部无守卫,须逐点加)。 - 影响范围与严重程度:特定条件(有活跃外部写者时执行
sessions rm)下 rm 卡死 / 影子 3 连败;删除本身(短事务)不受影响。 - 怎么修复的:
runRm在 shrink 前查store.unifiedActiveWriter();有活跃外部写者 ⇒ 只跳过 shrink 并给出带 pid 的说明;删除照常提交;无写者 /--no-vacuum路径不变;JSON 车道带vacuumed=false + vacuumNote。 - 是否有回归问题:无——无写者、
--no-vacuum、legacy 路径均未变;与runGc守卫同源一致。 - 是否破坏缓存:不涉及缓存 / 重试 / 游标 / 去重键。
- 是否改了设计方向:不涉及——沿用 #4612 的逐操作守卫设计,未改架构。
- 是否引入了新的配置:不涉及——无新 env / config / 默认值。
判定:APPROVE(agent 不能自批自己的 PR,正式 approve 点击留待 owner)。
(ai: vllm-qwen/qwen3.8-27b) Re-review of #5330 on the new head |
# Conflicts: # scripts/live-files.mjs
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Re-review after rebase (3rd) — APPROVE (verdict stands).
The head moved d59f6ae55 → 99bfd2a4b solely because the branch was merged with current master (1e357bf2d66). The PR's own diff is byte-identical to the previously-reviewed head:
src/storage-maintenance.ts— identicaltests/issue5236-rm-vacuum-writer-guard.test.ts— identicalscripts/live-files.mjs— the PR's ownissue5236registration (line 157) is intact; the only delta is master'sstorage-integrity-cache.test.tsregistration (#7156) pulled in by the rebase.
Master interaction checked, not just assumed. The rebase pulled in master's #7156 (storage-corruption / WAL-TRUNCATE-under-live-peer work), which touches the same storage files the PR's guard depends on. Verified:
unifiedActiveWriter()(src/persist.ts) and theactiveForeignWriter()definition (src/storage/store.ts:892) are unchanged.- The core lock discipline is intact:
open()still overwrites<db>.lockwith own pid (store.ts:671);close()still unlinks only whenforeignLockHolder === null(store.ts:870). - #7156 only added call sites for
activeForeignWriter()(gating WAL-TRUNCATE and integrity-cache refresh under a live peer) plus a boot-timeforeignLockPidAtBootcapture — i.e. it consumes the same live-foreign-writer signal the PR'srunRmguard uses. Complementary, not conflicting.
CI on 99bfd2a4b (mirror cache, fetched_at 2026-11-20T05:16:45Z): no failures — 14 success, 11 skipped, 5 still in_progress at read time. The prior head d59f6ae55 was fully green (18 success / 12 skipped / 0 fail); the residual in_progress shards are a master-integration confirmation (the PR content itself is unchanged and was green).
No kernel/ change in the PR's own diff, no config surface, no wire, no version touch. The full correctness / registry / 8-question analysis from my first review applies unchanged. The pre-existing <db>.lock last-opener-wins clobber gap remains a 🔶 需要决策 (A/B/C) pending the owner — not a blocker on this PR.
8问(中文,PR 自身内容未变,复述判定)
- 是什么问题:
bili sessions rm默认整库 full VACUUM,在长驻代理持有index.db写锁时长时间卡死(#5236/#4612)。 - 什么原因导致的:
runRm缺少runGc已有的unifiedActiveWriter()前置守卫(unifiedVacuum内部无守卫,须逐点加)。 - 影响范围与严重程度:特定条件(有活跃外部写者时执行
sessions rm)下 rm 卡死 / 影子 3 连败;删除本身(短事务)不受影响。 - 怎么修复的:
runRm在 shrink 前查store.unifiedActiveWriter();有活跃外部写者 ⇒ 只跳过 shrink 并给出带 pid 的说明;删除照常提交;无写者 /--no-vacuum路径不变;JSON 车道带vacuumed=false + vacuumNote。 - 是否有回归问题:无——无写者 /
--no-vacuum/ legacy 路径均未变;与runGc守卫同源一致;master #7156 对存储层的改动经核对本 PR 依赖的activeForeignWriter()定义与锁纪律均未变(互补而非冲突)。 - 是否破坏缓存:不涉及缓存 / 重试 / 游标 / 去重键。
- 是否改了设计方向:不涉及——沿用 #4612 的逐操作守卫设计,未改架构。
- 是否引入了新的配置:不涉及——无新 env / config / 默认值。
判定:APPROVE(agent 不能自批自己的 PR,正式 approve 点击留待 owner)。
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Resolved the merge conflict and pushed the final head. This run: the PR had drifted from master (master advanced 20+ commits since the last rebase, including the #7156 storage-corruption/dual-writer fixes and a kernel bump 0.0.199→0.0.200). Merging Also note: the local working copy had been left out of sync (reset to a master commit Verified locally on the merged tree:
Pushed Live state (mirror cache, fetched 05:03:50Z): sha 中文八问
结论:冲突已解决、最终 head 已推送、CI 正在新 head 上运行。无设计决策、无授权门禁。等待 CI 结果。 |
(ai: vllm-qwen/qwen3.8-27b) Re-review of #5330 on the new head |
[ework] CI fix verified green ✓ |
Refs #5236 — post-merge supplement to PR #5213 / owner ruling
3a6ab628(via PR #5294).What
bili sessions rm <id>defaults to a full VACUUM after the deletion. While another bili process (e.g. a running proxy) holds index.db, that full VACUUM can win the exclusive write lock and starve the other instance's writes across the whole O(db-size) rewrite — exactly the hazard class #4612 fixed forstorage gc --vacuum full. After the owner ruling 3a6ab62 (2026-10-31: a live foreign writer never blocks startup), per-operation guards are the sole defense line — and runRm was missing its guard while runGc kept its (#4612).Found while closing out #5236 on current master (caaab21): the ruling's commit message names runGc's
store.unifiedActiveWriter()guard as the surviving enforcement point; a call-site audit shows four full-VACUUM sites, three already guarded (runGc CLI refusal, admin.ts panel 409, store.gc internal), one not (runRm).Fix
runRm checks
store.unifiedActiveWriter()before the shrink (same source of truth as runGc's refusal): live foreign writer ⇒ skip ONLY the shrink up front, with an actionable pid-named note (shrink skipped: another process (pid N) is actively writing index.db — … or run 'bili storage gc --vacuum incremental'). The deletion itself is a short transaction and stays committed — same graceful shape as the pre-existing SQLITE_BUSY path in the same function. No-writer and--no-vacuumpaths unchanged. JSON lane carriesvacuumed=false+vacuumNote(fields pre-existed; no schema change).Behavior change (old → new)
sessions rm <id>with a live external writer attempted the full VACUUM anyway — either it won the exclusive lock and starved the co-resident instance's writes for the whole rewrite (minutes on multi-GB dbs), or it lost the race with SQLITE_BUSY and skipped the shrink with a generic "database busy" note.Tests
New
tests/issue5236-rm-vacuum-writer-guard.test.ts: positive gate (skip + pid-named note + deletion-committed proof + json honesty) and both negative gates per #3617 discipline (no writer ⇒ vacuum runs; dead holder ⇒ vacuum runs). Local: typecheck clean, suite 3/3 green on caaab21. Full-suite verdict = CI on this head.Single-module scope (
src/storage-maintenance.ts+ one new test file); no config surface, no kernel/, no wire changes, no version touch.