-
-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
squash! Support multi-nodes with lock on jobrunner
Support multi-nodes with lock on job runner Starting several odoo (main) processes with "--load=web,queue_job" was unsupported, as it would start several job runner, 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 job runners [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 in a connection on the "postgres" database, which ensure 2 job runners are not working on the same set of databases. At loading, the job runner tries to acquire the lock. If it can, it initializes the connection and listen for jobs. If the lock is taken by another job runner, it waits and retry to acquire it every 30 seconds. Example when a job runner is started and another one starts: INFO ? odoo.addons.queue_job.jobrunner.runner: starting INFO ? odoo.addons.queue_job.jobrunner.runner: already started on another node The shared lock identifier is computed based on the set of databases the job runner has to listen to: if a job runner is started with ``--database=queue1`` and another with ``--database=queue2``, they will have different locks and such will be able to work in parallel. Important: new databases need a restart of the job runner. This was already the case, and would be a great improvement, but is out of scope for this improvement. [0] #169 (comment)
- Loading branch information
Showing
1 changed file
with
137 additions
and
69 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