{"record":{"id":"149e338a0aa76860","repo":"juicedata/juicefs","slug":"failed-command-d-v-w","errorCode":null,"errorMessage":"failed command %d %+v: %w","messagePattern":"failed command (.+?) %\\+v: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis_bak.go","lineNumber":730,"sourceCode":"\tcase segTypeStat:\n\t\treturn m.loadDirStats(ctx, val)\n\tcase segTypeParent:\n\t\treturn m.loadParents(ctx, val)\n\tdefault:\n\t\tlogger.Warnf(\"skip segment type %d\", typ)\n\t\treturn nil\n\t}\n}\n\nfunc execPipe(ctx context.Context, pipe redis.Pipeliner) error {\n\tif pipe.Len() == 0 {\n\t\treturn nil\n\t}\n\tcmds, err := pipe.Exec(ctx)\n\tif err != nil {\n\t\tfor i, cmd := range cmds {\n\t\t\tif cmd.Err() != nil {\n\t\t\t\treturn fmt.Errorf(\"failed command %d %+v: %w\", i, cmd, cmd.Err())\n\t\t\t}\n\t\t}\n\t}\n\treturn err\n}\n\nfunc (m *redisMeta) loadFormat(ctx Context, msg proto.Message) error {\n\treturn m.rdb.Set(ctx, m.setting(), msg.(*pb.Format).Data, 0).Err()\n}\n\nfunc (m *redisMeta) loadCounters(ctx Context, msg proto.Message) error {\n\tcs := make(map[string]interface{})\n\n\tfor _, c := range msg.(*pb.Batch).Counters {\n\t\tif c.Key == \"nextInode\" || c.Key == \"nextChunk\" {\n\t\t\tcs[m.counterKey(c.Key)] = c.Value - 1\n\t\t} else {\n\t\t\tcs[m.counterKey(c.Key)] = c.Value","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis_bak.go#L712-L748","documentation":"execPipe runs a batch of read commands (used by loadNodes, loadEdges, loadChunks, loadSustained, loadXattrs) and, when pipe.Exec fails, returns the first individual command that errored along with its index and string form. This pinpoints which specific Redis command in the load pipeline failed during metadata load/restore.","triggerScenarios":"Restoring or loading metadata (juicefs load, warmup paths) when one queued command fails: WRONGTYPE on an existing key, OOM at the server, MOVED errors on a cluster whose keys were not migrated, or connection loss mid-exec.","commonSituations":"Loading a dump into a non-empty Redis database holding conflicting keys of different types; loading a single-node dump into a ClusterClient; Redis maxmemory reached during bulk load.","solutions":["Ensure the target database is empty before load (prepareLoad enforces this — run `juicefs load` against a flushed/new DB).","Read the wrapped cmd.Err(): fix WRONGTYPE conflicts by removing conflicting keys, or raise maxmemory.","When loading into a cluster, use the same cluster topology or hash tags as the source, or load via a standalone Redis then migrate.","Check Redis server logs for OOM or connection issues during the load."],"exampleFix":"// before\nif err := m.execPipe(ctx, txp, func(pipe redis.Pipeliner) error { ... }); err != nil {\n    return err\n}\n// after\nif err := m.execPipe(ctx, txp, func(pipe redis.Pipeliner) error { ... }); err != nil {\n    log.Fatalf(\"metadata load failed, check target DB is empty: %v\", err)\n}","handlingStrategy":"validation","validationCode":"n, _ := rdb.DBSize(ctx).Result()\nif n != 0 { return fmt.Errorf(\"target DB not empty (%d keys); load would conflict\", n) }","typeGuard":null,"tryCatchPattern":"if err := load(ctx, meta, f); err != nil {\n    if strings.Contains(err.Error(), \"WRONGTYPE\") {\n        log.Fatalf(\"target DB holds conflicting keys; flush it before load: %v\", err)\n    }\n    return err\n}","preventionTips":["Always load into a freshly created/flushed database.","Match cluster topology between dump source and load target.","Raise Redis maxmemory or use a dedicated instance for bulk loads.","Read cmd.Err() in the wrapped message — it names the exact failing key."],"tags":["redis","pipeline","metadata-load","wrongtype"],"backgroundTag":"database-write-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"}