juicedata/juicefs · error

get chunk result err: %w

Error message

get chunk result err: %w

What it means

After the chunk pipeline succeeds, dumpChunks iterates each queued StringSliceCmd and calls Result(). This error wraps a per-command failure (typically redis.Nil or an error on that specific chunk record read), aborting the dump at the first bad entry.

Source

Thrown at pkg/meta/redis_bak.go:568

			continue
		}
		ino, _ := strconv.ParseUint(ps[0][len(m.prefix)+1:], 10, 64)
		idx, _ := strconv.ParseUint(ps[1], 10, 32)
		pipe.LRange(ctx, m.chunkKey(Ino(ino), uint32(idx)), 0, -1)
		inos = append(inos, ino)
		idxs = append(idxs, uint32(idx))
	}

	cmds, err := pipe.Exec(ctx)
	if err != nil {
		return fmt.Errorf("chunk pipeline exec err: %w", err)
	}

	chunks := make([]*pb.Chunk, 0, len(cmds))
	for k, cmd := range cmds {
		vals, err := cmd.(*redis.StringSliceCmd).Result()
		if err != nil {
			return fmt.Errorf("get chunk result err: %w", err)
		}
		if len(vals) == 0 {
			continue
		}

		pc := pools[0].Get().(*pb.Chunk)
		pc.Inode = inos[k]
		pc.Index = idxs[k]

		pc.Slices = pools[1].Get().([]byte)
		if len(pc.Slices) < len(vals)*sliceBytes {
			pc.Slices = make([]byte, len(vals)*sliceBytes)
		}
		pc.Slices = pc.Slices[:len(vals)*sliceBytes]

		for i, val := range vals {
			if len(val) != sliceBytes {
				logger.Errorf("corrupt slice: len=%d, val=%v", len(val), []byte(val))

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Re-run the dump with the volume quiesced (no writers/GC running) so keys do not disappear mid-scan.
  2. Inspect the failing key's type with TYPE/HGETALL in redis-cli; remove or fix malformed keys only after backing up.
  3. If redis.Nil from expiry is expected, ensure no TTLs are set on JuiceFS-managed keys.
  4. Update old clients that may write incompatible chunk records.

Example fix

// before
vals, err := cmd.(*redis.StringSliceCmd).Result()
if err != nil {
    return fmt.Errorf("get chunk result err: %w", err)
}
// after (skip vanished keys during dump)
vals, err := cmd.(*redis.StringSliceCmd).Result()
if err == redis.Nil {
    continue
}
if err != nil {
    return fmt.Errorf("get chunk result err: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before dumping, confirm chunk keys have the expected type
iter := rdb.Scan(ctx, 0, "*chunk*", 100).Iterator()
for iter.Next(ctx) {
    t, _ := rdb.Type(ctx, iter.Val()).Result()
    if t != "hash" { log.Printf("unexpected type %s at %s", t, iter.Val()) }
}

Try / catch

if err := dumpMeta(ctx, src, dst); err != nil {
    var re *redis.RedisError
    if errors.As(err, &re) && strings.Contains(err.Error(), "WRONGTYPE") {
        log.Fatalf("corrupt/foreign key in chunk data: %v — inspect with TYPE/HGETALL", err)
    }
    return err
}

Prevention

When it happens

Trigger: A specific HGETALL chunk command inside the executed pipeline fails: key vanished between SCAN and pipeline exec, wrong value type stored at the key, or per-command timeout in cluster mode.

Common situations: Concurrent deletion/GC of chunks while dumping; a key with unexpected type left by an older client version or manual tampering; redis.Nil on a key that expired mid-dump.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/629a3143a474270a. Report an issue: GitHub.