Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

[18.0] queue_job: job failed to be requeued or cancelled if function is removed while job not yet done

未關閉
#864 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
38/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
python
領域
backend

研究方向

The failure is in _change_job_state in queue_job/models/queue_job.py, which calls Job.load, and in _load_from_db_record in queue_job/job.py, where getattr(recordset, method_name) raises once the function is removed. Start by reading those two spots and deciding whether state-only actions (requeue, cancel, set done) can skip resolving the method. Done means those actions succeed on a job whose method no longer exists, with a test covering that case. The issue itself leaves the expected behaviour open, so check with maintainers first.

由索引模型根據 Issue 內容生成。

描述

bug

Module

queue_job

Describe the bug

If a job having its function (job.method_name) removed, while being pending/enqueued or failed (maybe, I haven't double checked but I think loading failed jobs during initialization), the job runner will stuck trying to requeue the job as failing to load the job. Trying to cancel to unlink the job from UI will also fail due to the same reason.

To Reproduce

Affected versions: 18.0 but properly other versions too.

Steps to reproduce the behavior: Explained in the description.

Expected behavior
I don't really know whether this is truly a bug, or it's missing a reliable way to prevent this from happening, maybe it's a rule of thumb to not having function removed if it's used in queue job, but since function can be enqueue anywhere using with_delay or delayable(), it's hard to tell which functions are used with queue job. Unless we always define job as job function to allow enqueueing it.

A way to prevent this issue from happening without enforcing how to implement jobs or control the development is to not loading the job if we are just setting the state of it (requeue, cancel or set done).

Additional context
Below is where it fails, since method_name is removed, getattr simply break

  File "/opt/odoo/src/queue/queue_job/models/queue_job.py", line 309, in _change_job_state
    job_ = Job.load(record.env, record.uuid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/src/queue/queue_job/job.py", line 213, in load
    return cls._load_from_db_record(stored)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/src/queue/queue_job/job.py", line 288, in _load_from_db_record
    method = getattr(recordset, method_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
主要語言
Python
星號
271
分支
602
平均合併
4 天 4 小時
30 天內合併 PR
6

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

OCA/queue 的其他 Issue

查看 OCA/queue 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。