Skip to content

[18.0][IMP] queue_job_cron: Behave like native cron - #1028

Open
qgroulard wants to merge 3 commits into
OCA:18.0from
acsone:18.0-imp-queue_job_cron_like_native_cron-qgr
Open

qgroulard wants to merge 3 commits into
OCA:18.0from
acsone:18.0-imp-queue_job_cron_like_native_cron-qgr

Conversation

@qgroulard

Copy link
Copy Markdown
Contributor

Based on #959

A cron run as a queue job behaves differently from a cron run by the Odoo cron worker in two ways:

Never run the same cron twice in parallel

Unlike the native cron worker, which holds the cron row lock for the whole run, a cron run as a queue job is only locked while it is enqueued, and no_parallel_queue_job_run only skips a job when an identical one is pending. A run lasting longer than the cron interval, or a trigger committed mid-run with allow_commit, started a second job of the same cron in parallel.

The job now holds the cron row lock while it runs. A concurrent job of the same cron gets LockNotAvailable, which queue_job turns into a postponed retry.

Support the cron progress API

_notify_progress is a no-op without the progress record the native cron runner puts in context, so a batched cron run as a queue job processed a single batch per run and could not deactivate itself.

The server action now runs with a progress record: the cron is triggered again while records remain, and deactivated when it asks so.

baimont and others added 3 commits August 14, 2026 12:05
Unlike the native cron worker, which holds the cron row lock for the
whole run, a cron run as a queue job is only locked while it is
enqueued, and no_parallel_queue_job_run only skips a job when an
identical one is pending. A run lasting longer than the cron interval,
or a trigger committed mid-run with allow_commit, started a second job
of the same cron in parallel.

The job now holds the cron row lock while it runs. A concurrent job of
the same cron gets LockNotAvailable, which queue_job turns into a
postponed retry.
_notify_progress is a no-op without the progress record the native
cron runner puts in context, so a batched cron run as a queue job
processed a single batch per run and could not deactivate itself.

The server action now runs with a progress record: the cron is
triggered again while records remain, and deactivated when it asks so.
@qgroulard qgroulard changed the title [18.0][FIX] queue_job_cron: Behave like native cron [18.0][IMP] queue_job_cron: Behave like native cron Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants