{
  "id": "php/laravel-queue-worker-memory-leak",
  "signature": "Illuminate\\Queue\\MaxAttemptsExceededException: App\\Jobs\\ProcessOrder has been attempted too many times or run too long. The job may have previously timed out.",
  "signature_zh": "Illuminate\\Queue\\MaxAttemptsExceededException：App\\Jobs\\ProcessOrder已尝试次数过多或运行时间过长。该任务可能之前已超时。",
  "regex": "/MaxAttemptsExceededException: App\\\\Jobs\\\\[a-zA-Z]+ has been attempted too many times/",
  "domain": "php",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "A queue worker process exceeded the allowed memory limit (memory_limit) or the job's timeout (retry_after or --timeout), causing the job to be released and retried until it reaches the maximum attempts threshold.",
  "root_cause_type": "generic",
  "root_cause_zh": "队列工作进程超出了允许的内存限制（memory_limit）或任务的超时时间（retry_after或--timeout），导致任务被释放并重试，直到达到最大尝试次数阈值。",
  "versions": [
    {
      "version": "Laravel 10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Laravel 11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PHP 8.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PHP 8.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only delays the problem; the underlying memory leak or timeout issue still exists, and the job will eventually fail again or consume excessive resources.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling timeouts can cause workers to hang indefinitely, leading to resource starvation and blocking other jobs.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Restarting resets the worker state but does not fix the memory leak; the error will reoccur after enough jobs are processed.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase PHP's memory_limit in php.ini or via ini_set() for the queue worker: memory_limit = 512M. Then restart the worker: php artisan queue:restart.",
      "success_rate": 0.7,
      "how": "Increase PHP's memory_limit in php.ini or via ini_set() for the queue worker: memory_limit = 512M. Then restart the worker: php artisan queue:restart.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add explicit garbage collection in the job's handle() method: unset($largeVariable); gc_collect_cycles(); Also ensure no circular references exist.",
      "success_rate": 0.75,
      "how": "Add explicit garbage collection in the job's handle() method: unset($largeVariable); gc_collect_cycles(); Also ensure no circular references exist.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use the --max-jobs option to restart the worker after a set number of jobs: php artisan queue:work --max-jobs=100. This prevents memory accumulation.",
      "success_rate": 0.85,
      "how": "Use the --max-jobs option to restart the worker after a set number of jobs: php artisan queue:work --max-jobs=100. This prevents memory accumulation.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase PHP's memory_limit in php.ini or via ini_set() for the queue worker: memory_limit = 512M. Then restart the worker: php artisan queue:restart.",
    "Add explicit garbage collection in the job's handle() method: unset($largeVariable); gc_collect_cycles(); Also ensure no circular references exist.",
    "Use the --max-jobs option to restart the worker after a set number of jobs: php artisan queue:work --max-jobs=100. This prevents memory accumulation."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://laravel.com/docs/11.x/queues#max-attempts",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.78,
  "resolvable": "partial",
  "first_seen": "2024-01-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}