[FIX] ir.cron: execute jobs in priority order (again)
The selection mechanism selects 1 job at a time from the jobs that are
ready to execute, but while doing this it should respect the `priority`
defined on the jobs. Otherwise the field is useless, and the user has no
way to ensure that a long-running job does not cause starvation.
(Assuming execution resources that are insufficient for 100% of the
processing to happen)
The `priority` ordering was apparently lost during the introduction of
the trigger mechanism in #62124 via
4b28f1162a.
It was previously taken into account in `_process_jobs()`.
The `ORDER BY` is not strictly necessary in `_get_all_ready_jobs()`, but
it seems more consistent for this method to return an ordered list as
well, given the semantics of the `priority` field. We don't know what
the caller will do with the result.
closes odoo/odoo#68411
X-original-commit: 9d570662b4016b5cd9ad3c85abbcb5428c169cc6
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
This commit is contained in:
@@ -179,6 +179,7 @@ class ir_cron(models.Model):
|
||||
WHERE call_at <= (now() at time zone 'UTC')
|
||||
)
|
||||
)
|
||||
ORDER BY priority
|
||||
""")
|
||||
return cr.dictfetchall()
|
||||
|
||||
@@ -224,6 +225,7 @@ class ir_cron(models.Model):
|
||||
)
|
||||
)
|
||||
AND id in %s
|
||||
ORDER BY priority
|
||||
LIMIT 1 FOR NO KEY UPDATE SKIP LOCKED
|
||||
""", [job_ids])
|
||||
return cr.dictfetchone()
|
||||
|
||||
Reference in New Issue
Block a user