候选归档 79 版 / 56MB blob 上,overview、storage、snapshots 三个只读接口 都在 10s 请求期限后返回 503。分段计时定位到唯一瓶颈是按版本重读全部 blob: Open 0ms、LoadManifest×79 11~22ms、ContentUsage 15~25ms、 Usage(逐版 Load 验字节)13.75~14.11s;单版 Load 261~290ms。 - Usage 拆成 Usage(逐版复核字节,同步/恢复与运维 CLI 用)与 UsageFromManifests(同一份去重实现,只做清单级校验),列举路径改用后者; - library_storage.go 每版两次 Load、snapshots 每版一次 Load 改为一次清单读取; - wiki/文档差异只读所需部件,被读部件仍由 OpenPart 复核摘要; - LoadManifest 与 Load 共用同一套清单判据(严格解码 + 重新编码校验); - 列举响应带 verification=manifest / verified=false,详情整版复核后才是 content, 避免把"清单可读"读成"完整性已验证"; - libraryWithDeadline 去掉超时后再写已结束响应的 goroutine 写法 (候选环境实测 http: superfluous response.WriteHeader call)。 回归:多版本共享大 blob 时枚举不读 blob 字节(篡改后枚举仍成功), 而 Load/OpenPart/Usage 仍拒绝坏 blob;坏清单两条路径都整条报错。 make verify 15 项全绿(local 档案)。
This commit is contained in:
@@ -45,10 +45,27 @@ func (a *Archive) OpenPart(p Part) (io.ReadCloser, error) {
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// Usage reports content bytes, not filesystem allocation or reclaimed space.
|
||||
// It is deliberately read-only: protection/retention and live-job references
|
||||
// must be acquired from the coordinator before any future cleanup operation.
|
||||
func (a *Archive) Usage() ([]Usage, error) {
|
||||
// Usage reports content bytes per version and is **verified**: every referenced
|
||||
// blob is re-read and re-hashed through Load. Execution paths (sync/restore) and
|
||||
// the operator CLI use it, because acting on a version must not trust the
|
||||
// manifest's own claim about bytes it did not check.
|
||||
func (a *Archive) Usage() ([]Usage, error) { return a.usage(a.Load) }
|
||||
|
||||
// UsageFromManifests is the read-only listing counterpart: the same accounting,
|
||||
// but it validates only each manifest's own digest/structure instead of
|
||||
// re-hashing every blob.
|
||||
//
|
||||
// Why it exists: a listing does not execute anything, and re-hashing every blob
|
||||
// of every version turned a 15 ms inventory into a 13.8 s timeout at 79 versions
|
||||
// (measured on the candidate archive). Keep the numbers real: they are recomputed
|
||||
// from the current inventory on every call, under the same "inventory must not
|
||||
// change while reading" guard, and an unreadable/invalid manifest still fails the
|
||||
// whole read. What this does *not* prove is that the referenced bytes are intact —
|
||||
// Load/OpenPart still decide that, and callers must not report this as
|
||||
// "integrity verified".
|
||||
func (a *Archive) UsageFromManifests() ([]Usage, error) { return a.usage(a.LoadManifest) }
|
||||
|
||||
func (a *Archive) usage(load func(string) (Manifest, error)) ([]Usage, error) {
|
||||
ids, err := a.versionIDs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -60,7 +77,7 @@ func (a *Archive) Usage() ([]Usage, error) {
|
||||
inventories := make([]inventory, 0, len(ids))
|
||||
refs := map[string]int{}
|
||||
for _, id := range ids {
|
||||
m, err := a.Load(id)
|
||||
m, err := load(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user