{"record":{"id":"e81687163565977b","repo":"juicedata/juicefs","slug":"get-dirusedspacekey-err-w","errorCode":null,"errorMessage":"get dirUsedSpaceKey err: %w","messagePattern":"get dirUsedSpaceKey err: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis_bak.go","lineNumber":458,"sourceCode":"\t\treturn fmt.Errorf(\"get dirUsedInodesKey err: %w\", err)\n\t}\n\tfor k, v := range vals {\n\t\tinode, err := strconv.ParseUint(k, 10, 64)\n\t\tif err != nil {\n\t\t\tlogger.Warnf(\"parse inodes stat inode: %s: %v\", k, err)\n\t\t\tcontinue\n\t\t}\n\t\tinodes, _ := strconv.ParseInt(v, 10, 64)\n\t\tif q, ok := stats[Ino(inode)]; !ok {\n\t\t\tlogger.Warnf(\"stat for used inodes not found: %d\", inode)\n\t\t} else {\n\t\t\tq.UsedInodes = inodes\n\t\t}\n\t}\n\n\tvals, err = m.rdb.HGetAll(ctx, m.dirUsedSpaceKey()).Result()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get dirUsedSpaceKey err: %w\", err)\n\t}\n\tfor k, v := range vals {\n\t\tinode, err := strconv.ParseUint(k, 10, 64)\n\t\tif err != nil {\n\t\t\tlogger.Warnf(\"parse space stat inode: %s: %v\", k, err)\n\t\t\tcontinue\n\t\t}\n\t\tspace, _ := strconv.ParseInt(v, 10, 64)\n\t\tif q, ok := stats[Ino(inode)]; !ok {\n\t\t\tlogger.Warnf(\"stat for used space not found: %d\", inode)\n\t\t} else {\n\t\t\tq.UsedSpace = space\n\t\t}\n\t}\n\n\tss := make([]*pb.Stat, 0, min(len(stats), redisBatchSize))\n\tcnt := 0\n\tfor _, s := range stats {","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis_bak.go#L440-L476","documentation":"Wrapped by dumpDirStat in redis_bak.go:458 when HGetAll on dirUsedSpaceKey() (per-directory used-space totals) fails while dumping directory statistics. This is the third of three sequential HGetAll calls; the Redis error is wrapped with the key name and aborts the dump.","triggerScenarios":"Running `juicefs dump` when the final HGetAll (dir used-space hash) errors after the previous two hashes succeeded — typically a mid-dump connection failure, timeout, or cluster routing error.","commonSituations":"Long-running dumps across unstable networks; Redis restarting under memory pressure; auth token/session expiring mid-dump on managed Redis services.","solutions":["Read the wrapped Redis error, fix the underlying issue (network/auth/memory), and re-run the dump.","Retry during lower load or co-locate the dump command with the Redis instance.","Raise client timeouts (read-timeout in the metadata URL) for very large dirstat hashes.","On managed Redis, check service logs for restarts/failovers at the failure timestamp."],"exampleFix":"// before\njuicefs dump redis://managed:6379/1 out.json   // fails at large hash\n// after\njuicefs dump \"redis://managed:6379/1?read-timeout=300s\" out.json","handlingStrategy":"retry","validationCode":"redis-cli -h primary -p 6379 ping && redis-cli -h primary -p 6379 hlen <dirUsedSpaceKey>","typeGuard":null,"tryCatchPattern":"if err := dumpDirStat(...); err != nil {\n    if strings.Contains(err.Error(), \"dirUsedSpaceKey\") {\n        // final hash read failed mid-dump: fix stability, retry the dump\n    }\n    return err\n}","preventionTips":["Raise read-timeout (e.g. ?read-timeout=300s) for large dir-stat datasets.","Check managed-Redis logs for restarts/expiring sessions at the failure time.","Schedule dumps in low-traffic windows on stable infrastructure.","Always re-dump from scratch; never resume from a partial output."],"tags":["redis","dump","dirstat","hgetall"],"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-14T00:17:10.932Z"}