daemon: the evidence store is one JSON string, so a store over ~512 MB fails every check with 'Invalid string length' (DB subset-dedupe, 6 checks on #133)

未关闭
#179 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
领域
backend, databases

调研方向

Start with oracle-gaps/evidence.mjs, where diskStore serializes and reads the entire evidence store, then trace its callers in oracle-gaps/check.mjs and oracle-gaps/daemon.mjs. Choose a storage approach that avoids V8's string length limit. Add the test-only size ceiling and e2e history described in the issue; done means the next daemon check completes when that ceiling is reached.

由索引模型根据 Issue 内容生成。

描述

Summary

The daemon's evidence store (diskStore, evidence.mjs) writes the whole store as one JSON.stringify string and reads it back as one string. V8 caps a string at about 512 MB, so a store past that size makes every later check end in an internal error:

RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at Object.flush (oracle-gaps/evidence.mjs:98:37)
    at checkIn (oracle-gaps/check.mjs:2836:24)
    at async Object.check (oracle-gaps/check.mjs:1693:14)
    at async oracle-gaps/daemon.mjs:525:20

The CLI reports oracle-gaps: error Invalid string length: a bug in oracle-gaps, not in your oracle and exits 3.

Trace

TanStack DB 21c52a07, packages/db --source src/query/subset-dedupe.ts (559 units), Arca pool tag r133-dbb4-all. Each variant ran a daemon sequence from an empty state: a first check, 3 unchanged rechecks and 3 one-line-edit rechecks.

CLI Result Store size
main 97a4e7a8 all 7 checks complete 425 MB at the end
#133 head 9bb7c74a, Vitest cache off the 3rd edit recheck (the 7th check) fails 457 MB at the last good flush
#133 head, Vitest cache on (every check recomputes all units) the 2nd unchanged recheck (the 3rd check) and every later check fail 358 MB at the last good flush

Composition

A store after 2 checks with the cache on (#133 head): 1,114 rows, 1 variant each. Each variant has about 481 inputs (52 KB of JSON) and a unit payload of about 83 KB.

Of the inputs, 261,508 are fs: keys (41 MB), 118,996 are env: keys (10 MB) and 22,662 are stat: keys. #133's every-read inputs add about 60% to a variant. Main already sits at 425 MB after 7 checks, so main reaches the ceiling a few edits later on the same suite.

Proposed fix (choose one)

  • Write and read the store one row per line (JSONL), streamed, so no single string holds the whole store.
  • Or store each distinct input list once, by its hash, and have variants name it, since most units share their env: and node_modules inputs.
  • Or both.

A bound on the store's size is a separate design question. The retention law (bounded retention) covers memory, not this file.

Under P9 the fix needs an oracle-first witness: a test-only knob that lowers the store's size ceiling, so that a constructed e2e history reaches the state with a small store and requires that the next daemon check complete.

Authority

R13 (the daemon is the default) and P10 (an internal error is a CLI defect). Found while measuring #133 for M "Vitest cache off, measured".

This issue was written by Isaac.

主要语言
JavaScript
星标
5
派生
1
平均合并
11 小时 18 分钟
30 天内合并 PR
66

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/oracles 的其他 Issue

查看 TanStack/oracles 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。