Skip to content

[FIX] base_bg: run one job per cron run and isolate the user notification - #519

Closed
fw-bot-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-18.0-t-79313-rov-11128-fw
Closed

fw-bot-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-18.0-t-79313-rov-11128-fw

Conversation

@fw-bot-adhoc

Copy link
Copy Markdown
Contributor

Tarea: https://www.adhoc.inc/odoo/project.task/79313

Problem

limit_time_real_cron counts the whole cron run. In 18.0 _cron_run_enqueued_jobs(limit=5) chains up to 5 jobs in one run, so with jobs of about 10 minutes each (large bank statement imports) the worker passes the limit and is killed with SIGKILL. The jobs start again from zero.

Also, finish() and _notify_user() share the same commit. When the notification fails with could not serialize access due to concurrent update on UPDATE discuss_channel_member, the rollback discards the work of a job that already finished, and the retry runs it again.

Changes

  • _cron_run_enqueued_jobs: one job per run by default (limit is kept as a parameter). When enqueued jobs remain, the runner triggers itself again. This also covers a failed job that is enqueued again, which before waited for the 10 minute interval.
  • run(): commits the job work and finish() before notifying. The new _notify_result posts the notification in a savepoint and only logs an error, so the job stays done and is not run again.

Forward-port to 19.0

19.0 already runs one job per cron run, so the runner part and test_cron_runs_one_job_per_run_and_retriggers do not apply there and must be dropped. The notification fix does apply, adapted to the 19.0 run() (it handles errors without raising and calls invalidate_all()). That adaptation is ready and its test passes on 19.0 (59/59 base_bg tests on a fresh database).

Tests

  • test_run_notification_failure_keeps_job_done
  • test_cron_runs_one_job_per_run_and_retriggers

These 18.0 tests were not run locally (19.0 environment): runbot validates them.

Forward-Port-Of: #494

@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@fw-bot-adhoc

Copy link
Copy Markdown
Contributor Author

@rov-adhoc @maq-adhoc cherrypicking of pull request #494 failed.

stdout:

Auto-merging base_bg/models/bg_job.py
CONFLICT (content): Merge conflict in base_bg/models/bg_job.py
Auto-merging base_bg/tests/test_bg_job.py
CONFLICT (content): Merge conflict in base_bg/tests/test_bg_job.py

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

:shipit: you can use git-fw to re-do the forward-port for you locally.

⚠️ after resolving this conflict, you will need to merge it via @roboadhoc.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

run() committed the job work, its finish() and the user notification
together. When the notification failed (e.g. a serialization failure on
discuss_channel_member), the rollback discarded the work of a job that
had already finished, and the retry ran it again.

run() now commits the job work and finish() before notifying. The
notification runs in a savepoint and an error there is only logged, so
a finished job is not rolled back nor run again.

The runner change of the original commit (one job per cron run) is not
forward-ported: 19.0 already processes one job per run and re-triggers
the runner while enqueued jobs remain.

X-original-commit: b074ac1
@rov-adhoc
rov-adhoc force-pushed the 19.0-18.0-t-79313-rov-11128-fw branch from 9bcc7ad to e52b731 Compare November 13, 2026 13:11
@rov-adhoc

Copy link
Copy Markdown
Contributor

@roboadhoc r+ nobump

roboadhoc pushed a commit that referenced this pull request Nov 13, 2026
run() committed the job work, its finish() and the user notification
together. When the notification failed (e.g. a serialization failure on
discuss_channel_member), the rollback discarded the work of a job that
had already finished, and the retry ran it again.

run() now commits the job work and finish() before notifying. The
notification runs in a savepoint and an error there is only logged, so
a finished job is not rolled back nor run again.

The runner change of the original commit (one job per cron run) is not
forward-ported: 19.0 already processes one job per run and re-triggers
the runner while enqueued jobs remain.

closes #519

X-original-commit: b074ac1
Signed-off-by: Filoquin adhoc <[email protected]>
Signed-off-by: rov-adhoc <[email protected]>
@roboadhoc roboadhoc closed this Nov 13, 2026
@roboadhoc
roboadhoc deleted the 19.0-18.0-t-79313-rov-11128-fw branch November 13, 2026 14:22

This branch was previously deployed

1 inactive deployment
merge — e52b7317 Deployed Nov 13, 2026 by roboadhoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants