Skip to content

SQLite unified storage degraded to legacy-only (bili v0.1.209, node v24.18.0, win32-x64) #5359

Closed

Description

@wxl3304413941-afk

=== billion-context diagnostics ===
generated: 2026-10-31T12:56:03.145Z
bili version: 0.1.209 (commit 39a0ada)
node: v24.18.0
platform: win32 x64
os: Windows_NT 10.0.22631
uptime: 18m 32s
--- storage ---
requested mode: full
effective mode: legacy
degrade reason: index database failed to open (Error: database is locked)
engine: none
engine bootstrap: not-needed
BILI_STORAGE_UNIFIED: (unset)
storage.unified (config file): (unset)
BILI_STORAGE_JSON_WRITER: (unset)
storage.jsonWriter (config file): (unset)
BILI_SQLITE_AUTO_DOWNLOAD: (unset)
storage.sqliteAutoDownload (config file): (unset)
BILI_STORAGE_WAL_JOURNAL_SIZE_LIMIT_BYTES: (unset)
storage.walJournalSizeLimitBytes (config file): (unset)
BILI_ENCRYPTION_KEY set: no
sessions on disk: 5
last [storage] log lines:
2026-10-31T16:35:34.303 [info] [v=0.1.209] [storage] unified FULL mode ENABLED (storage.unified=full or BILI_STORAGE_UNIFIED=full): index.db is the load path (unified-first, legacy fallback); legacy files keep being written — unset the kno…
2026-10-31T17:07:35.870 [error] [v=0.1.209] [storage] another process (pid 30336) is already writing ~.local\share\billion-context\sessions/index.db — two processes on one index.db corrupt it (#3923/#3959). One session dir must have exact…
2026-10-31T17:07:41.001 [info] [v=0.1.209] [storage] unified FULL mode ENABLED (storage.unified=full or BILI_STORAGE_UNIFIED=full): index.db is the load path (unified-first, legacy fallback); legacy files keep being written — unset the kno…
2026-10-31T17:20:48.359 [info] [v=0.1.209] [storage] unified FULL mode ENABLED (storage.unified=full or BILI_STORAGE_UNIFIED=full): index.db is the load path (unified-first, legacy fallback); legacy files keep being written — unset the kno…
2026-10-31T17:38:04.155 [info] [v=0.1.209] [storage] split-brain notice for session session- acknowledged via web UI
2026-10-31T18:11:10.385 [debug] [sess=session-7fea4dca-d936-4fde-88a4-fc8df7cb3377] [v=0.1.209] [storage] periodic WAL checkpoint at ingest 20: busy=0 log=15987 checkpointed=15987
2026-10-31T20:32:45.187 [info] [v=0.1.209] [storage] unified FULL mode ENABLED (storage.unified=full or BILI_STORAGE_UNIFIED=full): index.db is the load path (unified-first, legacy fallback); legacy files keep being written — unset the kno…
2026-10-31T20:37:37.133 [error] [v=0.1.209] [storage] another process (pid 1696) is already writing ~.local\share\billion-context\sessions/index.db — two processes on one index.db corrupt it (#3923/#3959). One session dir must have exactl…
2026-10-31T20:37:37.173 [info] [v=0.1.209] [storage] unified FULL mode ENABLED (storage.unified=full or BILI_STORAGE_UNIFIED=full): index.db is the load path (unified-first, legacy fallback); legacy files keep being written — unset the kno…
2026-10-31T20:52:28.841 [warn] [sess=c9ebbed8-9b0b-4583-b539-0afb1e5d95e1] [v=0.1.209] [storage] unified shadow disabled after 3 consecutive failures (last: Error: database is locked)
2026-10-31T20:52:47.448 [warn] [v=0.1.209] [storage] unified sidecar failed to open ~.local\share\billion-context\sessions/index.db (Error: database is locked) — staying legacy-only; delete the file to reset the index
2026-10-31T20:52:47.594 [info] [v=0.1.209] [storage] second-process pid 1696 has exited — stale warning cleared
--- host client versions ---
dsh profile desktop: dsh ?, dsh-compaction-basic ?, dsh-web-app ?
--- bili config (secrets masked) ---
{"providers":{},"security":{"adminRelay":true}}

Activity

  1. ranxianglei commented on Oct 31, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    查重:重复 #5325 —— 同版本 v0.1.209、同平台 win32-x64、同签名(degrade reason: index database failed to open (Error: database is locked) + another process (pid …) is already writing);#5325 当天先开,owner 已按此机制关闭。按政策我不自行关单,打 duplicate 标签留说明,关闭由 owner 决定。

    标签: bug / dsh / scope/storage / p2 / duplicate —— 缺陷类、dsh 车道、存储域;产品仍可用有绕行故 p2;与 #5325 同症状同机制。

    发生了什么(人话):你的机器上先后有三个 bili 进程共用同一个 sessions 目录(~\.local\share\billion-context\sessions\)。日志时间线:pid 1696 于 20:32 正常启动;20:37 第二个进程启动时检出 1696(那条 error 行,v0.1.209 只是告警、继续跑,之后它的写入连续撞锁);约 20:52 第三个进程(出这份诊断的)打开 index.db 时锁还没释放,SQLite 直接回 database is locked → 静默落回 legacy-only。v0.1.209 里「两个进程共写一个 index.db」是 warn-only 共存设计,锁竞争失败后没有任何重试或恢复路径——这正是 #5325 报过的已知形态。

    数据是完好的:full 模式下 JSON 文件一直在写,index.db 是被「锁住」不是「损坏」。不要删任何文件(删了反而丢 checkpoints)。

    master 上的行为(已修好,尚未发版):

    1. 多进程共享一个 index.db 现在是受支持拓扑(owner 决策 2026-10-31,PR [PR] fix(storage): a live second writer no longer blocks startup — sharing a local-disk index.db is a supported topology (rev | fix(storage): 活着的第二写者不再阻止启动——共享一个本地盘 index.db 是受支持拓扑(撤回 #5213 的拒绝策略) #5294):共存只提示 + 状态面可见,仅「同一会话被双写」才走 split-brain 告警;
    2. 其他原因打不开 index.db(杀软占用等环境故障)→ 拒绝启动并给出明确报错和修复指引,不再静默降级(owner 政策 2026-10-30,[PR] [storage] Degradation Semantics Bundle: Seven accepted fixes consolidated into one branch — a single merge suffices (inc | [storage] 降级语义全家桶:七个已验收修复合成一个分支,合并一次即可(含撤回损坏库自动改名) #5213);
    3. 你日志里 20:52 撞到的「连续失败 3 次自禁用」熔断器已整体移除——运行期索引写入永不放弃,win32 的 OS 拒绝类提示也覆盖到写入期失败。

    最新 release 仍是 v0.1.209,以上变更随下一版本发出。

    当前版本的即时恢复:

    • 每个 sessions 目录只保留一个活着的 bili 进程:停掉重复实例,重启降级的那个进程即恢复 full 模式;
    • 若确实要并行跑多个实例,用 BILI_SESSIONS_DIR 给每个实例独立目录隔离;
    • 或显式设 BILI_STORAGE_UNIFIED=legacy 接受 JSON-only(这是用户选择,不再是隐式兜底)。

    结构化八问

    1. 是什么问题:双实例共用一个 sessions 目录时,SQLite 写锁竞争让后启动的进程打不开 index.db,静默降级为 legacy-only 直到重启。
    2. 什么原因导致的:v0.1.209 把「两进程共写一个 index.db」当 warn-only 共存处理,锁竞争失败后无重试/恢复路径(open 失败终身 latch、3 连败熔断终身),属该版本的已知设计形态而非新缺陷。
    3. 影响范围与严重程度:v0.1.209 上多个 bili/dsh 实例共用同一 sessions 目录的用户;产品仍可用(JSON 路径正常服务会话),损失的是统一存储的加载性能/checkpoint 收益,无数据丢失——p2。
    4. 怎么修复的:master 三条线已落地——多实例共写升为受支持拓扑(只提示不报错)、其他 open 失败拒绝启动并给指引、自禁用熔断器移除;本单无需额外代码改动。
    5. 是否有回归问题:本单无改动;master 链的行为变更清单见 [PR] [storage] Degradation Semantics Bundle: Seven accepted fixes consolidated into one branch — a single merge suffices (inc | [storage] 降级语义全家桶:七个已验收修复合成一个分支,合并一次即可(含撤回损坏库自动改名) #5213 / [PR] fix(storage): a live second writer no longer blocks startup — sharing a local-disk index.db is a supported topology (rev | fix(storage): 活着的第二写者不再阻止启动——共享一个本地盘 index.db 是受支持拓扑(撤回 #5213 的拒绝策略) #5294 的 PR 描述与 [PR] fix: keep the lane's sticky zone pointer under live same-lane holders (#4566 part 2) #5064 决策记录。
    6. 是否破坏缓存:不涉及。
    7. 是否改了设计方向:是——「双实例共享 index.db」从 warn-only 变为明确受支持的拓扑([PR] fix: keep the lane's sticky zone pointer under live same-lane holders (#4566 part 2) #5064 最终裁决),split-brain 告警继续守护同会话双写这一真实危险面。
    8. 是否引入了新的配置:本单未引入;既有逃生口 BILI_STORAGE_UNIFIED=legacy 语义不变。

    收工判定:本单为 #5325 的重复条目,全部观测到的机制均已被 master 修复链覆盖,等下一版发布即可根治;已打 duplicate 标签,关闭留给 owner。

  2. ranxianglei commented on Oct 31, 2026

    @ranxianglei
    Owner

    ework 问个问题 这个问题在master还会存在吗?master应该禁止回退到legacy-only了

  3. ranxianglei commented on Oct 31, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    不会。master 上这个形态(锁竞争 → 静默永久 legacy-only)已经不存在,你的理解是对的,代码核实如下:

    1. 触发条件本身不再是错误。两个进程共用一个 index.db 现在是受支持拓扑(#5064 最终裁决 / PR #5294)——WAL 多进程安全,第二写者只走 informational 提示 + status 面(src/storage/store.ts 里 StorageSecondWriterError 已标 deprecated、仓内不再抛出)。v0.1.209 那套「检出他进程 → 告警但继续 → 撞锁降级」的链条整个没了。

    2. 万一 open 时仍撞上环境类失败(含极端争用下的 database is locked)→ 拒绝启动,不降级(src/storage/shadow.ts:301-316):no-engine / CANTOPEN / readonly / OS 级拒绝一律 throw,报错里带修复指引(win32 还有杀软/完整性标签/路径超长定向提示),或显式设 BILI_STORAGE_UNIFIED=legacy 才是用户选择。#5361 诊断里那种「effective mode: legacy + degrade reason」的静默终态在 master 上开不出来。

    3. 运行期不再有任何永久熔断。3 连败自禁用已整体移除(shadow.ts:121-124,字段保留兼容、恒 false),ingest 失败逐次告警 + 永远重试,不存在「撞几次就终身 legacy」的棘轮。

    唯一保留的两条「无索引服务」路径,都不是静默降级:

    • quick_check 证明 index.db 损坏(与锁是不同故障域):带着大声 alarm 启动、从 JSON envelope 服务、文件原样不动等人工处理(shadow.ts:258-285)——这是 2026-10-30 你拍板的最终形态(撤掉了 [PR] fix: auto-quarantine a corrupt index.db instead of degrading to legacy-only forever #3965 的自动隔离改名);
    • 显式 opt-out(BILI_STORAGE_UNIFIED=legacy / 加密 opt-out / persistence off):用户配置,不算降级。

    所以结论:#5361 报的具体问题在 master 上双重消失——触发机制升为支持拓扑 + 残余环境故障改 fail-fast。等下一版发出即可根治用户侧。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdshduplicateThis issue or pull request already existsp2scope/storage

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions