vacuum on transient model cannot work
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Fix Released
|
Low
|
OpenERP's Framework R&D | ||
Therp Backports (Deprecated) |
Fix Released
|
Low
|
Stefan Rijnhart (Opener) |
Bug Description
For transient models there are some methods to automatically unlink old records, based on age or a count of records.
At the same time there is logic that is intended to only cleanup older records, after the vaccum function has been called a number of times.
The vacuum function is called:
- from a cronjob
- on each create call on a transient model
problem is that te counter to prevent too frequent calls, is reset on every call. Therefore vacuum cleaning never gets done:
if (not force) and (self._
return True
This problem masks another problem: if configuration is based on a maximum count of records, then when cleaning is done ALL existing records will be deleted. This might not be a problem is only one user is using the transient model at that time. But with multiple users, this is bound to result in errors...
Therefore:
- the counter should ONLY be reset when actual cleaning is done.
- cleaning on number of records should leave a minimum amount of records, or alternatively, only delete records that have not been changed in say 10 minutes.
I will create a branch containing these changes...
Related branches
- Vo Minh Thu (community): Needs Fixing
-
Diff: 105 lines (+28/-37)1 file modifiedopenerp/osv/orm.py (+28/-37)
- OpenERP Core Team: Pending requested
-
Diff: 101 lines (+29/-39)1 file modifiedopenerp/osv/orm.py (+29/-39)
- Raphael Collet (OpenERP) (community): Approve
-
Diff: 78 lines (+31/-18)1 file modifiedopenerp/osv/orm.py (+31/-18)
- OpenERP Core Team: Pending requested
-
Diff: 78 lines (+31/-18)1 file modifiedopenerp/osv/orm.py (+31/-18)
Changed in openobject-server: | |
assignee: | nobody → OpenERP's Framework R&D (openerp-dev-framework) |
importance: | Undecided → Low |
status: | New → Confirmed |
Changed in therp-backports: | |
milestone: | none → 6.1-maintenance |
no longer affects: | therp-backports |
Changed in therp-backports: | |
status: | New → Fix Committed |
importance: | Undecided → Low |
assignee: | nobody → Stefan Rijnhart (Therp) (stefan-therp) |
milestone: | none → 6.1-maintenance |
status: | Fix Committed → Fix Released |
Changed in openobject-server: | |
status: | Confirmed → Fix Released |
Changed in therp-backports: | |
milestone: | 6.1-maintenance → fixed-after-61 |
Thinking further about _transient_ max_count. ...
This parameter seems to mean that whenever the maximum number of records is reached, that cleaning will be done. In the comments of the method, it is described as a limit that when reached will trigger cleaning.
However in the code - which is not reached because of the bug described - something entirely different is done: no matter what the actual number of records is, when count base vacuum is called it will delete a maximum of _transient_ max_count rows.
Actually this might mean that the number of transient records will increase forever. Put max-count on 10. Vacuuming will only be done every 20 records (20 is the _transient_ check_time value). So 10 records will be left in the database. On the next vacuum action, 20 records will be left in the database. And so on....
Seems better to me to forget about count based vacuuming altogether. What is the use case?
If there still is a reason to implement it, then the actual number of records in the database should be retrieved, and compared with the max_count to decide wether deletions should be carried out...