Scheduler is not working when OpenERP is running with gunicorn
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Fix Released
|
Wishlist
|
OpenERP's Framework R&D |
Bug Description
The OpenERP scheduler ois not working correctly in version 6.1 when OpenERP is running using gunicorn. In the initial investigations that I've done I think that the problem is because each gunicorn worker is running in a separate thread, so the memory space is different. OpenERP is designed to be stateless, so this should be fine. However, in the case of the scheduler, tasks are being pushed and popped from the heap... which will be different for each process.
I think that a more robust solution would be add the tasks to the database and the cron Master Thread process would read from the database (instead of the heap).
This is straightforward to verify: create some scheduled actions that are due to be run (there are some in the system by default) and start OpenERP using gunicorn. You should see that the scheduled actions aren't run. Then compare what happens when OpenERP is started in a single-threaded manner e.g. ./openerp-server -d dbname. This time you'll see that the schedule actions are run.
Related branches
- OpenERP Core Team: Pending requested
-
Diff: 92 lines (+37/-8)2 files modifiedgunicorn.conf.py (+3/-0)
openerp/cron.py (+34/-8)
Hi,
You are guessing too much :)
The main cron thread is simply not running at all when using Gunicorn. Gunicorn workers should only be used to serve requests (so resource consumption is directly related to the request and appropriate actions can be taken if limits are reached without affecting cron jobs).
That being said, we should look to providing a way to start the main cron thread in the main Gunicorn process.