Closed Bug 637352 Opened 13 years ago Closed 13 years ago

purge service shouldn't open db's if there are no retention settings

Categories

(MailNews Core :: Backend, defect)

x86
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 5.0b1

People

(Reporter: Bienvenu, Assigned: Bienvenu)

References

Details

(Keywords: perf)

Attachments

(1 file, 2 obsolete files)

Attached patch proposed fix (obsolete) — Splinter Review
We store per-folder override of a server's retention settings in the msg database for the folder. When the purge service is applying retention settings, it causes the db to get opened to check if the folder has overridden the retention settings. Since this is relatively rare, it would be better to store a folder property that says whether the folder is using the server retention settings - if so, we don't have to open the db. This helps in the case of a user with enormous folders w/o retention settings, when opening a db can block the ui for seconds.

I can't write a unit test for the purge service, since it's timer-based and we don't have prefs for the intervals, but I can probably write a unit test for the retention settings.
I can verify that for my profile, the purge service no longer opens db's. This would cut down on general disk churn and heap use.
iirc you said the purge interval is 5 minutes?
Keywords: perf
(In reply to comment #2)
> iirc you said the purge interval is 5 minutes?

It is, but we'll only ever purge any given folder every 8 hours.
Attached patch fix with unit test (obsolete) — Splinter Review
This adds a unit test for basic retention policy handling.
Attachment #515646 - Attachment is obsolete: true
Attachment #519551 - Flags: review?(bugzilla)
Comment on attachment 519551 [details] [diff] [review]
fix with unit test

So there's one main issue I see with this patch - the first time it is run, it leaves virtually all the DBs open. I believe it will also leave DBs open every 8 hours if the folders/servers are set to retain all messages.

I think the issue is that before the GetRetentionSettings call was wrapped by opening the database, doing the call, doing the apply, and then closing the database.

With the new code you're only closing the database if we actually apply the retention settings. 

>+            nsCOMPtr <nsIMsgIncomingServer> incomingServer;

nit: no space before < (several places I think)

>+            if (useServerDefaults)
>+              useServerRetention.AssignLiteral("1");
>+            else
>+              useServerRetention.AssignLiteral("0");

Would the useServerDefault ? "1" : "0" notation be better here?
Attachment #519551 - Flags: review?(bugzilla) → review-
(In reply to comment #5)
> 
> So there's one main issue I see with this patch - the first time it is run, it
> leaves virtually all the DBs open. I believe it will also leave DBs open every
> 8 hours if the folders/servers are set to retain all messages.
If folders are using server retention settings, we'll never open the db (after the very first run with the patch).
> 
> I think the issue is that before the GetRetentionSettings call was wrapped by
> opening the database, doing the call, doing the apply, and then closing the
> database.
Hmm, I'll fix that...

> Would the useServerDefault ? "1" : "0" notation be better here?

If it compiled, it would. But iirc, it didn't :-(
this fixes the closing of the dbs when retention settings aren't applied, and adds a simple test that we're not leaving a db open in that case (first time application of retention settings).
Attachment #519551 - Attachment is obsolete: true
Attachment #519739 - Flags: review?(bugzilla)
Attachment #519739 - Flags: review?(bugzilla) → review+
fixed on trunk

http://hg.mozilla.org/comm-central/rev/b3fe922d09c8
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 3.3a4
See Also: → 1726319
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: