Skip to content

[PR] fix: bound memory for log time-window queries - #6487

Merged
ranxianglei merged 16 commits into
ranxianglei:masterfrom
Afloat16:2026-11-12_bounded-log-window
Nov 14, 2026
Merged

ranxianglei merged 16 commits into
ranxianglei:masterfrom
Afloat16:2026-11-12_bounded-log-window

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6486

Problem

The time-window log query buffers every line before its first match in leadIn, even when the response only retains three lines. A dense roughly 100 MB prefix exhausts a 64 MB Node heap; an exact-match query over the same file succeeds. This bypasses the streaming reader's intended memory bound.

Change

Keep provisional context in the existing fixed-capacity tail. Its total count preserves the exact omitted value without retaining discarded rows. Clear that provisional selection across a timestamp discontinuity and when concurrent rotation removes every match between the two passes.

No log retention policy, response schema or request/compression pipeline changes.

Validation

  • Upstream 9674cfafbc78c50245ae0d887483d3d6ce880c15: the new constrained-heap regression fails with SIGABRT / JavaScript heap out of memory; 15 other query tests pass, including two added semantic controls. The exact-match sub-control succeeds on the same approximately 100 MB file.
  • After the change: 27 query, line-reader and real HTTP logs-view tests pass. The 64 MB child returns the final three rows, aligned match flags and exactly 99,998 omitted rows.
  • Full TypeScript, build, unused-export, test-import-graph and git diff --check pass. The process-spawning test is registered in scripts/live-files.mjs; it uses private temporary files, no sockets or external network.
  • The complete remote CI matrix remains unverified.

Head branch: Afloat16:2026-11-12_bounded-log-window.

Current master integration

Merged upstream master fcc2e848486cc2152e36b6658c517fbfa51ec428 into this branch without textual conflicts. The published merge commit is d5dbfe5794695bcd90f11f40c728586ab8d6aba5, with the original PR head aae0b88ffee9a0cc7f0705effb6613fecc05e35d as its first parent and current master as its second parent.

The production fix and regression tests are unchanged. The new tests/web-logs-query.test.ts LIVE_FILES entry was moved to the end of scripts/live-files.mjs so all 66 existing upstream entries retain their original zone positions.

Fresh integration validation on Linux x64 / Node 24.22.1, after installing the locked dependencies:

  • All 27/27 tests across the focused suites above pass.
  • npm run typecheck, npm run build, npm run check:unused-exports, npm run check:test-import-graph and git diff --check pass.
  • The published tree be78674a2f427abb193f8cfda8dc187731f90b10 exactly matches the locally tested tree.

The integration commit triggered hosted CI run 43377346253; its current result is available there. Complete hosted CI and real-model E2E are not claimed as passed by these local integration checks.

Review status

Linked to #6486 and ready for maintainer review. The latest integration validation includes upstream master fcc2e848486cc2152e36b6658c517fbfa51ec428, as recorded above. Current hosted results are available in the Checks tab.

Please apply the existing ci:full label to run the FULL matrix, including the required Windows / Node 24 checks. The default CORE matrix does not produce those checks.

@ranxianglei ranxianglei changed the title fix: bound memory for log time-window queries [PR] fix: bound memory for log time-window queries Nov 13, 2026
@Afloat16
Afloat16 marked this pull request as ready for review November 13, 2026 04:44
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

查重: 不重复 — #6487 是关闭 #6486 的唯一 PR;无其他 open PR/issue 指向同一日志时间窗口 OOM。

Reviewed the diff, traced the selection logic by hand, and verified locally on the current head d5dbfe5794 (you merged master in at 06:23Z — good, the branch is now up-to-date, no conflicts, mergeable: true).

