fix(dsh): replace instead of append compaction-capsule sources - #91
Open
evilh2019 wants to merge 2 commits into
Open
fix(dsh): replace instead of append compaction-capsule sources#91evilh2019 wants to merge 2 commits into
evilh2019 wants to merge 2 commits into
Conversation
recordCompactionCapsule appended every shadowed span to the stable session-memory-<hash> node forever, so long sessions grew gm_node_sources without bound (observed: one node with 10559 rows, 30% of the table). Add replaceNodeSources() and use it for capsule nodes so a fresh summary supersedes the previously shadowed span instead of accumulating every old span. Extraction-path nodes keep their append semantics unchanged. Co-authored-by: xiaod1 <xiaod1@localhost>
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.
问题
recordCompactionCapsule(dsh.ts)每次 DSH 会话滚动压缩产生compaction/summary事件时,把被压缩掉的shadowedSeqs追加为稳定名节点session-memory-<sha1(sid)[0:16]>的 source。由于:saveNodeSources纯INSERT OR IGNORE,无任何删除/上限/TTL实测:单一会话节点积累 10559 条 source,占全表
gm_node_sources(34392 行)的 30.7%;节点 content 只有最新一份摘要(12KB),却声称代表 1 万条消息。DB 体积膨胀至 123MB,且每次压缩都重新 embedding 摘要。修复
replaceNodeSources(db, nodeId, sessionId, sources):DELETE 该节点全部旧 source 后 INSERT 本次,替换而非追加。recordCompactionCapsule改为调用replaceNodeSources:新摘要取代旧 span,节点永远只引用最近一份压缩。验证
tsc构建 exit 0。影响面
gm_node_sources唯一消费方是assembleContext的 episodic 溯源(getNodeSourceMessages),替换后溯源指向最近一份压缩的证据,更准确。