{"record":{"id":"10ca711cf3753229","repo":"juicedata/juicefs","slug":"verify-checksum-failed-d-d","errorCode":null,"errorMessage":"verify checksum failed: %d != %d","messagePattern":"verify checksum failed: (.+?) != (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/object/checksum.go","lineNumber":68,"sourceCode":"\t\t}\n\t}\n\treturn strconv.Itoa(int(hash))\n}\n\ntype checksumReader struct {\n\tio.ReadCloser\n\texpected        uint32\n\tchecksum        uint32\n\tremainingLength int64\n\ttable           *crc32.Table\n}\n\nfunc (c *checksumReader) Read(buf []byte) (n int, err error) {\n\tn, err = c.ReadCloser.Read(buf)\n\tc.checksum = crc32.Update(c.checksum, c.table, buf[:n])\n\tc.remainingLength -= int64(n)\n\tif (err == io.EOF || c.remainingLength == 0) && c.checksum != c.expected {\n\t\treturn 0, fmt.Errorf(\"verify checksum failed: %d != %d\", c.checksum, c.expected)\n\t}\n\treturn\n}\nfunc verifyChecksum(in io.ReadCloser, checksum string, contentLength int64) io.ReadCloser {\n\treturn verifyChecksum0(in, checksum, contentLength, crc32c)\n}\nfunc verifyChecksum0(in io.ReadCloser, checksum string, contentLength int64, table *crc32.Table) io.ReadCloser {\n\tif checksum == \"\" {\n\t\treturn in\n\t}\n\texpected, err := strconv.Atoi(checksum)\n\tif err != nil {\n\t\tlogger.Errorf(\"invalid crc32c: %s\", checksum)\n\t\treturn in\n\t}\n\treturn &checksumReader{in, uint32(expected), 0, contentLength, table}\n}\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/checksum.go#L50-L86","documentation":"checksumReader transparently CRC32C-checksums data as it streams from object storage. When the stream ends (io.EOF) or the expected remaining length is consumed, the running checksum must equal the expected value recorded by the writer; otherwise the data was corrupted in transit/storage and Read returns this error with the computed vs expected CRC values.","triggerScenarios":"Reading an object whose uploaded content does not match its recorded checksum: bit rot in the object store, truncated upload, buggy third-party writer, or a corrupted cache layer feeding wrong bytes for the expected length.","commonSituations":"Network corruption between object storage and client; partial/multipart upload that was truncated; disk errors on storage node; mismatched checksum metadata after a manual object replacement in the bucket.","solutions":["Re-upload/re-copy the affected object to restore a consistent checksum","Verify the object in the bucket (compare CRC32C of downloaded bytes with stored metadata)","Check object storage backend health/disk (SMART, scrubbing) for silent corruption","If a proxy/cache sits between client and storage, disable it and retest to isolate the corruption point"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: verify object integrity proactively after writing\nmeta, _ := obj.Head(ctx, key)\n// compare meta size/content-length with what you uploaded before reading back","typeGuard":null,"tryCatchPattern":"// Go\ndata, err := obj.Get(ctx, key, 0, -1)\nif err != nil && strings.Contains(err.Error(), \"verify checksum failed\") {\n    // treat as corruption: re-upload object or fail the read loudly; never retry in place\n}","preventionTips":["Monitor storage backend health (scrubbing, SMART) for silent corruption","Avoid manually replacing objects in the bucket out-of-band","Keep client and writer versions aligned so checksum metadata matches the data written"],"tags":["object-storage","checksum","data-corruption","crc32"],"backgroundTag":"checksum-mismatch","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"}