Skip to content

[DEL] explicit commits, they are not compatible with queue jobs#136

Merged
OCA-git-bot merged 2 commits intoOCA:16.0from
Therp:16.0-commit-not-allowed-in-jobs
Mar 27, 2026
Merged

[DEL] explicit commits, they are not compatible with queue jobs#136
OCA-git-bot merged 2 commits intoOCA:16.0from
Therp:16.0-commit-not-allowed-in-jobs

Conversation

@thomaspaulb
Copy link
Copy Markdown
Contributor

This is more of a discussion point, I think bluntly deleting this commit statements is maybe not the solution, perhaps we need to check if the methods are run via a queue job or not? Via the context? (Either by the context keys that queue_job injects itself, or by adding an explicit one)

@gjotten Do you remember which error you got? Scouring the logfile yields a couple of "Cursor already closed" errors, maybe it was that one?

@thomaspaulb
Copy link
Copy Markdown
Contributor Author

Ah, actually the error received is this one:

  File "/home/ubuntu/odoo/auto/addons/odoo_repository/utils/scanner.py", line 80, in _push_scanned_data
    self.env.cr.commit()  # pylint: disable=invalid-commit
  File "/home/ubuntu/odoo/auto/addons/queue_job/controllers/main.py", line 39, in forbidden_commit
    raise RuntimeError(
RuntimeError: Commit is forbidden in queue jobs. If the current job is a cron running as queue job, modify it to run as a normal cron.

@thomaspaulb thomaspaulb requested a review from sebalix March 24, 2026 11:16
@sebalix
Copy link
Copy Markdown
Collaborator

sebalix commented Mar 25, 2026

Thank you @thomaspaulb for this fix. Indeed, it has been done that way initially as one scanner call is able to parse & push multiple modules within the same transaction, but jobs have been processing module one by one now so this force-commit is useless I guess now (and doesn't work anyway as you stated).

@thomaspaulb thomaspaulb marked this pull request as ready for review March 25, 2026 11:19
@thomaspaulb
Copy link
Copy Markdown
Contributor Author

@sebalix without this change the module is now not working, so i guess we should approve and merge?

@sebalix
Copy link
Copy Markdown
Collaborator

sebalix commented Mar 26, 2026

@thomaspaulb I'm not able to reproduce it on my side (I have a 18.0 node running scans every day) , could it be linked to the configuration of queue_job? Here is mine:

ODOO_QUEUE_JOB_CHANNELS: root:4,root.odoo_repository_scan:3,root.odoo_repository_find_pr_url:1,root.odoo_repository_scan_migration:1

If you have more info so I could test this PR before merging

@sebalix
Copy link
Copy Markdown
Collaborator

sebalix commented Mar 27, 2026

@thomaspaulb sorry, I was not up-to-date regarding OCA/queue 👍 Just saw queue#880 which has been backported on 16.0 here.

I can reproduce the issue right now.

@sebalix
Copy link
Copy Markdown
Collaborator

sebalix commented Mar 27, 2026

/ocabot merge patch

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-136-by-sebalix-bump-patch, awaiting test results.

@sebalix sebalix added the bug Something isn't working label Mar 27, 2026
@OCA-git-bot OCA-git-bot merged commit 188ce03 into OCA:16.0 Mar 27, 2026
7 checks passed
@OCA-git-bot
Copy link
Copy Markdown
Contributor

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

@thomaspaulb
Copy link
Copy Markdown
Contributor Author

Ah great, you were able to reproduce :) thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working merged 🎉

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants