[PERF] mail: no memoryerror from slow load_message_failures
Earlier PR improved ACLs in Discuss [1]. Route `/mail/load_message_failures` was made in non-sudo as to take ACLs into account, so that we don't get mail failures that we don't have access [2] However, checking ACLs on `mail.message` from `search` on `mail.notification` is very slow [3], to the point where the RPC takes minutes and results in a `memoryerror`. Ideally we should have non-sudo and make checking ACLs more performant. As a quick fix in a stable version, we revert to using `sudo`, which results in same quick results as before. [1]: https://github.com/odoo/odoo/pull/138330 [2]: https://github.com/odoo/odoo/pull/138330/files#diff-6be51f3695e69474a19cf6857370c8bb9b529a15d568952258cec9a0ae519fc4R23 [3]: https://github.com/odoo/odoo/blob/17.0/addons/mail/models/res_partner.py#L251 closes odoo/odoo#146184 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -20,4 +20,6 @@ class WebclientController(http.Controller):
|
||||
|
||||
@http.route("/mail/load_message_failures", methods=["POST"], type="json", auth="user")
|
||||
def mail_load_message_failures(self):
|
||||
return request.env.user.sudo(False).partner_id._message_fetch_failed()
|
||||
# sudo as to not check ACL, which is far too costly
|
||||
# sudo: res.users - return only failures of current user as author
|
||||
return request.env.user.partner_id._message_fetch_failed()
|
||||
|
||||
Reference in New Issue
Block a user