[18.0] queue_job: job failed to be requeued or cancelled if function is removed while job not yet done
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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時間
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OCA/queue のほかの issue
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
-
help wanted no stale work in progress
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Delaying unlink or write on a model whose method was replaced raises AttributeError at enqueue time対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 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 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
vllm-project/vllm#64845 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
dekobon/big-code-analysis#1729 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pydantic/pydantic-ai#12091 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100