Closed Bug 1890448 Opened 11 months ago Closed 9 months ago

Rewrite folder compaction

Categories

(MailNews Core :: General, task, P1)

Tracking

(thunderbird_esr115 wontfix, thunderbird127+ fixed)

RESOLVED FIXED
128 Branch
Tracking Status
thunderbird_esr115 --- wontfix
thunderbird127 + fixed

People

(Reporter: benc, Assigned: benc)

References

(Blocks 2 open bugs, Regressed 2 open bugs)

Details

Attachments

(2 files)

The current folder compaction code is fiddly to deal with and hard to fix bugs in.
There was a big series of patches landed in Bug 1756520 which helped a bit by straightening out a lot of the surrounding scaffolding, but left the core compaction code mostly as-is.

A summary of the remaining problems:

  • There are multiple code paths, dependent on folder type:
    • For IMAP folders it iterates through each message and gets the raw data using nsIMsgMessageService.streamMessage().
    • For local folders it issues a single up-front nsIMsgMessageService.copyMessages().
  • Shonky error handling/recovery.
    • Cleanup/rollback is not always correct. A lot of functions just don't clean up after themselves if they fail.
    • There are multiple places where cleanup is attempted, and it's very hard to tell if there are cases which slip through the cracks.
  • GUI code (progress/status updates, error alerts) is mixed in with the core logic.
  • The code is over-complicated:
    • There's no separation of responsibility between msgStore, folder and database - The same code handles both database updates, folder updates and mbox rewriting.
    • IMAP expunge and db rebuild ("repair folder") are tangled up with the compaction.
    • Core compaction logic is complicated by handling multiple folders.
  • It's not always clear when the "I'm finished" listener callback will be called.
    • It's an async operation, but the listener callback might be called synchronously - i.e. before the compact() function returns.

So this bug is a fresh attempt to sort it all out properly.

Attachment #9395915 - Attachment description: WIP: Bug 1890448 - Rewrite folder compaction. → Bug 1890448 - Rewrite folder compaction. r=#thunderbird-reviewers
Blocks: 1714472
Attachment #9395915 - Attachment description: Bug 1890448 - Rewrite folder compaction. r=#thunderbird-reviewers → Bug 1890448 - Rewrite folder compaction (1/2), Add nsIMsgPluggableStore.asyncCompact(). r=#thunderbird-reviewers

This patch replaces the old nsIMsgFolderCompactor code.
It provides new code which deals with the folder/db/notification/GUI
aspects around folder compaction, delegating the mbox wrangling to
nsIMsgPluggableStore.asyncCompact().

Depends on D207101

Severity: -- → S1
Status: NEW → ASSIGNED
Priority: -- → P1

Do we need another bug to clean up preexisting tmp files in the profile directory?
Or use bug 1878541 for that purpose?

Flags: needinfo?(benc)

I'd probably use Bug 1878541 for that.
Once these patches land, nstmp files will no longer be used (well, there will still be temp files, but they are anonymous and the foldercompaction never really knows their name. And if anything goes wrong the file cleanup is waaaay more robust than the old compaction code).

Flags: needinfo?(benc)
Target Milestone: --- → 128 Branch

Pushed by benc@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/4eedc45f960b
Rewrite folder compaction (1/2), Add nsIMsgPluggableStore.asyncCompact(). r=leftmostcat,mkmelin,darktrojan
https://hg.mozilla.org/comm-central/rev/dc0737b9d09a
Rewrite folder compaction (2/2), Replace nsIMsgFolderCompactor. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED

So far ... no problem reports in bugzilla, support or topicbox.
Well, other than my bug 1898780

Regressions: 1898780

As discussed on Matrix, we will want to take this on tomorrow's beta.

Flags: needinfo?(vseerror)
Flags: needinfo?(benc)
Blocks: 1890230

Not taking this in 127.0b4 because of extra caution related to items just noted in bug 1898780

Flags: needinfo?(vseerror)

Comment on attachment 9395915 [details]
Bug 1890448 - Rewrite folder compaction (1/2), Add nsIMsgPluggableStore.asyncCompact(). r=#thunderbird-reviewers

[Approval Request Comment]
Approved for beta

Attachment #9395915 - Flags: approval-comm-beta+

Comment on attachment 9396794 [details]
Bug 1890448 - Rewrite folder compaction (2/2), Replace nsIMsgFolderCompactor. r=#thunderbird-reviewers

[Approval Request Comment]
Approved for beta

Flags: needinfo?(benc)
Attachment #9396794 - Flags: approval-comm-beta+
Regressions: 1900172

Is it in beta 5? In release notes is no word about it.

(In reply to Eugene Savitsky from comment #12)

Is it in beta 5? In release notes is no word about it.

yes

See Also: → 1853584
Regressions: 1901846
Regressions: 1904208
Regressions: 1903174
No longer regressions: 1904208
Regressions: 1911076
See Also: → 1904208
Blocks: 1766101
Regressions: 1925117
Regressions: 1923526
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: