Hello Community,
I have a problem with the cron job that stops on a regular basis running after a while. I have been looking into the logs and I came across this error:
RuntimeError: OrderedDict mutated during iteration
Full log:
2022-03-28 12:26:57,168 344737 INFO test-server: xxx\.xxx\.xxx\.xxx\ \-\ \-\ \[28\ Mar2022\ 12:26:57\\]\\ "POST\\ /longpolling/poll\\ HTTP/1\\.0"\\ 200\\ \\-\\ 8\\ 0\\.002\\ 50\\.007
Exception\ in\ thread\ odoo\.service\.cron\.cron1:
Traceback\ \(most\ recent\ call\ last\):
\\ \\ File\\ "/usr/lib/python3\\.9/threading\\.py",\\ line\\ 954,\\ in\\ _bootstrap_inner
2022\\-03\\-28\\ 12:26:59,512\\ 344737\\ INFO\\ test\\-server\\ werkzeug:\\ 84\\.192\\.32\\.235\\ \\-\\ \\-\\ \\[28/Mar/2022\\ 12:26:59\\]\\ "POST\\ /longpolling/poll\\ HTTP/1\\.0"\\ 200\\ \\-\\ 8\\ 0\\.003\\ 50\\.009
\\ \\ \\ \\ self\\.run\\(\\)
\\ \\ File\\ "/usr/lib/python3\\.9/threading\\.py",\\ line\\ 892,\\ in\\ run
\\ \\ \\ \\ self\\._target\\(\\*self\\._args,\\ \\*\\*self\\._kwargs\\)
\\ \\ File\\ "/opt/odoo14/odoo/odoo/service/server\\.py",\\ line\\ 432,\\ in\\ target
\\ \\ \\ \\ self\\.cron_thread\\(i\\)
\\ \\ File\\ "/opt/odoo14/odoo/odoo/service/server\\.py",\\ line\\ 408,\\ in\\ cron_thread
\\ \\ \\ \\ for\\ db_name,\\ registry\\ in\\ registries\\.d\\.items\\(\\):
RuntimeError:\\ OrderedDict\\ mutated\\ during\\ iteration
This\\ error\\ happens\\ when\\ the\\ cron\\ job\\ runs\\.
I\\ found\\ this\\ website:\\ https://chowdera.com/2021/09/20210913213439937A.html
Explaining that the problem is related to the python version. Python >=3 has this problem. But oodo14 requests python >=3.6
They suggest a solution, in server.py in the function
def cron_thread(self, number):
change the line
for db_name, registry in registries.d.items():into
for db_name, registry in list(registries.d.items()):This sounds reasonable, but I wonder why this isn't done by odoo itself?
Could this be the solution? Is this an unreported bug? Or is there something else that is the cause of this?
Thanks for your reply.
my customer bumped into this similar problem, I wonder why, even this post still hasn't got any replies
I've been struggling with this problem myself. It kills the cron jobs after it happens twice (assuming it's because default cron workers is 2). Going to try your solution