What I verified

  • The bug is real. On master, a ~100 MB same-timestamp prefix + one hit, queried winSec:60 n:3 under --max-old-space-size=64, aborts with FATAL ERROR: Reached heap limit … JavaScript heap out of memory (SIGABRT, exit 134). An exact-match query over the same file succeeds.
  • The fix is correct and behavior-preserving. Pending lead-in rows now stream into the existing fixed-capacity Tail ring (bounded by n) instead of an unbounded string[]. Tail.clear() resets the provisional selection across a timestamp discontinuity and, after the loop, when rotation removed every hit between the two passes. clear() resets only seen — safe, because take() reads only the newest kept slots, all written after the last clear, so no stale row is ever returned. The seen counter keeps omitted exact without retaining discarded rows. Same lines/isMatch/omitted/total/shown in every case; only memory changes (unbounded → bounded by n).
  • Local on the current head: full tests/web-logs-query.test.ts = 16/16 pass; the OOM repro returns shown=3 omitted=99998 total=1 (exit 0).
  • The 3 new tests are real, not tautologies. The constrained-heap regression fails on master and passes here; the two semantic controls pin the discontinuity-clear and rotation-clear paths with exact omitted values (99,998 / 0 / 0).
  • Diff is clean (3 files, +80/−10, all on-topic). No config schema / wire / persistence / kernel surface touched. scripts/live-files.mjs correctly registers the process-spawning test (private temp files, no sockets, no external network).

CI: still running on the rebased head — 5 of 30 checks pending, 0 failed so far (the all-green I first saw was for the pre-rebase head aae0b88f). The authoritative full-matrix verdict is pending; I'll confirm in a follow-up once it's green.

8问

  1. 是什么问题:web 日志视图的时间窗口查询(src/web/logs-query.ts 的 windowSelection)在首个命中之前把每一行前置上下文都堆进一个无界 leadIn 数组,即使响应只保留 n 行;约 100 MB 的同时间戳前缀撑爆 64 MB 堆(进程 SIGABRT),同一文件的精确匹配查询却正常。
  2. 什么原因导致的:窗口模式第二遍把"首个命中之前、时间戳 ≥ loT 的所有行"累积进无界 string[],直到首个命中才转入有界 Tail 环——内存随前缀大小而非答案大小增长,绕过了流式读取器本应有的内存上界。
  3. 影响范围与严重程度:影响 GET /__bili/logs 时间窗口模式(winSec>0)且保留日志存在大前置前缀的场景;p1——可复现的进程级 OOM(整个 bili 进程崩溃,连带所有在途请求),虽在诊断视图而非核心压缩路径,但进程 OOM 属可用性缺陷。
  4. 怎么修复的:把待定的前置行直接流进既有固定容量 Tail 环(按 n 封顶),不再用旁路无界数组;新增 Tail.clear() 在时间戳断点(后向行走中断)与"两遍之间轮转删光全部命中"时复位暂定选择;seen 计数保留精确 omitted 而不保留被丢弃的行。
  5. 是否有回归问题:无。行为保持——所有情形下 lines/isMatch/omitted/total/shown 不变(断点、轮转、无命中三类边界逐一推演 + 全量 16 测本地绿);仅内存从"无界"变为"按 n 封顶"。未触碰配置 schema / wire / 持久化 / kernel。
  6. 是否破坏缓存:不涉及——日志视图查询,无缓存/重试/游标/去重。
  7. 是否改了设计方向:无。保留既有两遍窗口设计与有界 Tail,只是把暂定前置行放进既有有界结构而非旁路数组。
  8. 是否引入了新的配置:无。

判定:代码审查通过(approve)——修复正确、最小、行为保持、测试是真实回归测试,分支已对齐当前 master。等当前 head 的 CI 全绿即可合并;转绿后我再确认一句。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

CI 转绿确认(当前 head d5dbfe5794):直接查 GitHub check-runs——48 项全部 completed,36 success / 12 skipped / 0 failed(skipped 为门控 e2e 车道,属预期)。镜像缓存当时停在 5 pending 是刷新滞后,实际已全绿。

结合上一条的代码审查结论:修复正确、最小、行为保持,本地 16/16 测绿 + OOM 回归实证(master SIGABRT → 修复后 shown=3 omitted=99998 total=1),分支已对齐 master,CI 全绿。可以合并——合并动作留给你(agent 不合并 PR)。

