juicedata/juicefs · error

get counter %s

Error message

get counter %s

What it means

Raised by redisMeta.dumpCounters while dumping metadata: for each well-known counter (counterNames) the code calls m.getCounter(name), and any failure reading a counter from Redis is wrapped with "get counter <name>". DumpMeta needs all counters (usedInode, usedSpace, nextInode, nextChunk, etc.) to serialize a complete metadata image, so a read failure aborts the dump.

Source

Thrown at pkg/meta/redis_bak.go:70

		m.dumpACL,
		m.dumpQuota,
		m.dumpDirStat,
	}
	for _, f := range dumps {
		err := f(ctx, opt, ch)
		if err != nil {
			return err
		}
	}
	return nil
}

func (m *redisMeta) dumpCounters(ctx Context, opt *DumpOption, ch chan<- *dumpedResult) error {
	counters := make([]*pb.Counter, 0, len(counterNames)+1)
	for _, name := range counterNames {
		cnt, err := m.getCounter(name)
		if err != nil {
			return errors.Wrapf(err, "get counter %s", name)
		}
		if name == "nextInode" || name == "nextChunk" {
			cnt++ // Redis nextInode/nextChunk is one smaller than db
		}
		counters = append(counters, &pb.Counter{Key: name, Value: cnt})
	}
	if m.getFormat().ChangeLog {
		lastLog, err := m.rdb.Get(ctx, m.txnLastLog()).Int64()
		if err == nil {
			counters = append(counters, &pb.Counter{Key: "lastChangelog", Value: lastLog})
		}
	}
	return dumpResult(ctx, ch, &dumpedResult{msg: &pb.Batch{Counters: counters}})
}

func (m *redisMeta) dumpMix(ctx Context, opt *DumpOption, ch chan<- *dumpedResult) error {
	logger.Warnf("please make sure the redis server is readonly, otherwise the dumped metadata will be inconsistent")
	pools := map[int][]*sync.Pool{

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Retry the dump once Redis connectivity is stable; counters are simple GETs and the failure is usually transient.
  2. Confirm the Redis endpoint is a primary (or correctly routed cluster node), not a read-only replica.
  3. Check the specific counter named in the message exists in the keyspace (redis-cli GET with the counter name).
  4. Verify Redis health (latency, maxclients, OOM) if dumps repeatedly fail mid-way.
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the Redis endpoint answers before starting a dump:
if err := rdb.Ping(ctx).Err(); err != nil { return err }

Try / catch

err := juicefs.Dump(ctx, meta, f, opt)
for attempt := 0; err != nil && strings.Contains(err.Error(), "get counter") && attempt < 3; attempt++ {
    time.Sleep(backoff(attempt))
    err = juicefs.Dump(ctx, meta, f, opt)
}

Prevention

When it happens

Trigger: Running `juicefs dump` or metadata backup on a Redis engine when getCounter (a Redis GET on the counter key) fails — connection error, cluster routing failure, or timeout — for one of the standard counters.

Common situations: Redis failover during a long dump; READONLY replica used for backup reads; flaky network to Redis on large clusters; missing counter keys after manual key deletion (depends on getCounter's handling of missing keys).

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/810a373f2892e19a. Report an issue: GitHub.