Skip to content

Conversation

@hugosantosred
Copy link
Member

In servers with multiple databases db is not captured from URL when processing jobs in /queue_job/runjob

With this patch db is set from the db param in URL when calling the runjob endpoint

Fixes #503


Maybe this monkey patch is not the most elegant or efficient solution, but this is the only way that I've managed to set the right db in order to call the petition with the request._serve_db method after the http.py complete refactor in v16.

@OCA-git-bot
Copy link
Contributor

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

@hugosantosred hugosantosred force-pushed the 16.0-queue_job-fix-multiple-dbs branch from 931d2aa to ac10d2a Compare February 1, 2023 09:02
@hugosantosred hugosantosred changed the title [FIX] Patch Request._get_session_and_dbname to get db from URL [16.0][FIX] Patch Request._get_session_and_dbname to get db from URL Feb 1, 2023
@hugosantosred
Copy link
Member Author

Pre-commit is failing because of isort problem. Fixed by updating copier template in #505

@StefanRijnhart
Copy link
Member

Thanks! I agree that monkeypatching should be avoided if possible. Is the db argument populated in https://github.com/OCA/queue/blob/94bd236/queue_job/controllers/main.py#L74? In that case, maybe it helps to insert a line there that also assigns the db attribute to the request.

@hugosantosred
Copy link
Member Author

@StefanRijnhart At that point, the db argument is populated, but the problem is that the request is already served with the _serve_nodb method, because the request.db is not populated here: https://github.com/odoo/odoo/blob/16.0/odoo/http.py#L1989

In the requests that are getting served with the _serve_nodb method, there is not env available, and setting the request.db does nothing.

In servers with multiple databases db is not captured from URL when
processing jobs in /queue_job/runjob

With this patch db is set from the db param in URL when calling
the runjob endpoint

Fixes OCA#503
@hugosantosred hugosantosred force-pushed the 16.0-queue_job-fix-multiple-dbs branch from ac10d2a to 1f3e2b1 Compare February 14, 2023 09:06
Copy link

@zuher83 zuher83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work with me 🙂 Thanks

Copy link
Member

@davejames davejames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functional review, works well here in a multi-db scenario

Copy link
Member

@guewen guewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!
Also, thanks for checking if avoiding a monkey patch was possible. Sadly not, but at least it is applied very narrowly.

@guewen
Copy link
Member

guewen commented Jun 2, 2023

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

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

@OCA-git-bot OCA-git-bot merged commit 0cd9a10 into OCA:16.0 Jun 2, 2023
@OCA-git-bot
Copy link
Contributor

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

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.

[V16-queue_job] Problems with multiple databases

6 participants