RuntimeError: maximum recursion depth exceeded in cmp

In Odoo

Here's a shorter blog post than usual to keep trace of an unexpected issue that we faced recently with an Odoo 9.0 instance.

After moving its database from PG9.6 to PG12, the instance was facing weird recursion errors on some calls:

(...)

  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/redacted-production/odoo/openerp/addons/base/res/res_users.py", line 257, in _get_company
    context=context, load='_classic_write')
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/redacted-production/odoo/openerp/addons/base/res/res_users.py", line 955, in read
    res = super(users_view, self).read(cr, uid, ids, other_fields, context=context, load=load)
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/redacted-production/odoo/openerp/addons/base/res/res_users.py", line 316, in read
    return super(res_users, self).read(cr, uid, ids, fields=fields, context=context, load=load)
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/models.py", line 3209, in read
    result = BaseModel.read(records, fields, load=load)
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/models.py", line 3227, in read
    self.check_access_rights('read')
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/api.py", line 469, in new_api
    result = method(self._model, cr, uid, *args, **kwargs)
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/models.py", line 3568, in check_access_rights
    return self.pool.get('ir.model.access').check(cr, uid, self._name, operation, raise_exception)
  File "/opt/odoo/.local/share/virtualenvs/redacted-production/lib/python2.7/_abcoll.py", line 382, in get
    return self[key]
  File "/opt/odoo/redacted-production/addons/redacted-production/odoo/openerp/modules/registry.py", line 84, in __getitem__
    return self.models[model_name]
RuntimeError: maximum recursion depth exceeded in cmp

It turned out that it was due to a Postgresql setting: extra_float_digits:

  • its default value was 0 until PG12
  • starting from PG12, it is 1

Configuring this setting explicitly back to 0 fixed the problem.

Of course, not all RuntimeError: maximum recursion depth exceeded in cmp have this specific root cause.