← Back to team overview

openerp-india team mailing list archive

[Bug 1039600] Re: ir.cron performances: check "doall" parameter earlier

 

** Changed in: openobject-server
       Status: Confirmed => In Progress

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1039600

Title:
  ir.cron performances: check "doall" parameter earlier

Status in OpenERP Server:
  In Progress

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1039600/+subscriptions


References