Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][FIX] ir.cron: check registry earlier to avoid corner case #61277

Open
wants to merge 1 commit into
base: 13.0
Choose a base branch
from

Conversation

nilshamerlinck
Copy link
Contributor

Description of the issue/feature this PR addresses:

  • start instance with workers = 1 and max_cron_threads = 1
  • create new db
  • create 2 inactive ir.cron, cronSystem and cronAdmin:
[{"user_id":1,"interval_number":1,"interval_type":"minutes","active":false,"numbercall":-1,"state":"code","type":"ir.actions.server","name":"cronAdmin","model_id":1}, {"user_id":2,"interval_number":1,"interval_type":"minutes","active":false,"numbercall":-1,"state":"code","type":"ir.actions.server","name":"cronSystem","model_id":1}]
  • install im_livechat
  • activate cronSystem
  • restart instance (to empty the cron worker's cache)
  • cronSystem will run, and thus load the registry in the cron worker
  • deactivate cronSystem
  • uninstall im_livechat
  • activate cronAdmin
  • cronAdmin will fail to run with this traceback:
2020-11-02 16:21:23,695 46 ERROR v13c_cron odoo.addons.base.models.ir_cron: Unexpected exception while processing cron job {'id': 16, 'ir_actions_serv
er_id': 176, 'cron_name': 'cronAdmin', 'user_id': 2, 'active': True, 'interval_number': 1, 'interval_type': 'minutes', 'numbercall': -1, 'doall': None
, 'nextcall': datetime.datetime(2020, 11, 2, 16, 7, 45), 'lastcall': datetime.datetime(2020, 11, 2, 16, 7, 26), 'priority': 5, 'create_uid': 2, 'creat
e_date': datetime.datetime(2020, 11, 2, 8, 0, 45, 442940), 'write_uid': 2, 'write_date': datetime.datetime(2020, 11, 2, 16, 20, 50, 669605)}
Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/api.py", line 745, in get
    value = self._data[field][record._ids[0]]
KeyError: 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/fields.py", line 1000, in __get__
    value = env.cache.get(record, self)
  File "/opt/odoo/odoo/odoo/api.py", line 751, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('res.users(2,).tz', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/api.py", line 745, in get
    value = self._data[field][record._ids[0]]
KeyError: 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/fields.py", line 1000, in __get__
    value = env.cache.get(record, self)
  File "/opt/odoo/odoo/odoo/api.py", line 751, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('res.users(2,).partner_id', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_cron.py", line 237, in _process_jobs
    registry[cls._name]._process_job(job_cr, job, lock_cr)
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_cron.py", line 138, in _process_job
    now = fields.Datetime.context_timestamp(cron, datetime.now())
  File "/opt/odoo/odoo/odoo/fields.py", line 1786, in context_timestamp
    tz_name = record._context.get('tz') or record.env.user.tz
  File "/opt/odoo/odoo/odoo/fields.py", line 1024, in __get__
    self.compute_value(recs)
  File "/opt/odoo/odoo/odoo/fields.py", line 1109, in compute_value
    records._compute_field_value(self)
  File "/opt/odoo/odoo/odoo/models.py", line 3968, in _compute_field_value
    field.compute(self)
  File "/opt/odoo/odoo/odoo/fields.py", line 567, in _compute_related
    values = [first(value[name]) for value in values]
  File "/opt/odoo/odoo/odoo/fields.py", line 567, in <listcomp>
    values = [first(value[name]) for value in values]
  File "/opt/odoo/odoo/odoo/models.py", line 5689, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/opt/odoo/odoo/odoo/fields.py", line 2329, in __get__
    return super().__get__(records, owner)
  File "/opt/odoo/odoo/odoo/fields.py", line 1007, in __get__
    recs._fetch_field(self)
  File "/opt/odoo/odoo/odoo/models.py", line 2974, in _fetch_field
    self._read(fnames)
  File "/opt/odoo/odoo/odoo/addons/base/models/res_users.py", line 378, in _read
    super(Users, self)._read(fields)
  File "/opt/odoo/odoo/odoo/models.py", line 3046, in _read
    cr.execute(query_str, params)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 173, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 250, in execute
    res = self._obj.execute(query, params)
psycopg2.ProgrammingError: column res_users.livechat_username does not exist
LINE 1: ...out_of_office_message" as "out_of_office_message","res_users...

This happens because:

  • the uninstallation of im_livechat changed the res_users schema (dropped livechat_username)
  • but the res.users record for admin is loaded with the old registry, because the signaling check only happens later in the _callback() part.

This PR makes sure the registry check is done before starting to _process_job().

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@C3POdoo C3POdoo added the ORM ORM, python Framework related label Nov 3, 2020
@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses ☑ ci/runbot and removed ☐ ci/runbot labels Nov 3, 2020
@lathama
Copy link
Contributor

lathama commented Apr 15, 2024

@nilshamerlinck knowing that 13 is no longer updated, is this PR still needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI 🤖 Robodoo has seen passing statuses ORM ORM, python Framework related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants