{"record":{"id":"21b16e2bb7ae8b2c","repo":"juicedata/juicefs","slug":"invalid-key-s-fail-to-parse-slice-id","errorCode":null,"errorMessage":"invalid key %s, fail to parse slice id","messagePattern":"invalid key (.+?), fail to parse slice id","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis.go","lineNumber":4136,"sourceCode":"\t\t\tts, err := strconv.ParseInt(ps[1], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid key %s, fail to parse timestamp\", key)\n\t\t\t}\n\n\t\t\tm.decodeDelayedSlices([]byte(val), &ss)\n\t\t\tclean, err = scan(ss, ts)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif clean {\n\t\t\t\t_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {\n\t\t\t\t\tfor _, s := range ss {\n\t\t\t\t\t\trs = append(rs, pipe.HIncrBy(ctx, m.sliceRefs(), m.sliceKey(s.Id, s.Size), -1))\n\t\t\t\t\t}\n\t\t\t\t\tpipe.HDel(ctx, m.delSlices(), key)\n\t\t\t\t\tid, err := strconv.ParseUint(ps[0], 10, 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"invalid key %s, fail to parse slice id\", key)\n\t\t\t\t\t}\n\t\t\t\t\tm.genLog(ctx, pipe, time.Now(), \"CLEANUP_TRASH_SLICES(%d,%d)\", id, ts)\n\t\t\t\t\treturn nil\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\terr := m.txn(ctx, task, m.delSlices())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif clean && len(rs) == len(ss) {\n\t\t\tfor i, s := range ss {\n\t\t\t\tif rs[i].Err() == nil && rs[i].Val() < 0 {\n\t\t\t\t\tm.deleteSlice(s.Id, s.Size)\n\t\t\t\t}\n\t\t\t}\n\t\t}","sourceCodeStart":4118,"sourceCodeEnd":4154,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis.go#L4118-L4154","documentation":"Within the cleanup transaction for a delayed-slices entry, the first part of the \"<sliceId>_<ts>\" key must parse as a uint64 slice ID (used for the CLEANUP_TRASH_SLICES log). If ParseUint fails, the transaction rolls back with this error so no refcount decrement or log entry is committed for an unidentifiable slice.","triggerScenarios":"A delSlices key whose timestamp parses but whose ID portion is not a valid uint64 (e.g. \"_1700000000\" or \"12x34_1700000000\") during delayed-slice cleanup.","commonSituations":"Corrupted or manually altered metadata keys; entries produced by incompatible tooling that shares the Redis instance.","solutions":["Inspect and correct/remove the malformed key in the delSlices hash using redis-cli.","Verify slice refcounts with `juicefs gc`/fsck after removing the entry.","Ensure no external tooling writes into JuiceFS metadata keys; give JuiceFS an exclusive Redis DB.","Restore from a metadata backup if multiple keys are malformed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"ps := strings.Split(key, \"_\")\nif len(ps) == 2 { if _, err := strconv.ParseUint(ps[0], 10, 64); err != nil { fmt.Printf(\"bad slice id in key %q\\n\", key) } }","typeGuard":null,"tryCatchPattern":"if err := cleanup(ctx); err != nil && strings.Contains(err.Error(), \"fail to parse slice id\") {\n    logger.Errorf(\"unidentifiable slice key: %v\", err)\n    // transaction rolled back — safe to inspect and repair, then retry\n}","preventionTips":["Audit delSlices hash contents after any manual metadata intervention","Use juicefs gc/fsck rather than direct Redis edits to fix refcounts","Keep client versions homogeneous"],"tags":["redis","key-format","slice-id","delayed-slices"],"backgroundTag":"invalid-identifier-format","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"}