Archive: a segment damaged before its first event reads as an empty one
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- go
调研方向
Start by tracing how readRecordsWith in core/session/archive/reader.go reports truncation through Page and Earlier in core/session/archive/read.go, then check replay callers in core/session/archive/replay.go and the pre-first-record branch in core/sessionapi/export.go. The issue leaves open whether to propagate the flag or return an error for damage before the first event, so check the compatibility implications for callers outside this repo. Add the garbage-first-bytes test expecting HTTP 500, and update the export comments and docs/session-export.md once the behavior is settled.
由索引模型根据 Issue 内容生成。
描述
Split out of the #1830 review.
What happens
readRecordsWith (core/session/archive/reader.go) reports a torn tail or an
undecodable line as truncated=true, err=nil — a property of the data, not a
failure. Page then discards that flag (_, err := readSegment(...) in
core/session/archive/read.go:57), so no caller above it can tell a damaged
segment from a complete one.
For the paging endpoints that is the intended, documented behaviour: serve the
readable prefix. But a segment damaged before its first event has no readable
prefix, so it contributes nothing and is indistinguishable from an empty archive:
segment -> 39 bytes of non-zstd garbage GET /v1/export 200 application/x-ndjson ""
segment -> symlink loop (ELOOP) GET /v1/export 500 {"error":"archive read failed"}
Only a segment that cannot be opened produces an error today. GET /v1/export
(#1830) documents this as the tolerated case, and docs/session-export.md says an
export is not a way to detect a corrupt archive — but "nothing happened this month"
and "this month will not decode" really are different answers, and a backup/export
consumer is exactly who wants to tell them apart.
What to do
Hand truncated up from Page/Earlier, or distinguish "torn before the first
event in a non-empty file" from "torn tail" and return that as an error. Then
handleExport's pre-first-record branch catches it and answers 500, and the
claims in core/sessionapi/export.go and docs/session-export.md can be
strengthened back.
This is an archive-package change with paging and replay as callers, which is why
it is not in #1830. core/ is consumed outside this repo, so a signature change
needs the usual care.
Scope
core/session/archive/{reader,read,replay}.gocore/sessionapi/export.gocomments +docs/session-export.mdonce it lands- a test with a segment whose first bytes are garbage, asserting 500 rather than an empty 200
Refs #1810, #1830
Assisted-By: Claude (Anthropic AI) [email protected]
- 主要语言
- Go
- 星标
- 31
- 派生
- 49
- 平均合并
- 9 小时 43 分钟
- 30 天内合并 PR
- 367
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rossoctl/cortex 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug laptop
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
相似的 Issue
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behind可能已有人在做 @arshil42 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 80/100
ether/etherpad-go#571 ·
维护者通常 1 天内回复
-
labeler: read a limit above math.MaxInt as math.MaxInt in nonNegative (CodeQL alerts #20 and #21)未关闭cost:approved factory:queued factory:tracking priority:p2 rank:12 ready-for-doing task:approved tokens:50k
难度 2/5 1-3 小时 新手友好度 88/100
sisaku-security/sisakulint#860 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100