{"record":{"id":"3b4101843fe87e3b","repo":"juicedata/juicefs","slug":"failed-to-marshal-footer-w","errorCode":null,"errorMessage":"failed to marshal footer: %w","messagePattern":"failed to marshal footer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/backup.go","lineNumber":184,"sourceCode":"\tif err := footer.Unmarshal(r); err != nil {\n\t\treturn nil, err\n\t}\n\tif footer.Msg.Magic != BakMagic {\n\t\treturn nil, fmt.Errorf(\"invalid magic number %d, expect %d\", footer.Msg.Magic, BakMagic)\n\t}\n\tf.Footer = footer\n\treturn footer, nil\n}\n\ntype BakFooter struct {\n\tMsg *pb.Footer\n\tLen uint64\n}\n\nfunc (h *BakFooter) Marshal(w io.Writer) error {\n\tdata, err := proto.Marshal(h.Msg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal footer: %w\", err)\n\t}\n\n\tif n, err := w.Write(data); err != nil && n != len(data) {\n\t\treturn fmt.Errorf(\"failed to write footer data: err %w, write len %d, expect len %d\", err, n, len(data))\n\t}\n\n\th.Len = uint64(len(data))\n\tif n, err := w.Write(binary.BigEndian.AppendUint64(nil, h.Len)); err != nil && n != 8 {\n\t\treturn fmt.Errorf(\"failed to write footer length: err %w, write len %d, expect len 8\", err, n)\n\t}\n\treturn nil\n}\n\nfunc (h *BakFooter) Unmarshal(r io.ReadSeeker) error {\n\tlenSize := int64(unsafe.Sizeof(h.Len))\n\t_, _ = r.Seek(-lenSize, io.SeekEnd)\n\n\tdata := make([]byte, lenSize)","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/backup.go#L166-L202","documentation":"BakFooter.Marshal serializes the footer's protobuf message before writing it to the backup stream. proto.Marshal failure (invalid message state, nil message, field exceeding limits) aborts footer writing with this wrapped error.","triggerScenarios":"writeFooter calls BakFooter.Marshal when the accumulated Footer.Msg (segment infos, magic) cannot be protobuf-serialized — e.g. a nil Msg pointer or corrupt segment info accumulated during DumpMetaV2.","commonSituations":"Dumping a metadata engine that produced a footer with unserializable content; a bug where footer Msg was never initialized because all segments failed; extreme numbers of segment types pushing message over size limits.","solutions":["Retry the dump; if it reproduces, capture the full log and report with the metadata engine type","Check that segments marshalled successfully before the footer (earlier errors in the log)","Use a matching JuiceFS version for dump and load"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := dumpMetaV2(ctx, w); err != nil {\n    if strings.Contains(err.Error(), \"failed to marshal footer\") {\n        log.Printf(\"footer serialization failed; retry dump and report if persistent\")\n    }\n    return err\n}","preventionTips":["Re-run dumps on failure; treat persistent failure as a bug report","Keep dump/load versions aligned","Ensure segments dump cleanly before footer write"],"tags":["backup","protobuf","footer","serialization"],"backgroundTag":"protobuf-marshal-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}