Skip to content

[14.0][FW] queue_job: multiple ports from 18.0 - #987

Merged
OCA-git-bot merged 43 commits into
OCA:14.0from
camptocamp:oca-port-queue_job-18.0-to-14.0-d5fef7
Oct 26, 2026
Merged

OCA-git-bot merged 43 commits into
OCA:14.0from
camptocamp:oca-port-queue_job-18.0-to-14.0-d5fef7

Conversation

@florentx

@florentx florentx commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Port from 18.0 to 14.0:

The following PRs have been blacklisted:

florentx and others added 6 commits September 22, 2026 11:13
Without this fix, if db_replica_host is set, Odoo might pass a readonly
database cursor and the FOR UPDATE in the method would fail.
Without this, we leak connections to Databases that don't have queue_job
installed.
Without this we risk connection leaks in case of exceptions in the
constructor.
@oca-cla-bot

oca-cla-bot Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @guewen,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added mod:queue_job Module queue_job mod:test_queue_job Module test_queue_job series:14.0 labels Sep 22, 2026
@florentx
florentx force-pushed the oca-port-queue_job-18.0-to-14.0-d5fef7 branch 4 times, most recently from 102d592 to e4ea840 Compare September 22, 2026 11:58
@simahawk

Copy link
Copy Markdown
Contributor

@florentx worth to mention that we should be careful on existing installations because of this change #890

@florentx
florentx force-pushed the oca-port-queue_job-18.0-to-14.0-d5fef7 branch 2 times, most recently from 1a19365 to 3d46fe9 Compare September 22, 2026 12:34
…eue jobs in timeout

[IMP] queue_job: increment 'retry' when re-queuing job that have been killed
@florentx
florentx force-pushed the oca-port-queue_job-18.0-to-14.0-d5fef7 branch from 3d46fe9 to b9139f3 Compare September 22, 2026 12:53
benwillig and others added 7 commits September 22, 2026 14:57
'name' attributes for odoo's exception has been deprecated and produces a warning message. This commit fixes the behavior
datetime.datetime.utcnow() is now deprecated and should be replaced by datetime.datetime.now() (optional TZ parameter).
As the original _odoo_now() doesn't contain the Timezone, the parameter datetime.UTC is not added into this improvement
When a SerializationFailure occurs when updating the state of dependent
jobs, the cursor is not usable anymore so the retry failed with `current transaction is aborted`. A savepoint fixes that.
@florentx
florentx force-pushed the oca-port-queue_job-18.0-to-14.0-d5fef7 branch from b9139f3 to b7adb84 Compare September 22, 2026 12:57
In this commit we cleanly separate the job acquisition (i.e. verifying the job is in the exepected state, marking it started and locking it) from job execution.

We also avoid trying to start the job if it is already locked by using SKIP LOCKED
and exiting early. Indeed in such situations the job is likely already being handled by another worker so there is no point trying to start it, so we exit early
and let it be handled either by the other worker or the dead job requeuer.
Extract the logic to run one job out of the /queue_job/runjob route.
Towards making this logic reusable in other job executors.
ivantodorovich and others added 13 commits September 22, 2026 17:45
…ethod

We add the `_subscribe_job_creator` method in `queue.job` which will return True for the cases where we want to subscribe the job creator, False otherwise.
Jobs are always created through sudo() in the Job class, and always
deleted by the cron, never by users.

See discussion on OCA#802 (comment)
…rts patches

Otherwise monkey-patches could be added twice when instantiating new test classes.
(cherry picked from commit 47b8c48)
[ported to 18.0: isinstance union syntax for ruff UP038]
Add a new "paused" option on channel configuration.
A paused channel is equivalent to a channel with no capacity:
it yields no job and also blocks all its subchannels.

It still needs a restart of the jobrunner, so it does not allow dynamic
pause/resume, but hot reload may be added later in OCA#765.

It still is an improvement over setting the capacity at 0, because it
keeps the capacity in the configuration (removing the option in the
config restores the initial capacity).

Also, it does not require changing the channel of a job, which is an
issue when resuming paused jobs (they should go back to their former
channel to be resumed with their expected properties related to
capacity/sequential/throttle).
Allows to execute a model function when the job fails and will
not be retried.

[REF] queue_job: Move on fail definition to job function

Rename on_fail_hook to on_fail
Job.on_fail_method_name was only set as an instance attribute when
the job function configured on_fail_method, so on_fail() raised
AttributeError for every job that didn't opt into it.
This adds `capacity_default` and `sequential_default` options
that set `capacity` and `sequential` for autocreated subchannels.
It also allows non-root channel configurations to omit capacity.
Logging the usage of queue_job__no_delay makes sense only in 'production mode'.
We have tons of tests explicitly bypassing jobs and that generates a lot of useless entries in the logs.
@florentx
florentx force-pushed the oca-port-queue_job-18.0-to-14.0-d5fef7 branch from b7adb84 to e1505a3 Compare September 22, 2026 15:49
@guewen

guewen commented Oct 26, 2026

Copy link
Copy Markdown
Member

@florentx do you have production databases running with these backports?

@florentx

Copy link
Copy Markdown
Contributor Author

@florentx do you have production databases running with these backports?

Hello, yes we've deployed it on a Prod instance. It works fine.
We had issue with a different PR (#993), not with this backport.

@guewen

guewen commented Oct 26, 2026

Copy link
Copy Markdown
Member

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 14.0-ocabot-merge-pr-987-by-guewen-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit d035028 into OCA:14.0 Oct 26, 2026
6 of 8 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 657c768. Thanks a lot for contributing to OCA. ❤️

@florentx
florentx deleted the oca-port-queue_job-18.0-to-14.0-d5fef7 branch October 26, 2026 20:11
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.