Repository navigation
test(ci): 根治 schedule-repair 锁竞态与 v3 临时目录 teardown 两个高负载 flake - #3238
Merged
Merged
Conversation
Fixes #3232 Fixes #3235 两个只在高负载 CI runner 上复现的测试 flake,均为测试侧问题、src 零改动。 #3232 schedule-repair-adversarial-review(test(4/4)): 根因不是 pumpUntil 步进太多,而是锁竞态——TurnSendLedger.execute 包在 withFileLock 里,dispatch 在拿到文件锁之后才执行;高负载下拿锁要花真实 时间,测试却已经 settleLater 并推假时钟,结算跑在 send 登记 in-flight 之前,之后永远走不到 unknown(CI 里 line536 用例 150ms 即逻辑失败, line636 被它连累挂满 120s)。修法: - slowFinal 暴露 entered(dispatch 真正进入时 resolve),两个调用点先 await send.entered 再推时钟、再结算,保证 in-flight 先登记。 - 把 finish 登记进 pending,用例中途失败没走到 finish 时 afterEach 也能 释放悬着的 fenced send,不再连累后续用例超时。 - pumpUntil 步进保持 1s/500ms 不变。 #3235 workflow-node-daemon cleanupBotRuns(test(2/4) ENOTEMPTY): Node22 的 rmSync 只在第一轮删子项,后续重试只重试 rmdir 且第 i 轮前 同步 sleep i*retryDelay(旧 60×100ms 实际阻塞约 183s,CI 失败耗时 183043ms 与之吻合);第一轮之后才落地的文件永远不会被补删,同步 sleep 还卡住同进程的 fire-and-forget 写。加大 rmSync 预算既赢不了又会把 shard 卡死。修法:cleanupBotRuns 改为异步重删循环,每轮整体 rm(maxRetries:0) 重新删掉迟到文件,轮间 await 让出主线程让后台写收尾,30s 墙钟上限,只在 撞 ENOTEMPTY/EBUSY/EPERM 时等待,正常路径零延迟;四个裸调用点补 await。 验证(Node v22.21.1 匹配 CI,另跑 Bun 1.4.4): - typecheck、build 通过;17 个相关测试文件 365 用例双运行时全绿。 - #3232 探针:pbkdf2 占满线程池复现锁延迟,去 entered 门控时目标用例 133ms 复现 CI 同签名失败、恢复后通过;去 pending 登记时释放探针挂满 10s 超时,恢复后通过。 - #3235 探针:独立子进程在首轮 rm 期间持续落盘,新异步循环 978ms 清理 成功;去掉重试循环即抛与 CI 逐字相同的 ENOTEMPTY。探针为临时验证、未提交。 Co-Authored-By: Claude Fable 5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 9, 2026 05:32
deepcoldy
pushed a commit
to Phoobobo/botmux
that referenced
this pull request
Nov 9, 2026
master 新进的 deepcoldy#2865、决策看板文字换行修复、deepcoldy#3238 都不碰本 PR 的 5 个文件。 Co-Authored-By: Claude Fable 5 <[email protected]>
|
@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 91743e6。
|
|
🚀 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 runner 上复现的测试 flake,已经在多个 PR 和 master push 上红过,按 G4 不能靠同 SHA 重跑放行。本 PR 只改测试,
src零改动。test/schedule-repair-adversarial-review.test.ts在test (4/4)上墙钟超时。test/workflow-node-daemon.test.ts的cleanupBotRunsteardown 抛ENOTEMPTY,红在test (2/4)。#3232:根因是锁竞态,不是 pumpUntil 步进太多
CI 日志显示两条用例失败方式不同:一条 150ms 即逻辑断言失败,另一条被它连累挂满 120s;相邻用例只要 20–40ms,所以「假时钟步进轮次占满墙钟」不成立,调大步进反而失败更快。
真正根因:
TurnSendLedger.execute包在withFileLock里,dispatch要等拿到文件锁之后才执行。高负载下拿锁要花真实时间,测试却已经settleLater并开始推假时钟,于是结算跑在这次 send 登记为 in-flight 之前,之后永远走不到unknown。修法(
slowFinal测试夹具):enteredpromise,在dispatch真正被调用(已拿锁、已登记 in-flight)时 resolve;两个调用点先await send.entered再推假时钟、再结算,保证登记先于结算。finish登记进pending:某条用例中途失败、没走到自己的finish时,afterEach也能释放这次悬着的 fenced send,不会把后续用例拖到 120s 超时。pumpUntil的步进保持 1s / 500ms 不变。#3235:Node 22 的 rmSync 重试救不了迟到文件
Node 22 的
rmSync只在第一轮删子项,之后的重试只重试rmdir,且第 i 次重试前同步 sleepi × retryDelay——旧配置maxRetries: 60, retryDelay: 100实际阻塞约Σ i×100ms = 183s,与 CI 失败用例耗时 183043ms 吻合。第一轮之后才落地的文件后续重试永远不会补删,同步 sleep 还卡住同进程的 fire-and-forget 写,所以单纯加大rmSync预算既赢不了、又会把 shard 卡死约 30 分钟。修法(
test/helpers/v3-external-harness.ts的cleanupBotRuns):rmSync(..., { maxRetries: 0 })整体删一次(重新覆盖迟到文件),轮间await setTimeout让出主线程,让后台写有机会收尾。ENOTEMPTY/EBUSY/EPERM时等待,30s 墙钟上限;正常无竞争路径第一轮就返回,零额外延迟。async,四个不返回 promise 的裸调用点补上await;其余afterEach(() => cleanupBotRuns())箭头本身返回 promise,vitest 会 await,无需改。验证
CI 用 Node 22,本地默认 Node 24,两者的
rmSync失败行为不同,因此在 Node v22.21.1(匹配 CI)和 Bun 1.4.4 下分别验证:typecheck、build通过。entered门控时目标用例 133ms 复现与 CI 同签名的断言失败,恢复后通过;去掉pending登记时释放用例挂满 10s 超时,恢复后通过。ENOTEMPTY。影响面
只动测试与测试 helper,不改任何生产代码、配置或持久化格式。
🤖 Generated with Claude Code