Skip to content

fix(launcher): 并发车道覆盖 proxy-origin 时按 pid 认回自己的子进程 - #3327

Closed
xgx1 wants to merge 1 commit into
ranxianglei:masterfrom
xgx1:2026-10-16_lane-concurrent-bootstrap
Closed

xgx1 wants to merge 1 commit into
ranxianglei:masterfrom
xgx1:2026-10-16_lane-concurrent-bootstrap

Conversation

@xgx1

@xgx1 xgx1 commented Oct 16, 2026

Copy link
Copy Markdown

Fixes #3326

问题

同一用户下两个宿主几乎同时启动时,src/launcher.ts 的 spawn 轮询只读全局唯一的 proxy-origin 指针(last-writer-wins)。后启动的车道覆盖它之后,先启动方的 launchToken 校验读到别人的记录,判定“不是自己的子进程”;既有逻辑遇到“活记录”时又不会探自己首选端口的健康,于是白等满 20s,静默降级为 proxy bootstrap failed — model traffic goes direct (uncompressed)。健康的那条子进程一直在,只是没人按 pid 认它。

改动

  • src/launcher.ts:在原有 proxy-origin / launchToken 快路径之后加一段兜底——按 child.pid 在存活实例注册表里找自己的子进程,probeHealth(own.origin) 成功即 settleZonePort(own.port) 并返回。
  • 新增 LauncherDeps.discoverInstances(默认 discoverLiveInstances),便于测试注入。
  • tests/launcher.test.ts:新增回归用例 ensureProxyRunning: finds its own child when a concurrent lane overwrote proxy-origin(假 child pid 42499,readInstanceFile 指向另一车道的活记录,注册表返回 127.0.0.1:18799)。

验证

  • 删掉新增分支即复现 Error: bili: proxy did not become healthy within 20000ms(新用例失败)。
  • 带修复:tests/launcher.test.ts 242/242 通过。
  • 全量 env -u BILLION_CONTEXT_NATIVE npm test:3305 tests / 3288 pass / 0 fail / 17 skipped(不 unset 时 omp/pi/opencode 三条 native-host 用例会因 shell 跑在 dsh 里而误报 'dsh' !== 'omp')。
  • npm run typecheck 干净;npm run build 成功(dist-import-annotations: OK)。

备注

分支基于当前 master(a046d4ec),只含这一个提交。

The spawn poll reads the single proxy-origin pointer, which is
last-writer-wins: when two lanes start together the later writer replaces
it, the first launcher's launchToken check fails, and the live-record
guard makes it skip probing its own preferred port. It then burns the
whole 20s window and degrades to "proxy bootstrap failed — model traffic
goes direct (uncompressed)", silently disabling compression for that
lane until the next healthy bring-up.

Match the child by pid against the per-instance registry, which still
identifies it when the pointer names another lane's proxy. The registry
lookup is a LauncherDeps seam so the regression test can drive it; that
test reproduces the original 20s "did not become healthy" failure when
the registry branch is removed.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复 —— 按失败签名(proxy-origin 覆盖 / 并发车道 spawn 轮询误认 / bootstrap 20s 超时静默直连)检索 open+closed issue 与 PR,无同症状同机制的其他条目;本 PR 与 #3326 一一对应。

接单,开始独立审核。先报一个前置发现(已用工具核实):

  1. 分支基线严重过期。PR 描述称「基于当前 master(a046d4ec)」,但分支实际从 32a0c161e(refactor(ccr): retrievals deliver in the tool result — kernel v2 lockstep (requires acp-kernel 0.0.99) #1738 的合并点,2026-09-30)分出——fork 的 master 自 9 月 30 日起未同步过,分支落后当前 origin/master(d8c0e50e7)2043 个提交。期间 src/launcher.ts 有约 2861 行变动、tests/launcher.test.ts 约 2002 行变动,本 PR 的 patch 无法直接应用到当前 master,合入前必须 rebase。
  2. diff 本身很小(src/launcher.ts +19,测试 +43),方向(registry 按 pid 认回自己的子进程作兜底,proxy-origin/launchToken 快路径保留)与 [Bug] Dual-lane simultaneous startup: spawn polling misreads overwritten proxy-origin, healthy subprocess unrecognized → 20s timeout, silent direct connection (compression fails) | [Bug] 双车道同时启动:spawn 轮询误读被覆盖的 proxy-origin,健康子进程认不出 → 20s 超时静默直连(压缩失效) #3326 的期望一致。

接下来我会:在当前 master 上核对该机制是否仍然成立(spawn 轮询这段这半年被改过多少)→ 帮分支 rebase 到当前 master 并解冲突 → 定向回归(launcher 套件 + typecheck)→ 按八问体例给出完整审核结论。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重更正 + 最终结论:此 PR 与已合入的修复重复,予以关闭。

先更正首条回复:当时只按标题/关键词检索 issue,得出「不重复」,查得不够。把 diff 拿到当前 master 逐行核对后发现——这个修复已经在 master 上了,机制、插入位置、语义完全一致,只是挂在另一个 issue 名下:

为什么你本地还会踩到:你的日志是 [v=dev],而本 PR 分支的真实父提交是 32a0c161e(9 月 30 日,#1738 合入点)——早于 10 月 12 日的 #2954 修复(PR 描述称基于 a046d4e,但该提交其实已含此修复,分支历史与描述不符)。也就是说你跑的是修复前的 dev 构建,「在当前 master 稳定复现」实际是在旧树上复现。

结构化八问

  1. 是什么问题:两个车道几乎同时拉起代理时,后写者覆盖全局 proxy-origin 指针,先启动方认不回自己健康的子进程,白等满预算后静默降级为直连(无压缩)。
  2. 什么原因导致的:spawn 握手只认机器全局唯一的单文件(last-writer-wins),并发写入饿死 launchToken 匹配;等待循环没有按 pid 查每实例 registry。你的根因定位准确,与上游 [Kimi Native] 多 Provider 切换旁路绕过、Thinking 丢失、上下文窗口失真及端口冲突问题反馈 #2954 的分析一致。
  3. 影响范围与严重程度:触发条件窄(并发 bring-up / 端口竞争窗口重叠),但一旦触发自举彻底失败、该会话流量整段失去压缩——条件性阻断级。v0.1.196 及以后已不受影响。
  4. 怎么修复的:无需再修——fix(kimi): close native-lane gaps from #2954 — capability passthrough, full model windows, clobbered-origin handshake #2956 已用相同机制修掉(轮询中按 pid 查 registry 认回自己的子进程)。本 PR 的改动是它的严格子集,没有增量价值。
  5. 是否有回归问题:本 PR 不再合入,无新增回归面;上游修复合入时已逐项审过既有行为(token 快路径、stale 首选端口回退、超时强杀均保持不变)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及(维持「单指针快路径 + per-instance registry 兜底」的既有架构)。
  8. 是否引入新配置:无。

处置与后续:按「同症状 + 同机制 → 一条线,先来后到」规则,本 PR 作为 #2954 工作的重复项关闭。建议你同步上游 master(或升级 ≥v0.1.196)重建后复测;若在新构建上仍复现,请带版本号与 ~/.local/state/billion-context/instances/ 现场重开 #3326——那说明上游修复有缺口,值得单独排查。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

2 participants