ir.cron performances: check "doall" parameter earlier

Bug #1039600 reported by Kevin Deldycke
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP Publisher's Warranty Team

Bug Description

Let's say you have defined the following cron job in OpenERP 6.0:

    <record id="ir_cron_collect_invoicing_candidates" model="ir.cron">
        <field eval="&quot;&quot;&quot;collect_and_generate_invoices&quot;&quot;&quot;" name="function"/>
        <field eval="&quot;&quot;&quot;minutes&quot;&quot;&quot;" name="interval_type"/>
        <field name="user_id" ref="base.user_root"/>
        <field eval="&quot;&quot;&quot;Collect invoiceable projects and generate their invoices&quot;&quot;&quot;" name="name"/>
        <field eval="-1" name="numbercall"/>
        <field eval="&quot;&quot;&quot;1900-01-01 00:00:00&quot;&quot;&quot;" name="nextcall"/>
        <field eval="5" name="priority"/>
        <field eval="0" name="doall"/>
        <field eval="1" name="active"/>
        <field eval="10" name="interval_number"/>
        <field eval="&quot;&quot;&quot;project.project&quot;&quot;&quot;" name="model"/>
        <field eval="([], {'invoicing_cron': True})" name="args"/>
    </record>

As you can see it's a job running every 10 minutes. Its next call is defined to a really ancient date (1900-01-01) to make sure it will run.

When installing the module in which this cron job is defined, the OpenERP server will slow down and consume a lot of resources for several minutes.

This phenomenon is caused by the "while" loop in /bin/addons/base/ir/ir_cron.py (see: http://bazaar.launchpad.net/~openerp/openobject-server/6.0/view/head:/bin/addons/base/ir/ir_cron.py#L115 ). This loop will advance from 1900-01-01 to now by 10 minutes increments.

I did not expect this to be an issue because I set the "doall" parameter to False. By doing so, I authorize the cron job to jump in time to now, ignoring intermediate calls.

To fix this, we can refactor the cron loop a little and check the "doall" parameter earlier, saving some iterations.

Related branches

Revision history for this message
Kevin Deldycke (kevin-deldycke-deactivatedaccount) wrote :

BTW, I have an OPW partner contract for my customer. Can I leverage it to fix this issue ?

Changed in openobject-server:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello Kevin,

Yes you are absolutely right ! The execution of while loop when the *doall* is False is worthless and is impacting the performance of the schedulers. This needs to patched so that it will improve the performance of schedulers. A patch for the issue is in progress and will be released soon.
Thanks for the detail explanation and the bug report ! It was quite easy to track the issue.

Thanks,
Naresh

Changed in openobject-server:
importance: Undecided → High
status: New → Confirmed
importance: High → Medium
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

Hello,

Issue has been fixed in,
Branch: lp:~openerp-dev/openobject-server/6.0-opw-578313-rgo
Rev Id: <email address hidden>
Rev No.: 3635

Thanks.

Changed in openobject-server:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.