[FIX] base: avoid concurrent deletes when generating assets
Since [1] when website was moved to the backend, the `DELETE` SQL statement introduced in [2] can fail in situations where it happens in several workers at the same time. To avoid this, this commit filters the deleted ids to only keep the ones that are not locked. Steps to reproduce: - Revert commit [3]. (It avoids this scenario by returning to the root page.) - Start with only `website` installed. - Access a non-existing page. (e.g. `/@/a`) - Click on "+New". - Click on "Blog Post". - Click on "Install". => Popup with traceback when reloading the page. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b [2]: https://github.com/odoo/odoo/commit/0b22f4deee3129a84daa7113393da6e7200de6ff [3]: https://github.com/odoo/odoo/commit/886900c33d18f647016e596ba41c193f5fcf8a43 closes odoo/odoo#107635 X-original-commit: 5390199b1b3dcee1cbfb28ea9bbdeba0469a75d2 Signed-off-by: Julien Castiaux <juc@odoo.com>
This commit is contained in:
@@ -257,7 +257,9 @@ class AssetsBundle(object):
|
||||
Such a view would be website.layout when main_object is an ir.ui.view.
|
||||
"""
|
||||
to_delete = set(attach.store_fname for attach in attachments if attach.store_fname)
|
||||
self.env.cr.execute(f"DELETE FROM {attachments._table} WHERE id IN %s", [tuple(attachments.ids)])
|
||||
self.env.cr.execute(f"""DELETE FROM {attachments._table} WHERE id IN (
|
||||
SELECT id FROM {attachments._table} WHERE id in %s FOR NO KEY UPDATE SKIP LOCKED
|
||||
)""", [tuple(attachments.ids)])
|
||||
for file_path in to_delete:
|
||||
attachments._file_delete(file_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user