{"record":{"id":"5106fcf01a867dd5","repo":"hibiken/asynq","slug":"queue-q-is-already-paused","errorCode":null,"errorMessage":"queue %q is already paused","messagePattern":"queue %q is already paused","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/rdb/inspect.go","lineNumber":2082,"sourceCode":"\t\t}\n\t\te, err := base.DecodeSchedulerEnqueueEvent([]byte(data))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tevents = append(events, e)\n\t}\n\treturn events, nil\n}\n\n// Pause pauses processing of tasks from the given queue.\nfunc (r *RDB) Pause(qname string) error {\n\tkey := base.PausedKey(qname)\n\tok, err := r.client.SetNX(context.Background(), key, r.clock.Now().Unix(), 0).Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !ok {\n\t\treturn fmt.Errorf(\"queue %q is already paused\", qname)\n\t}\n\treturn nil\n}\n\n// Unpause resumes processing of tasks from the given queue.\nfunc (r *RDB) Unpause(qname string) error {\n\tkey := base.PausedKey(qname)\n\tdeleted, err := r.client.Del(context.Background(), key).Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif deleted == 0 {\n\t\treturn fmt.Errorf(\"queue %q is not paused\", qname)\n\t}\n\treturn nil\n}\n\n// ClusterKeySlot returns an integer identifying the hash slot the given queue hashes to.","sourceCodeStart":2064,"sourceCodeEnd":2100,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/internal/rdb/inspect.go#L2064-L2100","documentation":"Returned by RDB.Pause when the target queue is already in the paused state. Pause uses SetNX on the paused-key; if the key already exists, SetNX fails and this error is raised. It is an idempotency/state guard, not a network or data failure.","triggerScenarios":"Calling inspector.Pause(queue) twice, or calling Pause on a queue paused by another process/instance without an intervening Unpause.","commonSituations":"Multiple schedulers or ops scripts pausing the same queue concurrently; re-running an idempotent deployment script that pauses queues; retry logic that repeats Pause after a timeout.","solutions":["Check IsPaused(queue) before calling Pause","Treat this error as a no-op success if the desired state is 'paused'","Serialize pause/unpause operations through one controller","Use a retry loop that tolerates this specific error"],"exampleFix":"// before\nif err := inspector.Pause(q); err != nil {\n    return err\n}\n// after\nif err := inspector.Pause(q); err != nil && !strings.Contains(err.Error(), \"is already paused\") {\n    return err\n}","handlingStrategy":"validation","validationCode":"paused, err := inspector.IsPaused(q)\nif err != nil { return err }\nif paused { return nil } // nothing to do","typeGuard":null,"tryCatchPattern":"if err := inspector.Pause(q); err != nil && !strings.Contains(err.Error(), \"already paused\") {\n    return err\n} // treat already-paused as success","preventionTips":["Check IsPaused before Pause","Make pause/unpause idempotent in caller code","Route queue state changes through a single controller","Watch for duplicate Pause calls in deployment scripts"],"tags":["redis","queue-state","conflict"],"backgroundTag":"invalid-state-transition","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"}