{"record":{"id":"ff91aae68d4ea1b6","repo":"juicedata/juicefs","slug":"get-dirdatalengthkey-err-w","errorCode":null,"errorMessage":"get dirDataLengthKey err: %w","messagePattern":"get dirDataLengthKey err: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis_bak.go","lineNumber":423,"sourceCode":"\t}\n\tif err := m.dumpQuotas(ctx, &userQuotas, UserQuotaType); err != nil {\n\t\treturn err\n\t}\n\tif err := m.dumpQuotas(ctx, &groupQuotas, GroupQuotaType); err != nil {\n\t\treturn err\n\t}\n\treturn dumpResult(ctx, ch, &dumpedResult{msg: &pb.Batch{\n\t\tQuotas:      dirQuotas,\n\t\tUserQuotas:  userQuotas,\n\t\tGroupQuotas: groupQuotas,\n\t}})\n}\n\nfunc (m *redisMeta) dumpDirStat(ctx Context, opt *DumpOption, ch chan<- *dumpedResult) error {\n\tstats := make(map[Ino]*pb.Stat)\n\tvals, err := m.rdb.HGetAll(ctx, m.dirDataLengthKey()).Result()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get dirDataLengthKey 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 length stat inode: %s: %v\", k, err)\n\t\t\tcontinue\n\t\t}\n\t\tlength, _ := strconv.ParseInt(v, 10, 64)\n\t\tstats[Ino(inode)] = &pb.Stat{\n\t\t\tInode:      inode,\n\t\t\tDataLength: length,\n\t\t}\n\t}\n\n\tvals, err = m.rdb.HGetAll(ctx, m.dirUsedInodesKey()).Result()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get dirUsedInodesKey err: %w\", err)\n\t}","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis_bak.go#L405-L441","documentation":"Wrapped by dumpDirStat in redis_bak.go:423 when HGetAll on dirDataLengthKey() (the hash of per-directory aggregated data lengths) fails while dumping directory statistics. The dump's dirstat section is aborted and the Redis error is surfaced with the key name for diagnosis.","triggerScenarios":"Running `juicefs dump --dirs` (or a dump that includes dir stats) when HGetAll on the dir-data-length hash errors — connection drop, cluster MOVED, auth failure, or timeout.","commonSituations":"Large dirstat hashes taking long enough to hit a network timeout; Redis under memory pressure evicting/failing commands; dumping through a proxy that drops long connections.","solutions":["Fix the underlying Redis error reported after the colon (connectivity, auth, cluster config) and re-run the dump.","Increase the Redis client timeout for large hashes or dump over a faster link.","If keys are being evicted (maxmemory-policy), use noeviction or raise maxmemory so the hash remains intact.","Retry the dump; if it repeatedly fails at the same key, verify the key exists and is healthy with redis-cli HLEN."],"exampleFix":"// before: default timeouts drop long HGETALL\n// after: raise timeouts in the metadata URL\njuicefs dump \"redis://primary:6379/1?read-timeout=120s\" out.json","handlingStrategy":"retry","validationCode":"redis-cli -h primary -p 6379 hlen <dirDataLengthKey>  # confirm hash readable before dump","typeGuard":null,"tryCatchPattern":"if err := dumpDirStat(...); err != nil {\n    if strings.Contains(err.Error(), \"dirDataLengthKey\") {\n        // raise read-timeout or retry on a stable connection\n    }\n    return err\n}","preventionTips":["Increase read-timeout in the metadata URL for very large dirstat hashes.","Use a noeviction maxmemory policy so hashes aren't evicted mid-scan.","Dump over a fast, stable link or co-locate with the Redis instance.","Verify the key with HLEN via redis-cli if failures repeat at the same step."],"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-14T05:17:10.506Z"}