vacuum on transient model cannot work

Bug #1009014 reported by Ronald Portier (Therp)
24
This bug affects 4 people
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:

        self._transient_check_count += 1
        if (not force) and (self._transient_check_count % self._transient_check_time):
            self._transient_check_count = 0
            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

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

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...

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
Lara (Therp) (lfreeke)
Changed in therp-backports:
milestone: 6.1-maintenance → fixed-after-61
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Ronald, Stefan, Rafael, Thu,

thanks for your work. As I am affected by that on 6.1, I was wondering:

- maybe this is important enough to have it merged into the official 6.1, maybe backed by an Enterprise contract?

- if not, I gave a look at the ocb 6.1 branch, and if I understand correctly, there is the old version of Ronald's patch, rejected by Thu. Maybe it would make sense to consolidate things and revert the old patch and apply the new one? Incidentally, that would make ocb6.1 more similar to 7.0, true to the name "backport" ).

Thanks!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.