Skip to content

[PR] Fix: False-positive warnings and true conflict visibility for multi-lane shared storage (automatic dead-process cleanup | 修复:多车道共用存储的误报警告与真冲突可见性(死进程自动清除/跨车道降级/脑裂横幅+一键关闭) - #4434

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-23_split-brain-surface
Oct 23, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

什么东西坏了

同时开着多个 bili 车道(如 pi + dsh)共用同一个 sessions 目录时:

  1. Web 面板永久挂着一个红色警告「检测到第二个进程在写同一个 index.db」——哪怕那个进程早就退出了,警告也不会消失(状态只在启动时记一次,从不复查),只能重启代理才能消掉。
  2. 跨车道共用其实是受支持的拓扑,但警告一律按「数据损坏风险」的红色级别报警,把正常用户吓到。
  3. 真·脑裂冲突(两个实例同时写同一个会话——这才真正危险,折叠决策互相不可见,最后写入者赢)反而只在日志里有一行,面板上什么都看不到,也说不上是哪个会话、哪个客户端。

修复思路

  • D1 死进程自动清除:每次读取状态时复查 pid 存活,死了一笔带过地清掉警告并记一条 info 日志。警告不再冻结。
  • D2 跨车道降级:锁检测时查实例注册表——对方 pid 属于已知 bili 实例且车道不同(pi vs dsh)→ 降为 info 级提示「这是支持的共享拓扑」;同车道或查不到的陌生进程保持红色警告(宁可误报不可漏报)。
  • G1 真冲突可见:发生脑裂争用时,横幅带上会话 id + 标题 + 双方 pid/车道/版本;[split-brain] 日志同样点名标题和车道。写入者标记文件增加可选 lane 字段(纯增量,旧文件照常解析)。
  • G2 允许关闭:面板横幅提供「不再提示」按钮(POST /__bili/storage/split-brain/ack)——只清横幅不动数据;同一冲突(同 peer 同时间戳)不再弹,新冲突会重新弹出。

影响面 / 风险

  • 改动集中在 storage 状态层 + served-markers + Web 面板;不碰压缩引擎、协议接线、持久化格式。
  • 状态 wire 与标记文件均为纯增量字段,旧消费者照常工作。
  • 语义变更一处:tests/storage-durability.test.ts 原本钉住「死 pid 警告永久保留」的旧 bug 行为,按 D1 新语义更新(活 pid 保留/死 pid 清除,两个方向都断言)。

测试

新增 tests/issue-split-brain-surface.test.ts 5 项(活/死双方向、benign/非 benign 双方向、真冲突/无冲突双方向、ack 清除/同冲突不弹/新冲突重弹、Web wire+端点 200/400×2);相邻 6 套件(storage-durability/served-markers/web-storage-banner/web-i18n/storage-full-flip/issue4323-drift-escalation)全绿;npm run typecheck 干净。

config surface

无新增配置项。

…ismissable split-brain banner (#3923/#3959)

D1: the 'second process' web warning no longer freezes — a foreign pid that
has exited is cleared at the status read and logged once.
D2: a live foreign pid that maps to a known bili instance of a DIFFERENT
lane is the deliberate shared-topology: informational log + banner, wire
carries {pid, lane, instanceId, benign:true}. Same lane / unknown process
keep the loud corruption warning.
G1: a real split-brain contest now surfaces with identity on the web wire
(session id + title, both sides' pid/lane/version) and the [split-brain]
log line names title + lanes. Writer markers gain an optional lane field
(additive; old markers stay valid).
G2: POST /__bili/storage/split-brain/ack dismisses the surfaced entry; the
same contest (same peer + servedAt) stays quiet, a new one re-surfaces,
an unknown session answers 400. Web panel renders the banner (error
styling) with a dismiss button (zh+en copy).
@ranxianglei ranxianglei changed the title 修复:多车道共用存储的误报警告与真冲突可见性(死进程自动清除/跨车道降级/脑裂横幅+一键关闭) [PR] Fix: False-positive warnings and true conflict visibility for multi-lane shared storage (automatic dead-process cleanup | 修复:多车道共用存储的误报警告与真冲突可见性(死进程自动清除/跨车道降级/脑裂横幅+一键关闭) Oct 23, 2026
@ranxianglei
ranxianglei merged commit 7017777 into master Oct 23, 2026
14 of 49 checks passed
ranxianglei pushed a commit that referenced this pull request Oct 23, 2026
…e passes

#4434 (split-brain surface, merged at master tip) left three type exports with no cross-module consumers, red on pristine master. Drop the leading 'export' per the checker's INTERNAL_ONLY prescription — the types stay module-local. Complements in-flight #4419 (which covers the corrupt-index-child exports + lock-sync); different files, no overlap.
ranxianglei pushed a commit that referenced this pull request Oct 23, 2026
ranxianglei pushed a commit that referenced this pull request Oct 23, 2026
…n start

#4434 (split-brain surface, merged at master tip) added a process-spawning suite without registering it in scripts/live-files.mjs, so the SPAWN_RE tripwire in scripts/run-ci-tests.mjs hard-fails every test shard on any tree built from current master (reproduced locally on pristine master). Concurrency review per the #1248 rule before registering: the file spawns only a portless sleep child plus one port-0 proxy (makeOpts port 0), isolates dirs/env per test via mkdtemp, and restores everything in finally — safe under --test-concurrency 4. Appended at the end of LIVE_FILES per its append-only slot convention (slot = index drives the zone port band); standalone run of the suite passes 5/5.
broduer pushed a commit to AvernicAI/billion-context that referenced this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant