{"record":{"id":"103e9f7a40bab9e2","repo":"juicedata/juicefs","slug":"copied-s-size-mismatch-original-d-current-d","errorCode":null,"errorMessage":"copied %s size mismatch: original=%d, current=%d","messagePattern":"copied (.+?) size mismatch: original=(.+?), current=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/sync/sync.go","lineNumber":1251,"sourceCode":"\t\treturn nil // ignore symlink\n\t}\n\tif cur, err := src.Head(ctx, key); err == nil {\n\t\tif !config.CheckAll && !config.CheckNew {\n\t\t\tchecked.Increment()\n\t\t\tcheckedBytes.IncrInt64(obj.Size())\n\t\t}\n\t\tequal := cur.Size() == obj.Size()\n\t\tif equal && !cur.Mtime().Equal(obj.Mtime()) {\n\t\t\t// Head of an object may not return the millisecond part of mtime as List\n\t\t\tequal = cur.Mtime().Unix() == obj.Mtime().Unix() && cur.Mtime().UnixMilli()%1000 == 0\n\t\t}\n\t\tif !equal {\n\t\t\treturn fmt.Errorf(\"%s changed during sync. Original: size=%d, mtime=%s; Current: size=%d, mtime=%s\",\n\t\t\t\tcur.Key(), obj.Size(), obj.Mtime(), cur.Size(), cur.Mtime())\n\t\t}\n\t\tif dstObj, err := dst.Head(ctx, key); err == nil {\n\t\t\tif cur.Size() != dstObj.Size() {\n\t\t\t\treturn fmt.Errorf(\"copied %s size mismatch: original=%d, current=%d\", key, obj.Size(), dstObj.Size())\n\t\t\t}\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"check %s in %s: %s\", key, dst, err)\n\t\t}\n\t} else if errors.Is(err, os.ErrNotExist) {\n\t\treturn fmt.Errorf(\"object %s was removed during sync\", key)\n\t} else {\n\t\treturn fmt.Errorf(\"check %s in %s: %s\", key, src, err)\n\t}\n}\n\nfunc copyLink(src object.ObjectStorage, dst object.ObjectStorage, key string) error {\n\tvar p string\n\tvar err error\n\tif p, err = src.(object.SupportSymlink).Readlink(key); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":1233,"sourceCodeEnd":1269,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/sync/sync.go#L1233-L1269","documentation":"Raised by checkChange after the source object was confirmed unchanged: a Head on the destination shows the copied object's size doesn't match the source's. The copy itself produced a wrong-size object — a data-integrity failure of dst.","triggerScenarios":"checkChange: cur (src Head) equals the originally listed object; then dst.Head succeeds but dstObj.Size() != cur.Size(), so the already-copied object has the wrong size.","commonSituations":"Destination backend truncating or appending data (flaky storage, quota effects, concurrent writers to the same destination key); a partially failed earlier copy left a short object that sync then considered copied; custom/broken object storage implementations reporting or storing wrong sizes.","solutions":["Delete the destination object and rerun sync for that key so it is fully recopied.","Check for concurrent writers to the same destination key and make the sync exclusive.","Verify the destination backend's integrity (read back and checksum the object).","If using a custom object.ObjectStorage, audit its Put/Head size accounting."],"exampleFix":"# remove corrupt destination object and resync\njuicefs rm dst:bucket/key\njuicefs sync src dst --include key","handlingStrategy":"retry","validationCode":"cur, err := dst.Head(ctx, key)\nif err == nil && cur.Size() != expectedSize {\n  return fmt.Errorf(\"recopy needed for %s\", key)\n}","typeGuard":null,"tryCatchPattern":"if err := sync(...); err != nil && strings.Contains(err.Error(), \"size mismatch\") {\n  _ = dst.Delete(ctx, extractKey(err)) // remove corrupt copy\n  return sync(...)                     // full recopy\n}","preventionTips":["Make syncs exclusive per destination key; no concurrent writers.","Delete the mismatching destination object before rerunning sync.","Audit custom object storage implementations for size accounting bugs.","Read back and checksum large copies to catch backend corruption."],"tags":["sync","data-integrity","size-mismatch"],"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"}