Repository navigation
fix(aggregate): guard trace fragment materialization allocations - #218
Merged
Merged
Conversation
为 tracing 分片复杂规则物化和超限/混合格式回退增加分配前保护: 累计解码大小上限 64 MiB,进程共享 256 MiB 工作预算和 4 并发许可, 逐片按已预留输出容量解码,全部内容验证成功后才申请合并数组。 候选合并成功后再替换原组;错误释放预算并保留原组,决策记为 unknown。 新增有界解码 API,保持原公共解码 API 对未知 FCS 的兼容行为。 风险:永久超限或损坏的分组无法物化;临时预算不足会等待。 工作预算独立于调用方发送预算,不是进程 RSS 硬限制。 未启用分片缓冲和 spiller 路径保持原有实现。 验证:小内存探针修复前失败(约 12.6 MB),修复后通过(约 4.2 MB); go test -race ./aggregate -count=1 -timeout=60s 通过; golangci-lint run --new-from-rev=ef82a6ce --timeout=5m 为 0 issues。 已运行 LINT_FIX=false make lint(67 个历史问题)和 copyright_check (历史缺失 header);新增文件含 MIT header。 timeout 240s make test 未完成,diskcache 压测触发 disk quota exceeded。 未执行真实 OOM 复现。 关联 Dataway issue #129 和后续分片内存安全修复。
复审确认 DecodeAll 的 raw/RLE/generic 路径可能先增长一个块再报错, 不能仅将 WithDecodeAllCapLimit 当成分配前保护。 让公共有界解码(供 Dataway batcher 使用)与分片物化共享工作准入: 每任务按 4*decoded+1MiB 预留,容量257MiB/并发4。物化使用已取得 许可的 private core,避免嵌套申请;专用重编码目标按 MaxEncodedSize 预分配,保持公共压缩接口行为。 风险:预算不含 codec 自有的固定 scratch,不是 RSS 硬限制。 临时预算不足会等待;成功返回仍要求长度与 FCS 和调用方限额一致。 验证:go test -race ./aggregate -count=1 -timeout=60s 通过; 覆盖非single-segment低报FCS块级分配、共享等待/错误释放及防嵌套获取。 Spec 增量复审剩余发现0项。完整库检查的环境/历史限制见前一提交。
leecha
approved these changes
Nov 9, 2026
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.
同一 trace 的多个 zstd 分片在复杂规则物化或超限/混合格式回退时,原实现直接按未经内容验证的累计 FCS 分配合并数组,可能在解码器报错前触发大额分配。本修复在任何解码/合并分配之前加入单组限额和进程共享工作准入。
关联:Dataway issue #129,原分片优化 PR #217、Dataway MR !226。本 PR 为独立安全修复。
改动链路:
4*decoded+1 MiB。DecompressPointsPayloadWithLimit与物化共用工作预算;物化内部调用已持有许可的内核,避免嵌套等待。底层 DecodeAll 可能先增长一个块再报错,块级输出余量已纳入预留,不能只依赖 WithDecodeAllCapLimit。风险与边界:永久超限或损坏的分组不能物化;临时容量不足等待许可。预算针对 payload 工作数组,不包含编码器固定 history/table 等 scratch,也不是整个进程的堆/RSS 硬限制。正常发送端还须维护自己的驻留字节预算。
验证:
go test -race ./aggregate -count=1 -timeout=60s:通过,包含累计超限、极大声明的纯预检、回退原子性、预算等待/释放、共享准入、防嵌套获取、非 single-segment 低报 FCS 的块级分配回归。golangci-lint run --new-from-rev=ef82a6ce --timeout=5m:0 issues。LINT_FIX=false make lint:全库仍有 67 个历史问题(godoclint 16、iotamixing 1、modernize 50);本次增量无新增。make copyright_check:历史文件缺失 header 导致失败;本次新增文件均有 MIT header。timeout 240s make test:未完成;diskcache 压测出现disk quota exceeded,其余尚有耗时包。受影响 aggregate 的完整 race 测试已单独通过,不将全库检查表述为通过。复审结果:规范轴无硬性违规,文案建议已修正;需求/安全轴发现的块级扩容预算旁路已补齐,增量复审剩余发现 0 项。Dataway 将正常更新此 PR 的公开提交并通过 tidy/vendor 同步依赖,单独运行默认 vendor 模式检查。