juicedata/juicefs · error
invalid key %s, fail to parse slice id
Error message
invalid key %s, fail to parse slice id
What it means
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.
Source
Thrown at pkg/meta/redis.go:4136
ts, err := strconv.ParseInt(ps[1], 10, 64)
if err != nil {
return fmt.Errorf("invalid key %s, fail to parse timestamp", key)
}
m.decodeDelayedSlices([]byte(val), &ss)
clean, err = scan(ss, ts)
if err != nil {
return err
}
if clean {
_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
for _, s := range ss {
rs = append(rs, pipe.HIncrBy(ctx, m.sliceRefs(), m.sliceKey(s.Id, s.Size), -1))
}
pipe.HDel(ctx, m.delSlices(), key)
id, err := strconv.ParseUint(ps[0], 10, 64)
if err != nil {
return fmt.Errorf("invalid key %s, fail to parse slice id", key)
}
m.genLog(ctx, pipe, time.Now(), "CLEANUP_TRASH_SLICES(%d,%d)", id, ts)
return nil
})
}
return err
}
err := m.txn(ctx, task, m.delSlices())
if err != nil {
return err
}
if clean && len(rs) == len(ss) {
for i, s := range ss {
if rs[i].Err() == nil && rs[i].Val() < 0 {
m.deleteSlice(s.Id, s.Size)
}
}
}View on GitHub (pinned to c9a67b23e8)
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.
Defensive patterns
Strategy: validation
Validate before calling
ps := strings.Split(key, "_")
if len(ps) == 2 { if _, err := strconv.ParseUint(ps[0], 10, 64); err != nil { fmt.Printf("bad slice id in key %q\n", key) } } Try / catch
if err := cleanup(ctx); err != nil && strings.Contains(err.Error(), "fail to parse slice id") {
logger.Errorf("unidentifiable slice key: %v", err)
// transaction rolled back — safe to inspect and repair, then retry
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Corrupted or manually altered metadata keys; entries produced by incompatible tooling that shares the Redis instance.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- invalid key %s
- invalid key %s, fail to parse timestamp
- invalid value for delSlices %s: %v
- invalid key %s, fail to parse id
- invalid key %s, fail to parse size
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/21b16e2bb7ae8b2c.
Report an issue: GitHub.