From ad458174354501c616ed3b66d51df70b9d444ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 13 Dec 2023 15:50:19 +0100 Subject: [PATCH] [PERF] mail: no `memoryerror` from slow `load_message_failures` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/mail/controllers/webclient.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/controllers/webclient.py b/addons/mail/controllers/webclient.py index babde9c9c6a..8fc74de1f70 100644 --- a/addons/mail/controllers/webclient.py +++ b/addons/mail/controllers/webclient.py @@ -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()