[18.0][FIX] autovacuum_message_attachment: Add missing message_type 'auto_comment' and allow to batch deletion - #3665
Conversation
|
Hi @florian-dacosta, |
70113ae to
e6088fe
Compare
039f8aa to
9e35c6f
Compare
| with Registry(self.env.cr.dbname).cursor() as new_cr: | ||
| if batch_size == -1: | ||
| batch_size = len(self) | ||
| if not batch_size or batch_size < 0: |
There was a problem hiding this comment.
TODO: use if not batch_size or batch_size < new_cr.IN_MAX: instead
Done
| with Registry(self.env.cr.dbname).cursor() as new_cr: | ||
| if batch_size == -1: | ||
| batch_size = len(self) | ||
| if not batch_size or batch_size < 0: |
9e35c6f to
3b76be4
Compare
| with Registry(self.env.cr.dbname).cursor() as new_cr: | ||
| if batch_size == -1: | ||
| batch_size = len(self) | ||
| if not batch_size or batch_size < new_cr.IN_MAX: |
There was a problem hiding this comment.
| if not batch_size or batch_size < new_cr.IN_MAX: | |
| if not batch_size: |
Why not letting the option to the caller to have a batch size smaller than IN_MAX
There was a problem hiding this comment.
@TDu Because a small batch size is almost never a good idea, especially due to IO and database query optimization.
On the other side, Odoo uses IN_MAX everywhere: If you had a reason to want smaller batch size, you would likely need it changes for the whole Odoo, not just the batch operations.
|
|
||
| def batch_unlink(self): | ||
| def batch_unlink(self, batch_size=0): | ||
| # batch_size == -1 => delete everything in a single unlink (no chunking). |
There was a problem hiding this comment.
Why this option when it open the risk of Out Of Memory errors ?
Also mutating the IN_MAX value above a certain value is probably not recommended ! IMO
There was a problem hiding this comment.
It does not increase the risk of OOM, because little resources are allocated.
The GC will also not run between your batches, because your records are still referenced.
https://github.com/odoo/odoo/blob/03256802105c6273f62a5305d2395d7771418e0b/odoo/orm/models.py#L4232
https://github.com/odoo/odoo/blob/18.0/odoo/tools/misc.py#L692
On the other side, allowing to increase this limit reduces the risk of timeouts and idle transactions.
The max value acceptable for IN_MAX will depend on the context of the database. I was able to raise it to 1M on the customer database without issue, but it was not providing any performance improvment compared to batches of 50k.
|
@TDu I answered your questions. could you check? |
auto_commentmessage_type was missing=> Add the option
=> Added
batch_sizeparameter to the rulessearchperformedorderbywhich forces an extra sort on the whole table=> Use
_searchinsteadunlinkis batched by Odoo natively, andbatch_unlinkwas also batching with its own value=> Make them use the same limit and added a batch size parameter to
batch_unlink