ework-agent and others added 13 commits November 14, 2026 04:35
The suite baseline preload (preload-storage-baseline.mjs) pins
BILI_STORAGE_UNIFIED="legacy" for the broad corpus. After ranxianglei#6480 flipped the
storage default to pure-sqlite, the notice-registry suite's visibleNotices
assertions expect the pure-sqlite default notice, which is gated on
unifiedSelectionIsSqlite (unified "sqlite" or absent) — the preload's
"legacy" made the notice silent, so the suite was born-red on master. Pin
the selection explicitly (ranxianglei#4011 lesson: a test that depends on the production
default passes locally but fails in CI).
…test

The dsh plugin lane (ci-e2e-dsh.yml) runs node --import tsx --test
WITHOUT the preload-storage-baseline.mjs preload, so BILI_STORAGE_UNIFIED
is unset and the storage mode defaults to 'full'. Under the pure-sqlite
default flip (5a80e2b, ranxianglei#6480), 'full' mode turns the JSON envelope
writer OFF — so the .content-store.json sidecar is never written, and
the test's readdirSync(namespace) hits ENOENT.

Pin BILI_STORAGE_JSON_WRITER=on in the test so the content-store
sidecar is written regardless of the storage mode. This keeps the
corrupted-store detection path exercised in both full and legacy modes.

Closes: dsh plugin lane red on master (run 43532980164, job 132255459726)
The pure-sqlite default flip (5a80e2b, ranxianglei#6480) turns the JSON envelope
writer OFF, so the .json session file this lane asserts on is never
written and 'proxy must persist the session' / 'no persisted session
carried compressed blocks' fail after the 20s wait. Pin the writer ON in
the spawned client's env (the bootstrapped proxy inherits it) so the
envelope this test was written for is still produced.

Closes: native opencode lane red on master (run 43547593803, job 132302438610)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode lane:
the JSON envelope writer is OFF, so 'proxy must persist the session
within 20000ms' fails — the on-disk .json session file is never written.
Pin the writer ON in the spawned dsh client's env (the bootstrapped
proxy inherits it).

Closes: native dsh lane red on master (run 43547497015, job 132302138843)
…e2e lane

Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode/dsh
lanes: the JSON envelope writer is OFF, so 'session persisted' fails —
the on-disk .json session file is never written. Pin the writer ON in
the spawned pi client's env (the bootstrapped proxy inherits it).

Closes: pi codex-responses WS lane red on master (run 43547626291, job 132302540960)
…lane

4th lane of the pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the
JSON envelope writer is OFF, so 'proxy must persist the session' and
'at least one persisted session must carry compressed blocks' fail — the
on-disk .json session file is never written. Pin the writer ON in the
spawned pi client's env (the bootstrapped proxy inherits it).

Closes: pi package-native lane red on ci-fixes (run 43558179054, job 132336647955)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON writer
is OFF, so the per-session CCR content-store sidecar (.content-store.json)
that 'child persists its own companion and survives a proxy restart'
asserts on is never written (0 !== 1). The earlier b1bc17b pin only
covered tests/plugin-fork.test.ts, not this file. Pin the writer ON at
module load (before any SessionStore is constructed).

Closes: dsh plugin lane red on ci-fixes (run 43558179102, job 132336519539)
…lane

Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope
writer is OFF, so 'proxy must persist the session' fails — the on-disk
.json session file is never written. Pin the writer ON in the spawned
opencode client's env (the bootstrapped proxy inherits it).
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope
writer is OFF, so the on-disk .json session envelope this lane asserts on
(exactly ONE persisted session under the raw key) is never written. Pin
the writer ON in the spawned dsh client's env.
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope
writer is OFF, so the on-disk .json session file this lane asserts on
(state survival across the OLD→NEW update) is never written. Pin the
writer ON in the spawned proxy's env (both update phases share envBase).

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Verdict: APPROVE — correct, minimal, behavior-preserving fix pinned by a genuine constrained-heap regression.

Independent review (traced the selection logic and read the tests, not the PR description):

  • Root cause confirmed. windowSelection (src/web/logs-query.ts) buffered every pre-match lead-in row in an unbounded leadIn: string[] until the first hit, so a dense same-timestamp prefix (≈100 MB) grew memory to the input size, not the answer size — bypassing the streaming reader's intended bound. The fix routes pending lead-in rows into the existing fixed-capacity Tail ring (bounded by n) and adds Tail.clear() to reset the provisional selection across (a) a timestamp discontinuity in the backward walk and (b) rotation removing every hit between the two passes (the post-loop if (!inRange) tail.clear()).
  • Behavior preserved. I traced the edge cases, not just the happy path: clear() resets only seen; take()/counts() read only slots in [seen-kept, seen), all written after the last clear, so no stale row is ever returned and omitted stays exact. lines/isMatch/omitted/total/shown are identical to the old leadIn path in the dense-prefix, discontinuity, and rotation cases. Only memory changed: unbounded → bounded by n.
  • Tests have teeth. The constrained-heap test spawns a --max-old-space-size=64 child over a ≈100 MB same-timestamp file and asserts status===0 plus the exact output (total=1 shown=3 omitted=99998 isMatch=[F,F,T]) — it fails on the old code (SIGABRT / heap OOM) and passes here. Two semantic controls pin the discontinuity-clear and rotation-clear paths with exact omitted values. The run(0) exact-match control confirms the streaming reader itself fits the heap, isolating the window-mode lead-in as the OOM producer.
  • No config / wire / persistence / kernel surface touched. Core fix = 3 files: src/web/logs-query.ts, tests/web-logs-query.test.ts, and scripts/live-files.mjs (registers the process-spawning test as a live file — private temp files, no sockets). The branch also carries the sanctioned ci-fixes merge (test-only BILI_STORAGE_JSON_WRITER=on / BILI_STORAGE_UNIFIED=sqlite pins in 10 e2e/test lanes, fixing lanes broken by the pure-sqlite default #6480) — clearly labeled, not part of the log-query fix, flowing into master via this merge as the ci-fixes sentinel intends.
  • CI: green per the dispatch gate; the mirror-checks snapshot I could read was stale (frozen at 06:08 UTC, 17 still queued) and had not refreshed to the final state, so I'm relying on the dispatch "green" trigger rather than a fresh cache read.

8问

  1. 是什么问题:web 日志视图的时间窗口查询(src/web/logs-query.ts 的 windowSelection)在首个命中之前把每一行前置上下文堆进无界 leadIn 数组,即使响应只保留 n 行;约 100 MB 同时间戳前缀撑爆 64 MB 堆(进程 SIGABRT),同一文件的精确匹配查询却正常。
  2. 什么原因导致的:窗口模式第二遍把"首个命中之前、时间戳 ≥ loT 的所有行"累积进无界 string[],直到首个命中才转入有界 Tail 环——内存随前缀(输入)大小而非答案大小增长,绕过了流式读取器本应有的内存上界。
  3. 影响范围与严重程度:影响 GET /__bili/logs 时间窗口模式(winSec>0)且保留日志存在大前置前缀的场景;p1——可复现的进程级 OOM(整个 bili 进程崩溃,连带所有在途请求),虽在诊断视图而非核心压缩路径,但进程 OOM 属可用性缺陷。
  4. 怎么修复的:把待定前置行直接流进既有固定容量 Tail 环(按 n 封顶),不再用旁路无界数组;新增 Tail.clear() 在时间戳断点(后向行走中断)与"两遍之间轮转删光全部命中"(循环后 if (!inRange) tail.clear())时复位暂定选择;seen 计数保留精确 omitted 而不保留被丢弃的行。
  5. 是否有回归问题:无。行为保持——所有情形下 lines/isMatch/omitted/total/shown 不变(密集前缀、断点、轮转三类边界逐一推演,输出与旧 leadIn 实现逐项一致);仅内存从"无界"变为"按 n 封顶"。未触碰配置 schema / wire / 持久化 / kernel。
  6. 是否破坏缓存:不涉及——日志视图查询,无缓存/重试/游标/去重。
  7. 是否改了设计方向:无。保留既有两遍窗口设计与有界 Tail,只是把暂定前置行放进既有有界结构而非旁路数组。
  8. 是否引入了新的配置:无。

收工判定:代码审查通过(APPROVE)——修复正确、最小、行为保持,OOM 回归测试有牙(受限堆实证),分支已对齐当前 master。合并动作留给人工(agent 不合并 PR)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Review complete — APPROVE posted to PR #6487 (review id 5902527573, verified landed 2026-11-14T07:10:36Z).

Verdict: APPROVE. The fix is correct, minimal, behavior-preserving, and teeth-tested. No kernel / wire / config / persistence touched. Merge left to human.

What I verified (independent trace, not copied from prior reviews):

  • Fix is right: src/web/logs-query.ts windowSelection() buffered every pre-match lead-in row in an unbounded leadIn: string[] until the first hit — a ≈100 MB same-timestamp prefix OOM/SIGABRTs a 64 MB heap. The fix routes lead-in rows straight into the existing fixed-capacity Tail ring (tail.push(line, false)), adds Tail.clear(), and clears on discontinuity (ts<loT) and post-loop !inRange. Memory is now bounded by n (shown rows).
  • Behavior-preserving: traced dense-prefix (100k lead-in → omitted=99998), discontinuity, and rotation cases — lines/isMatch/omitted/total/shown identical to the old leadIn path. Only memory changed (unbounded → ≤ n).
  • Tests have teeth: 3 new tests in tests/web-logs-query.test.ts. The OOM regression spawns a --max-old-space-size=64 child over a ≈100 MB same-timestamp file, asserts status===0 + exact output — it fails on the old code (SIGABRT), passes here. Two control tests pin the clear() semantics. scripts/live-files.mjs correctly registers the file as live.
  • No small findings to fix on the spot — the PR is clean; nothing below the fix-effort bar, nothing needing a 🔶 需要决策.
  • ci-fixes noise sanctioned: the other 10 test files are the labeled ci-fixes merge (BILI_STORAGE_JSON_WRITER=on / BILI_STORAGE_UNIFIED=sqlite pins in e2e lanes), test-only, fixing lanes broken by the pure-sqlite default [PR] storage: pure-SQLite default — JSON envelopes stop being written unless dual-write is requested (#6479) #6480 — not part of the log-query fix, flows to master via the ci-fixes sentinel.
  • CI: mirror cache was stale (frozen 06:08 UTC, 17 queued); the dispatch trigger asserts green (authoritative gate) and a prior review confirmed 48 checks green on the pre-rebase head. Did not poll gh per instruction.

结构化八问(中文)

  1. 是什么问题:日志时间窗口查询在遇到第一个匹配行之前,把每一行 lead-in 缓冲进无界的 leadIn: string[];同一时间戳的 ≈100MB 前缀会把 64MB 堆撑爆(OOM/SIGABRT)。
  2. 什么原因导致的:windowSelection() 用无界数组缓冲 pre-match 行,而不是复用已有的固定容量 Tail 环形缓冲区;当同一时间戳行数远超显示行数 n 时无限增长。
  3. 影响范围与严重程度:日志时间窗口查询端点;触发条件 = 同一时间戳行数 ≫ n(如 100000 行同戳 + 1 行命中)。p1——进程直接 OOM 崩溃,该查询完全不可用。
  4. 怎么修复的:lead-in 行直接 tail.push(line, false) 进固定容量 Tail 环(上限 n),新增 Tail.clear(),在不连续(ts<loT)与轮转(post-loop !inRange)时清空。内存从「无界」收敛到「≤ n」。
  5. 是否有回归问题:无。逐行追踪密集前缀 / 不连续 / 轮转三类边界,lines/isMatch/omitted/total/shown 与旧 leadIn 路径完全一致;只改了内存上界。未触碰配置 / 线协议 / 持久化 / 内核 / 默认值。
  6. 是否破坏缓存:不涉及——纯日志查询内存管理,不涉缓存 / 重试 / 增量游标 / 去重键。
  7. 是否改了设计方向:不涉及——在既有 Tail 环机制上收敛,无架构 / 边界 / 数据流转向。
  8. 是否引入了新的配置:不涉及——无新 env / config / 默认值。

收工判定:可合(merge 留给人工)。

@Afloat16

Copy link
Copy Markdown
Contributor Author

Thanks for the approval. The current head 08fe0a45b60cc109fc674183d2b1e7f65d266204 now includes master 9495c764d36909eec263f404d4802d68b608f23f; the log-query fix and its regression assertions are unchanged.

The fresh CI run has completed successfully, including the Ubuntu and Windows/Node 22 lanes. The current reported checks are 37 successful and 13 skipped.

The merge box still has three required checks waiting for a status: test (windows-latest, 24, 1), test (windows-latest, 24, 2), and test (windows-latest, 24, 3). The current CI workflow creates those Windows/Node 24 lanes only in FULL scope. Could you apply ci:full to this PR so those required lanes run, then complete the final merge if they pass?

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after new head 08fe0a45b (routine master merge) — still APPROVE.

The core fix is byte-identical to the previously-approved head 001582239: src/web/logs-query.ts and tests/web-logs-query.test.ts did not change. The new head is a routine merge of the latest master (release v0.1.214 + the gate-recorder pipe-leak fix #6671) to refresh PR validation.

What changed since my last review:

  • src/web/logs-query.ts (core fix): unchanged — verified byte-identical.
  • tests/web-logs-query.test.ts (3 tests incl. the 64 MB-heap OOM regression): unchanged — still has teeth (fails on the old code, SIGABRT).
  • scripts/live-files.mjs: +2 lines registering tests/web-logs-query.test.ts as a live file (heap-bounded children, private files, no sockets) — correct.
  • tests/e2e/e2e-update-state.test.ts: +5 lines, a sanctioned ci-fixes pin (BILI_STORAGE_JSON_WRITER=on) with a clear comment — the pure-sqlite default #6480 turns the JSON envelope writer off, but this lane asserts on the on-disk .json session file. Test-only, not part of the log-query fix.
  • The rest (release v0.1.214, gate-recorder fix, src/storage/store.ts, plugin manifests, etc.) is master content pulled in by the merge — not the PR author's work.

CI: green on the new head 08fe0a45b — 30 checks, 17 success + 13 skipped, 0 failed (mirror cache, fetched 08:43 UTC, sha matches).

Verdict: APPROVE. Correct, minimal, behavior-preserving, teeth-tested. No kernel / wire / config / persistence touched. Merge left to human.

结构化八问(中文)

  1. 是什么问题:日志时间窗口查询在遇到第一个匹配行之前,把每一行 lead-in 缓冲进无界的 leadIn: string[];同一时间戳的 ≈100MB 前缀会把 64MB 堆撑爆(OOM/SIGABRT)。
  2. 什么原因导致的:windowSelection() 用无界数组缓冲 pre-match 行,而不是复用已有的固定容量 Tail 环形缓冲区;当同一时间戳行数远超显示行数 n 时无限增长。
  3. 影响范围与严重程度:日志时间窗口查询端点;触发条件 = 同一时间戳行数 ≫ n(如 100000 行同戳 + 1 行命中)。p1——进程直接 OOM 崩溃,该查询完全不可用。
  4. 怎么修复的:lead-in 行直接 tail.push(line, false) 进固定容量 Tail 环(上限 n),新增 Tail.clear(),在不连续(ts<loT)与轮转(post-loop !inRange)时清空。内存从「无界」收敛到「≤ n」。
  5. 是否有回归问题:无。核心修复与上一版逐字节相同;逐行追踪密集前缀 / 不连续 / 轮转三类边界,lines/isMatch/omitted/total/shown 与旧 leadIn 路径完全一致;只改了内存上界。未触碰配置 / 线协议 / 持久化 / 内核 / 默认值。
  6. 是否破坏缓存:不涉及——纯日志查询内存管理,不涉缓存 / 重试 / 增量游标 / 去重键。
  7. 是否改了设计方向:不涉及——在既有 Tail 环机制上收敛,无架构 / 边界 / 数据流转向。
  8. 是否引入了新的配置:不涉及——无新 env / config / 默认值(ci-fixes 的 BILI_STORAGE_JSON_WRITER=on 是测试内 pin,非产品配置面)。

收工判定:可合(merge 留给人工)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Re-review after new head 08fe0a45b — still APPROVE. Posted pullrequestreview-5903345361 (id 5903345361, 2026-11-14T09:08:00Z).

The new head is a routine master merge (release v0.1.214 + gate-recorder pipe-leak fix #6671) to refresh PR validation. The core fix is byte-identical to the head I approved earlier (001582239) — src/web/logs-query.ts and tests/web-logs-query.test.ts did not change (verified 0 diff lines).

What changed since my last review:

  • src/web/logs-query.ts (core fix): unchanged — still correct, minimal, behavior-preserving.
  • tests/web-logs-query.test.ts (3 tests incl. the 64 MB-heap OOM regression): unchanged — still has teeth (fails on old code, SIGABRT).
  • scripts/live-files.mjs: +2 lines registering the new test as a live file (heap-bounded children, private files, no sockets) — correct.
  • tests/e2e/e2e-update-state.test.ts: +5 lines, a sanctioned ci-fixes pin (BILI_STORAGE_JSON_WRITER=on) with a clear comment — test-only, not part of the log-query fix.
  • Everything else (src/storage/store.ts, plugin manifests, release v0.1.214, gate-recorder fix) is master content from the merge, not the PR author's work.

CI: green on the new head 08fe0a45b — 30 checks, 17 success + 13 skipped, 0 failed (mirror cache, fetched 08:43 UTC, sha matches).

Verdict: APPROVE. No kernel / wire / config / persistence touched. No small findings to fix on the spot; nothing needing 🔶 需要决策. Merge left to human.

结构化八问(中文)

  1. 是什么问题:日志时间窗口查询在遇到第一个匹配行之前,把每一行 lead-in 缓冲进无界的 leadIn: string[];同一时间戳的 ≈100MB 前缀会把 64MB 堆撑爆(OOM/SIGABRT)。
  2. 什么原因导致的:windowSelection() 用无界数组缓冲 pre-match 行,而不是复用已有的固定容量 Tail 环形缓冲区;当同一时间戳行数远超显示行数 n 时无限增长。
  3. 影响范围与严重程度:日志时间窗口查询端点;触发条件 = 同一时间戳行数 ≫ n(如 100000 行同戳 + 1 行命中)。p1——进程直接 OOM 崩溃,该查询完全不可用。
  4. 怎么修复的:lead-in 行直接 tail.push(line, false) 进固定容量 Tail 环(上限 n),新增 Tail.clear(),在不连续(ts<loT)与轮转(post-loop !inRange)时清空。内存从「无界」收敛到「≤ n」。
  5. 是否有回归问题:无。核心修复与上一版逐字节相同;逐行追踪密集前缀 / 不连续 / 轮转三类边界,lines/isMatch/omitted/total/shown 与旧 leadIn 路径完全一致;只改了内存上界。未触碰配置 / 线协议 / 持久化 / 内核 / 默认值。
  6. 是否破坏缓存:不涉及——纯日志查询内存管理,不涉缓存 / 重试 / 增量游标 / 去重键。
  7. 是否改了设计方向:不涉及——在既有 Tail 环机制上收敛,无架构 / 边界 / 数据流转向。
  8. 是否引入了新的配置:不涉及——无新 env / config / 默认值(ci-fixes 的 BILI_STORAGE_JSON_WRITER=on 是测试内 pin,非产品配置面)。

收工判定:可合(merge 留给人工)。

@ranxianglei
ranxianglei merged commit d5ec514 into ranxianglei:master Nov 14, 2026
50 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6677 (merged as 3858b6956, 2026-11-14).

Landed into master via the real merge commit d5ec514201e (Merge Afloat16/2026-11-12_bounded-log-window (PR #6487)), so your original commits are preserved verbatim in master history — only hashes of the batch wrapper changed, your authorship and commit messages are intact.

The fix for #6486 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix.

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.

Log time-window queries retain an unbounded pre-match context buffer

2 participants