hibiken/asynq · error
failed to get queue info
Error message
failed to get queue info: %w
What it means
After listing queue names, collectQueueInfo calls Inspector.GetQueueInfo(qname) per queue; any failure fetching a single queue's stats is wrapped with this message and aborts the collection. This is typically a Redis-level error or the queue disappearing between listing and fetching.
Solutions
- Retry the scrape or add retry logic around GetQueueInfo for transient Redis errors.
- Log/unwrap the wrapped cause to see whether it is NOGROUP/missing key vs connection error.
- Skip failing queues gracefully instead of failing the entire Collect call.
- Verify the queue still exists and that the Inspector connects to the same Redis as the server.
Example fix
// before
qinfo, err := qmc.inspector.GetQueueInfo(qname)
if err != nil { return nil, fmt.Errorf("failed to get queue info: %w", err) }
// after
qinfo, err := qmc.inspector.GetQueueInfo(qname)
if err != nil {
log.Printf("skipping queue %s: %v", qname, err)
continue
} Defensive patterns
Strategy: fallback
Validate before calling
for _, q := range qnames {
if _, err := insp.GetQueueInfo(q); err != nil {
log.Printf("queue %s unavailable: %v", q, err)
}
} Try / catch
qinfo, err := insp.GetQueueInfo(qname)
if err != nil {
log.Printf("skipping queue %s: %v", qname, err)
continue // degrade metrics instead of failing scrape
} Prevention
- Avoid deleting queues while metrics scrapes are active, or tolerate missing queues.
- Handle Redis NOGROUP/resharding errors in cluster setups.
- Add per-queue error counters so partial failures are visible.
When it happens
Trigger: Collect → collectQueueInfo; GetQueueInfo fails for one queue due to Redis error, key deleted mid-scrape, cluster resharding, or transient network failure.
Common situations: A queue is purged/deleted while Prometheus scrapes; Redis cluster failover; intermittent network issues between the metrics server and Redis.
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
- failed to get queue names
- redis connection is shared so the Inspector can't be closed…
- redis command failed
- task id conflicts with another task
- testutil: redis is down
AI-assisted analysis of hibiken/asynq@d135f1439b (2026-09-07).
Data as JSON: /api/errors/a9e1d066cb364716.
Report an issue: GitHub.
Appendix: source
Thrown at x/metrics/metrics.go:34
// It implements prometheus.Collector interface.
//
// All metrics exported from this collector have prefix "asynq".
type QueueMetricsCollector struct {
inspector *asynq.Inspector
}
// collectQueueInfo gathers QueueInfo of all queues.
// Since this operation is expensive, it must be called once per collection.
func (qmc *QueueMetricsCollector) collectQueueInfo() ([]*asynq.QueueInfo, error) {
qnames, err := qmc.inspector.Queues()
if err != nil {
return nil, fmt.Errorf("failed to get queue names: %w", err)
}
infos := make([]*asynq.QueueInfo, len(qnames))
for i, qname := range qnames {
qinfo, err := qmc.inspector.GetQueueInfo(qname)
if err != nil {
return nil, fmt.Errorf("failed to get queue info: %w", err)
}
infos[i] = qinfo
}
return infos, nil
}
// Descriptors used by QueueMetricsCollector
var (
tasksQueuedDesc = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "tasks_enqueued_total"),
"Number of tasks enqueued; broken down by queue and state.",
[]string{"queue", "state"}, nil,
)
queueSizeDesc = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "queue_size"),
"Number of tasks in a queue",
[]string{"queue"}, nil,View on GitHub (pinned to d135f1439b)