Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
7 Odpowiedzi
51286 Widoki

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

 

Awatar
Odrzuć
Najlepsza odpowiedź

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. 

Awatar
Odrzuć
Najlepsza odpowiedź

The setting max_cron_threads=1 apparently causes another issue though. Cron jobs are just stopping to work after a few days until the docker container gets restarted.

Awatar
Odrzuć
Najlepsza odpowiedź

In my case, it turned out there was a cron that a previous developer added to the system that was always running and never getting done. I inspected the Odoo log file for ir_cron logs. A pair of starting/done logs look like so:

2024-05-30 10:09:29,891 481994 INFO HalaFTTH_db odoo.addons.base.models.ir_cron: Starting job Jobs Garbage Collector.

2024-05-30 10:09:29,895 481994 INFO HalaFTTH_db odoo.addons.base.models.ir_cron: Job Jobs Garbage Collector done.

However, my long running cron only had a 'Starting' but never a 'done' log line. When I turned off that cron, the module upgraded normally. 

Awatar
Odrzuć
Najlepsza odpowiedź

Same situation here, also looking for an answer.

Awatar
Odrzuć
Najlepsza odpowiedź

Same situation here, also looking for an answer.

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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.

Powiązane posty Odpowiedzi Widoki Czynność
3
mar 15
20858
3
kwi 24
3176
1
mar 15
8187
0
lut 25
1720
2
sty 25
8400