This question has been flagged
3 Replies
44776 Views

In my postgresql log, I see following error (keeps on beeing logged over and over):

2015-01-28 17:40:26 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 17:40:26 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=2
                                       FOR UPDATE NOWAIT
2015-01-28 17:41:32 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 17:41:32 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=7
                                       FOR UPDATE NOWAIT
2015-01-28 18:36:39 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 18:36:39 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=1
                                       FOR UPDATE NOWAIT
2015-01-28 19:30:44 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 19:30:44 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=9
                                       FOR UPDATE NOWAIT
2015-01-28 19:36:57 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 19:36:57 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=1
                                       FOR UPDATE NOWAIT
2015-01-28 19:41:07 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 19:41:07 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=2
                                       FOR UPDATE NOWAIT
2015-01-28 19:41:16 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 19:41:16 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=7
                                       FOR UPDATE NOWAIT
2015-01-28 21:11:30 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 21:11:30 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=7
                                       FOR UPDATE NOWAIT
2015-01-28 23:30:43 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 23:30:43 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=9
                                       FOR UPDATE NOWAIT
2015-01-28 23:36:55 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 23:36:55 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=1
                                       FOR UPDATE NOWAIT
2015-01-28 23:41:03 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 23:41:03 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=2
                                       FOR UPDATE NOWAIT
2015-01-28 23:41:14 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-28 23:41:14 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=7
                                       FOR UPDATE NOWAIT
2015-01-29 03:07:02 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-29 03:07:02 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=1
                                       FOR UPDATE NOWAIT
2015-01-29 04:07:25 UTC ERROR:  could not obtain lock on row in relation "ir_cron"
2015-01-29 04:07:25 UTC STATEMENT:  SELECT *
                                       FROM ir_cron
                                       WHERE numbercall != 0
                                          AND active
                                          AND nextcall <= (now() at time zone 'UTC')
                                          AND id=1
                                       FOR UPDATE NOWAIT

What is causing this error?

I have following configuration:

  • Odoo v8.0
  • Ubuntu 14.04 LTS on vps
  • No outgoing mailserver configured

 

Avatar
Discard

Same situation here, also looking for an answer.

Same situation here, also looking for an answer.

Best Answer

Please check your ir_cron actions for "scheduled actions" that have  very small interval_time like 1 minute interval. It is likely that the next run is starting before the previous one is finished (LOCKED FOR UPDATE). This happens in scheduled actions like fetching mail from your mail server which may take longer than 1 or 2 minutes due to connection issues or alot of emails to download. 

Avatar
Discard
Best Answer

It seems that if the postgresql server comes up again after being down for a while, odoo tries to run all missed cron entries at once. This results in a bunch of those errors within seconds.

Avatar
Discard
Best Answer

You verify how many openerp server instances have run.

>ps aux | grep oepenrp

or, you set in openerp-server.conf

max_cron_threads = 1

This appears to be because two cron threads run the same command.

Avatar
Discard
Author

I only have 1 server instance running. max_cron_threads is set to 2, but if this is the bug, why does this option even exist? Should I always put max_cron_threads = 1, and why?

If the whole system works properly, settings max_cron_threads = 2 is good.