Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#864 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
38/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Calme
Stack technique
python
Domaine
backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Langage dominant
Python
Étoiles
271
Forks
602
Merge moyen
4 j 4 h
PR mergées (30 j)
6

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de OCA/queue

Toutes les issues de OCA/queue

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.