{"record":{"id":"82f6eea037cb91e1","repo":"hibiken/asynq","slug":"queue-is-not-empty","errorCode":null,"errorMessage":"queue is not empty","messagePattern":"queue is not empty","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"inspector.go","lineNumber":210,"sourceCode":"\t}\n\tvar res []*DailyStats\n\tfor _, s := range stats {\n\t\tres = append(res, &DailyStats{\n\t\t\tQueue:     s.Queue,\n\t\t\tProcessed: s.Processed,\n\t\t\tFailed:    s.Failed,\n\t\t\tDate:      s.Time,\n\t\t})\n\t}\n\treturn res, nil\n}\n\nvar (\n\t// ErrQueueNotFound indicates that the specified queue does not exist.\n\tErrQueueNotFound = errors.New(\"queue not found\")\n\n\t// ErrQueueNotEmpty indicates that the specified queue is not empty.\n\tErrQueueNotEmpty = errors.New(\"queue is not empty\")\n\n\t// ErrTaskNotFound indicates that the specified task cannot be found in the queue.\n\tErrTaskNotFound = errors.New(\"task not found\")\n)\n\n// DeleteQueue removes the specified queue.\n//\n// If force is set to true, DeleteQueue will remove the queue regardless of\n// the queue size as long as no tasks are active in the queue.\n// If force is set to false, DeleteQueue will remove the queue only if\n// the queue is empty.\n//\n// If the specified queue does not exist, DeleteQueue returns ErrQueueNotFound.\n// If force is set to false and the specified queue is not empty, DeleteQueue\n// returns ErrQueueNotEmpty.\nfunc (i *Inspector) DeleteQueue(queue string, force bool) error {\n\terr := i.rdb.RemoveQueue(queue, force)\n\tif errors.IsQueueNotFound(err) {","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/inspector.go#L192-L228","documentation":"Sentinel error ErrQueueNotEmpty, returned by Inspector.DeleteQueue when the target queue still holds pending/active/scheduled tasks. It fires because DeleteQueue refuses to delete a non-empty queue unless called with force=true; callers detect it via errors.Is and can either purge tasks first or retry with force.","triggerScenarios":"inspector.DeleteQueue(q, false) on a queue with pending/scheduled/archived tasks; DeleteQueue(q, true) while tasks are actively being processed.","commonSituations":"Decommissioning a queue that still has backlog; trying to force-delete during live traffic; forgetting force only bypasses size limits, not active tasks.","solutions":["Drain or requeue the tasks first (use Inspector to list and delete/archive them).","Call DeleteQueue with force=true after confirming no tasks are active.","Pause the queue and wait for active tasks to complete, then delete.","Treat errors.Is(err, asynq.ErrQueueNotEmpty) as 'retry after drain'."],"exampleFix":"// before\ninsp.DeleteQueue(\"legacy\", false)\n// after\nif err := insp.DeleteQueue(\"legacy\", true); err != nil {\n    log.Printf(\"queue still draining: %v\", err)\n}","handlingStrategy":"type-guard","validationCode":"stats, err := insp.Stats(qname)\nif err == nil && stats.Pending+stats.Scheduled+stats.Archived > 0 { return ErrQueueStillHasTasks }","typeGuard":"func isQueueNotEmpty(err error) bool { return errors.Is(err, asynq.ErrQueueNotEmpty) }","tryCatchPattern":"if err := insp.DeleteQueue(q, true); err != nil {\n    if isQueueNotEmpty(err) { return ErrRetryAfterDrain }\n    return err\n}","preventionTips":["Drain or requeue tasks before decommissioning a queue","Pause the queue and let active tasks finish before deleting","Use force=true only after verifying no active tasks"],"tags":["redis","queue","deletion","inspector"],"backgroundTag":"resource-not-empty","analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}