{"record":{"id":"a9c3d500d0a0002d","repo":"juicedata/juicefs","slug":"stage-footer-size-mismatch-offset-d-size-d-fi","errorCode":null,"errorMessage":"stage footer size mismatch: offset %d, size %d, file size %d","messagePattern":"stage footer size mismatch: offset (.+?), size (.+?), file size (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache_file.go","lineNumber":98,"sourceCode":"\nfunc (f *stageFooter) unmarshal(cf *cacheFile) error {\n\tif cf.footerOff == 0 {\n\t\tf.Tier = 0 // no footer, fall back to the default\n\t\treturn nil\n\t}\n\tvar hdr [4]byte\n\tif _, err := cf.File.ReadAt(hdr[:], cf.footerOff); err != nil {\n\t\treturn fmt.Errorf(\"read stage footer header: %w\", err)\n\t}\n\tif magic := binary.BigEndian.Uint16(hdr[:2]); magic != stageFooterMagic {\n\t\treturn fmt.Errorf(\"invalid stage footer magic %#04x\", magic)\n\t}\n\tsize := int64(binary.BigEndian.Uint16(hdr[2:4]))\n\tif size == 0 {\n\t\treturn fmt.Errorf(\"invalid stage footer length %d\", size)\n\t}\n\tif cf.footerOff+4+size != cf.size {\n\t\treturn fmt.Errorf(\"stage footer size mismatch: offset %d, size %d, file size %d\", cf.footerOff, size, cf.size)\n\t}\n\tbuf := make([]byte, size)\n\tif _, err := cf.File.ReadAt(buf, cf.footerOff+4); err != nil {\n\t\treturn fmt.Errorf(\"read stage footer data: %w\", err)\n\t}\n\tif err := msgpack.Unmarshal(buf, f); err != nil {\n\t\treturn err\n\t}\n\tif f.Tier > maxTierID {\n\t\tf.Tier = 0 // ignore unknown/corrupted tier, fall back to the default\n\t}\n\treturn nil\n}\n\nvar (\n\tstageFooterBaseLen int\n\tstageFooterPad     [4][]byte\n\tstageFooterMagic   = uint16(0x4653)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache_file.go#L80-L116","documentation":"Returned by stageFooter.unmarshal when the footer offset plus header plus declared size does not equal the actual file size — the staged cache file layout is inconsistent, indicating truncation or partial writes.","triggerScenarios":"Thrown at pkg/chunk/disk_cache_file.go:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Discard the inconsistent staged file so staging is retried","Check for processes truncating files in the cache dir"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}