{"record":{"id":"629a3143a474270a","repo":"juicedata/juicefs","slug":"get-chunk-result-err-w","errorCode":null,"errorMessage":"get chunk result err: %w","messagePattern":"get chunk result err: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis_bak.go","lineNumber":568,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tino, _ := strconv.ParseUint(ps[0][len(m.prefix)+1:], 10, 64)\n\t\tidx, _ := strconv.ParseUint(ps[1], 10, 32)\n\t\tpipe.LRange(ctx, m.chunkKey(Ino(ino), uint32(idx)), 0, -1)\n\t\tinos = append(inos, ino)\n\t\tidxs = append(idxs, uint32(idx))\n\t}\n\n\tcmds, err := pipe.Exec(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"chunk pipeline exec err: %w\", err)\n\t}\n\n\tchunks := make([]*pb.Chunk, 0, len(cmds))\n\tfor k, cmd := range cmds {\n\t\tvals, err := cmd.(*redis.StringSliceCmd).Result()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"get chunk result err: %w\", err)\n\t\t}\n\t\tif len(vals) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tpc := pools[0].Get().(*pb.Chunk)\n\t\tpc.Inode = inos[k]\n\t\tpc.Index = idxs[k]\n\n\t\tpc.Slices = pools[1].Get().([]byte)\n\t\tif len(pc.Slices) < len(vals)*sliceBytes {\n\t\t\tpc.Slices = make([]byte, len(vals)*sliceBytes)\n\t\t}\n\t\tpc.Slices = pc.Slices[:len(vals)*sliceBytes]\n\n\t\tfor i, val := range vals {\n\t\t\tif len(val) != sliceBytes {\n\t\t\t\tlogger.Errorf(\"corrupt slice: len=%d, val=%v\", len(val), []byte(val))","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis_bak.go#L550-L586","documentation":"After the chunk pipeline succeeds, dumpChunks iterates each queued StringSliceCmd and calls Result(). This error wraps a per-command failure (typically redis.Nil or an error on that specific chunk record read), aborting the dump at the first bad entry.","triggerScenarios":"A specific HGETALL chunk command inside the executed pipeline fails: key vanished between SCAN and pipeline exec, wrong value type stored at the key, or per-command timeout in cluster mode.","commonSituations":"Concurrent deletion/GC of chunks while dumping; a key with unexpected type left by an older client version or manual tampering; redis.Nil on a key that expired mid-dump.","solutions":["Re-run the dump with the volume quiesced (no writers/GC running) so keys do not disappear mid-scan.","Inspect the failing key's type with TYPE/HGETALL in redis-cli; remove or fix malformed keys only after backing up.","If redis.Nil from expiry is expected, ensure no TTLs are set on JuiceFS-managed keys.","Update old clients that may write incompatible chunk records."],"exampleFix":"// before\nvals, err := cmd.(*redis.StringSliceCmd).Result()\nif err != nil {\n    return fmt.Errorf(\"get chunk result err: %w\", err)\n}\n// after (skip vanished keys during dump)\nvals, err := cmd.(*redis.StringSliceCmd).Result()\nif err == redis.Nil {\n    continue\n}\nif err != nil {\n    return fmt.Errorf(\"get chunk result err: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// before dumping, confirm chunk keys have the expected type\niter := rdb.Scan(ctx, 0, \"*chunk*\", 100).Iterator()\nfor iter.Next(ctx) {\n    t, _ := rdb.Type(ctx, iter.Val()).Result()\n    if t != \"hash\" { log.Printf(\"unexpected type %s at %s\", t, iter.Val()) }\n}","typeGuard":null,"tryCatchPattern":"if err := dumpMeta(ctx, src, dst); err != nil {\n    var re *redis.RedisError\n    if errors.As(err, &re) && strings.Contains(err.Error(), \"WRONGTYPE\") {\n        log.Fatalf(\"corrupt/foreign key in chunk data: %v — inspect with TYPE/HGETALL\", err)\n    }\n    return err\n}","preventionTips":["Quiesce writers and GC during dumps so chunk keys are not deleted mid-scan.","Never set TTLs on JuiceFS-managed Redis keys.","Periodically audit key types in the metadata DB.","Keep all clients on a compatible JuiceFS version."],"tags":["redis","pipeline","chunk","metadata-dump"],"backgroundTag":"database-query-failed","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"}