Skip to content

[17.0][FW] queue_job: multiple ports from 18.0#915

Open
guewen wants to merge 29 commits intoOCA:17.0from
guewen:oca-port-queue_job-18.0-to-17.0-b92225
Open

[17.0][FW] queue_job: multiple ports from 18.0#915
guewen wants to merge 29 commits intoOCA:17.0from
guewen:oca-port-queue_job-18.0-to-17.0-b92225

Conversation

@guewen
Copy link
Member

@guewen guewen commented Mar 23, 2026

amh-mw and others added 29 commits March 23, 2026 15:25
This prevents TestOverrides.test_creates from failing in the Odoo
`base` module due to sentinel protections taking effect even for
local create invocations.
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
The automatic dead jobs requeuer now works out of the box.
This allows creating test job with a long duration for stress testing.
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.
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.
Since we are not going to delete records nor modify foreign keys,
we can take a weaker lock.
This would release the job lock, causing spurious restarts by the dead jobs requeuer.
Every time a job is done, even if it is not part of a graph, it runs a
query to look for dependents to enqueue. Storing the dependent uuids in
the "dependencies" field was on purpose to know that we have no further
jobs in the graph and that we can skip the check entirely and have no
overhead in this case.

It looks like an oversight, we can add the missing condition.
In this case, when a module adds a value in context, the tests fail
It is forbidden to commit inside a job, because it releases the job lock
and can cause it to start again, while still being run, by the dead jobs
requeuer. For some use cases, it may actually be legitimate, or at least
be needed in the short term before actual updates in the code.

A new option on the job function, false by default, allow to run the job
in a new transaction, at the cost of an additional connection +
transaction overhead.

Related to OCA#889
False on new databases, True on existing databases.
Should always be False by default on future versions.
As the controller changes env on Job instances.
@guewen guewen force-pushed the oca-port-queue_job-18.0-to-17.0-b92225 branch from 9b8a745 to cf7d7c8 Compare March 23, 2026 15:14
@guewen guewen marked this pull request as ready for review March 23, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants