Repository navigation
test(mojo): PROBE 2 等 SIGKILL 死亡窗口结束再断言关闭诚实性 - #3076
Merged
Merged
Conversation
bun-test 偶发挂在 PROBE 2「a REPLACEMENT backend terminates the inherited survivor...」:destroySession 已对继承的 setsid 后代发出 SIGKILL,扫描器读 /proc/<pid>/environ 得到 ENOENT/ESRCH 按「进程已 消失」跳过、判 diagnostic-clean 并诚实返回 ok:true;但同一瞬间 /proc/<pid>/stat 仍可能显示 running,测试在信号后零延迟读 liveness, 于是 expect(stillExecuting).toBe(false) 误红。 修复与同文件 PROBE 1b 一致:断言前用有界 waitFor 等进程进入 gone/ zombie 再判定。不变量保持原样——若成员真的杀不掉,等待会超时 (settled=false),ok:true 仍然咬红;只消除内核回收窗口造成的假阳性。 纯测试改动,生产代码零修改。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 16:11
Owner
Author
|
评审结论:0 P1 / 0 P2,可合。
这是自动评审的初步意见,最终以维护者审阅为准。 |
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
CI 的 bun-test 偶发挂在
test/mojo-task9-probes.test.ts的 PROBE 2 用例「a REPLACEMENT backend terminates the inherited survivor before reporting success」(expected false, received true,断言在 :241)。本地复跑同一棵树与 master 基线各 5 轮全部通过,是时序型 flake。根因
用例对一个被
setsid脱离、继承到新 worker generation 的后代执行destroySession():生产代码对继承的 containment handle 逐个成员发 SIGKILL,然后用scanMojoTree复核。内核回收一个刚被 SIGKILL 的进程时,两个/proc文件的消失有先后:/proc/<pid>/environ先变成 ENOENT/ESRCH,扫描器在readProcTable里按「进程已消失」跳过该 pid(readEnviron的 gone 分支),成员列表为空 →diagnostic-clean→ close 诚实返回ok:true(SIGKILL 确实已送达,进程正在退出);/proc/<pid>/stat仍可能报 running 态。测试在
destroySession()返回后零延迟读一次readProcLiveness,恰好落在这个窗口里就会看到stillExecuting=true,而result.ok===true,于是expect(stillExecuting).toBe(false)误红。用合成 /proc 的探针复审独立复现了这个口径差:同一个 fixture(stat 为 running、environ 已消失)下,扫描成员列表为空而 liveness 仍是 running。生产侧的失败方向是:活着的进程无法让自己的 environ 变成 ENOENT/ESRCH(那是进程消失时才有的形态);stat/environ 的其他读取错误(EIO、不可解析等)会让整个扫描失败并保留 device-isolation blocker。EACCES/EPERM 只会计入
envBlindSpots,而该字段当前没有消费者(见 #3082),不构成额外保证——本 flake 被 SIGKILL 的进程走的是 gone 而非 blind,与这条正交。修法
纯测试改动,生产代码零修改。断言前用既有的
waitFor有界等待该进程进入gone/zombie再判定,与同文件 PROBE 1b(waitFor(() => !existsSync('/proc/...')))和mojo-containment.test.ts里的等法一致。原不变量保持不变:close 只有在没有执行中成员时才允许
ok:true。若成员真的杀不掉(合成 /proc 的伴生用例 P2c 覆盖的形状),等待会超时、settled=false,ok:true仍会咬红。验证
bun run build(含 tsc)通过。expect(settled).toBe(true)反转为toBe(false),该用例确定性咬红,恢复后转绿。关联
这个 flake 挡在 #3002 的合码门禁上(其 PR head 首跑唯一红 job 即此用例,其余 13 项全绿);本 PR 合入后 #3002 同步 master 走新 head 首跑。
🤖 Generated with Claude Code