-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multi-nodes with lock on jobrunner
Starting several odoo (main) processes with "--load=web,queue_job" was unsupported, as it would start several jobrunner, which would all listen to postgresql notifications and try to enqueue jobs in concurrent workers. This is an issue in several cases: * it causes issues on odoo.sh that uses an hybrid model for workers and starts several jobrunners [0] * it defeats any setup that would use several nodes to keep the service available in case of failure of a node/host The solution implemented here is using a PostgreSQL advisory lock, at session level, to lock a database on a specific jobrunner. At loading, the jobrunner tries to acquire the lock. If it can, it initializes the connection and listen for jobs. Every 30 seconds, it tries to acquire again all the databases that it couldn't acquire, in case a concurrent node is stopped. If all the databases have been acquired by a concurrent node, it will do nothing but wait and retry every 30 seconds. Example when a jobrunner is started for databases queue1 and queue2 and another node already works on queue2: INFO ? odoo.addons.queue_job.jobrunner.runner: starting INFO ? odoo.addons.queue_job.jobrunner.runner: initializing database connections INFO ? odoo.addons.queue_job.jobrunner.runner: queue job runner ready for db queue1 DEBUG ? odoo.addons.queue_job.jobrunner.runner: queue job runner already started on another node for db queue2 INFO ? odoo.addons.queue_job.jobrunner.runner: database connections ready for: queue1 Important: new databases need a restart of the jobrunner. This was already the case, and would be a great improvement, but is out of scope for this improvement. [0] OCA#169 (comment)
- Loading branch information
Showing
1 changed file
with
77 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters