[18.0] queue_job: job failed to be requeued or cancelled if function is removed while job not yet done
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
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 內容生成。
描述
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 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
OCA/queue 的其他 Issue
-
enhancement
難度 3/5 1-2 天 新手友好度 30/100
維護者通常 1 天內回覆
-
help wanted no stale work in progress
難度 5/5 一週以上 新手友好度 35/100
維護者通常 1 天內回覆
-
Delaying unlink or write on a model whose method was replaced raises AttributeError at enqueue time可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug
難度 4/5 3-5 天 新手友好度 35/100
OCA/queue#996 · 1 個 reaction ·
維護者通常 1 天內回覆
-
[19.0] queue_job: Jobs stay pending after the jobrunner's database connection is silently dropped可能已有人在做 @HoloborodkoBohdan 於 32 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 25/100
OCA/queue#984 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 35/100
OCA/queue#965 · 1 個 reaction ·
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
namespace operations
難度 1/5 1 小時以內 新手友好度 65/100
EclipseFdn/open-vsx.org#15057 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
FinanceFlash/unvibecode#349 ·
-
Mission statement: why this is free, in the README, Why This Exists and the wiki Home可能已有人在做 @ChiefGyk3D 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
ChiefGyk3D/Clouds-Against-Humanity#348 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
vllm-project/vime#508 ·
維護者通常 4 天內回覆