Repository navigation
fix: refuse concurrent launches on a live shared overlay instead of clobbering it (#1952) - #1969
Merged
Merged
Conversation
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1985-pr.1969.a0962b6This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1969.tgz
npm install -g packageInstall instructions are refreshed on each push. |
This was referenced Oct 3, 2026
…lobbering it (#1952) Two bili launches sharing one real home both target the fixed `${home}-bili` overlay. The second launch detected the live first holder (.bili-launch.pid) but only warned, then rewrote the first launcher's generated .env (proxy routing) and MCP config.toml — last writer won. The detection was advisory: no ownership, and even two FIRST launches racing had a check-then-write window. Replace the advisory check with an exclusive lease: - acquireOverlayLease(): atomic mkdir of <overlay>/.bili-launch.lock/ plus an owner record (pid + random token). A live foreign holder throws OverlayBusyError BEFORE any refresh/config write; a dead holder's lease is reclaimed (crash residue); a partially written owner record reads BUSY (manual unlock = delete the lock dir). The legacy .bili-launch.pid marker still acts as a liveness hint, so this build also protects overlays held by pre-#1952 launchers. - runLaunch aborts cleanly on busy: logs the reason, stops THIS launch's own proxy child (a plain throw would leak it — prepare runs after ensureProxyRunning), exits 1. The lease is released in the same finally that stops the proxy. - Sits in the shared refreshOverlayHome, so every overlay lane gets the guard (codex + dsh) — one fix at the mechanism. Behavior change: a second concurrent launch of the same home now hard-refuses (exit 1, zero writes) instead of warning and clobbering the first launcher's config. Sequential relaunches are unaffected (lease released on exit; stale leases auto-reclaimed). Tests: tests/overlay-busy-lock.test.ts — OP repro via legacy marker, foreign live lease, partial owner record, stale reclaim (lease + marker), same-process roundtrip, token-verified release, six-process race (exactly one winner), dsh lane parity, runLaunch integration (proxy stopped, client not spawned, exit 1).
…infers CJS and esbuild rejects its top-level await (children exit 1 before printing; red on all 4 CI lanes and locally)
ranxianglei
force-pushed
the
2026-10-03_codex-overlay-busy-lock
branch
from
October 3, 2026 07:53
4440e86 to
83174c7
Compare
Owner
Author
[bot] 🏷 ## PR #1969 review 结论(第二轮:rebase 后复核) 按 [PR] 流程核对完毕:拉取分支逐行审代码、确认 CI、本地对合并后树重跑定向验证。分支未被我改动(见文末说明)。 审查动作与证据
结构化七问
验证状态
过程说明本轮我原本要把分支 rebase 到最新 master 再推回;推送时发现远端分支已被并发工作先行 rebase,且与我本地重基结果树完全一致( 判定:可合。 §7.4 launcher 生命周期类,不满足 auto-merge,请人工合并:#1969 |
ranxianglei
added a commit
that referenced
this pull request
Oct 3, 2026
…o the real codex home (#1965) finalizeCodexHome excluded the legacy pid marker but not the lease DIRECTORY from #1969. The normal path deletes it in releaseOverlayLease before finalize runs, but a failed release (Windows EBUSY-class) leaves the dir behind and finalize would merge it — and its owner.json — into the REAL home, violating #1965's acceptance that lock metadata never writes back. Exclude it like the other launcher metadata; regression test plants a stale lease dir and asserts the db still merges back.
8 tasks
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.
Closes #1952
What / why
Two
bili codexlaunches sharing one real Codex home both target the fixed${CODEX_HOME}-bilioverlay. The second launch detected the live first holder (.bili-launch.pid) but only printed a warning, then rewrote the first launcher's generated.env(proxy routing) and MCPconfig.toml— last writer won. The detection was advisory only: no ownership, and even two FIRST launches racing had a check-then-write window.Fix
Exclusive lease on the overlay, acquired before any refresh/config write:
acquireOverlayLease()— atomicmkdirof<overlay>/.bili-launch.lock/+ owner record (pid + random token). Live foreign holder →OverlayBusyErrorbefore any write. Dead holder → stale lease reclaimed automatically (crash residue). Partially written owner record → treated as busy (conservative); manual unlock = delete the lock dir. The legacy.bili-launch.pidmarker still acts as a liveness hint, so this build also refuses to touch an overlay held by a pre-[Bug][Codex launcher] 检测到存活启动器后仍覆盖共享 overlay 的代理与 MCP 配置 #1952 launcher.runLaunchaborts cleanly on busy: logs the reason, stops THIS launch's own proxy child, exits 1. A plain throw would leak the detached proxy — the prepare step runs afterensureProxyRunning, outside the cleanupfinally. The lease is released in that samefinally.refreshOverlayHome, so every overlay lane gets the guard (codex + dsh) — one fix at the mechanism, matching the issue's acceptance criteria.Behavior change (old → new)
.env/ MCP config / pid marker (last writer wins)rm -rf <home>-bili/.bili-launch.lock)No config surface added — no new env vars / config fields / CLI flags. No persistence-format change (the lock dir is transient runtime state inside the existing overlay). Wire protocol untouched. Not auto-merge eligible (§7.4: launcher lifecycle territory) — needs human review.
Tests
New
tests/overlay-busy-lock.test.ts(10 tests): OP repro via legacy marker (byte-identical files after refusal), foreign live lease, partial owner record, stale lease reclaim, stale marker alone, same-process roundtrip, token-verified release, six-process race (exactly one winner), dsh-lane parity,runLaunch(codex)integration (proxy stopped, client never spawned, exit 1, message carries holder pid).Targeted local runs (CI does the full suite): overlay-busy-lock 10/10 · codex-overlay-env 14/14 · launcher-sqlite-overlay 17/17 · instance-governance 14/14 · launcher 264/265 (1 pre-existing env skip: needs built dist). Typecheck (src) clean; build green.