Skip to content

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

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

fw-bot-adhoc wants to merge 1 commit into
ingadhoc:20.0from
adhoc-dev:20.0-18.0-t-79313-rov-11513-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: #519
Forward-Port-Of: #494

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: d5a8ab6
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@fw-bot-adhoc

Copy link
Copy Markdown
Contributor Author

@rov-adhoc @maq-adhoc this PR targets 20.0 and is the last of the forward-port chain.

To merge the full chain, use

@roboadhoc r+

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

@rov-adhoc

Copy link
Copy Markdown
Contributor

@roboadhoc r+ nobump

@roboadhoc roboadhoc added the 19.1 label Nov 13, 2026
@roboadhoc roboadhoc closed this in 60e6386 Nov 13, 2026
@roboadhoc
roboadhoc deleted the 20.0-18.0-t-79313-rov-11513-fw branch November 13, 2026 15:13

This branch was successfully deployed

1 active deployment
merge — 059d7e2d 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