Exchange: a rebuilt folder database (deleted .msf, Repair Folder) leaves the folder permanently empty: sync token kept, and maildirValid never set
Categories
(MailNews Core :: Networking: Exchange, defect)
Tracking
(Not tracked)
People
(Reporter: btirmarche, Assigned: btirmarche)
Details
Attachments
(1 file, 1 external file)
Thunderbird 158, Exchange (EWS) account, maildir store, some messages downloaded for offline use.
Steps: quit Thunderbird, delete the Inbox .msf (or use Repair Folder), then restart.
Actual: the Inbox stays empty for good, with no error. The folder's ewsSyncStateToken survives in folderCache.json, so the next sync only asks for changes. If the token is removed by hand, the folder resyncs fully, but it is empty again after the next restart: the rebuilt .msf has no maildirValid (the original one had it).
Cause:
nsMsgMaildirStore::IsSummaryFileValidrequiresmaildirValidin dbFolderInfo oncecur/holds messages. For Exchange folders, that flag is set at folder creation and as a side effect ofnsMailDatabase::DeleteMessages, but never on a database created byExchangeFolder::GetDatabase→CreateNewDB.- On the next open, the summary is reported out of date and deleted, and
GetDatabasesilently creates another empty database. Meanwhile the sync token is kept, so the folder never fills again.
Patch: when GetDatabase falls back to CreateNewDB, clear ewsSyncStateToken (forcing a full resync), call SetSummaryValid(true) and commit, and log the rebuild. Test: test_rebuiltDatabaseResync.js (maildir and mbox).
Built and tested locally (macOS, mozilla-central of 2026-10-16 + comm-central d438ab08ff66): the test passes, and fails without the fix ("the sync state should have been reset along with the database"). Exchange unit tests 30/30, lint clean on the changed lines.
Known follow-ups: a rebuild resync treats every message as new (filters, junk classification and notifications run again), and with maildir the old offline files are left orphaned in cur/.
See also bug 1967333.
| Assignee | ||
Comment 1•1 month ago
|
||
Proposed fix, includes test_rebuiltDatabaseResync.js (built and tested locally, see the description).
Comment 2•1 month ago
|
||
Justin - is your in-progress sync token work going to handle this case?
Comment 3•1 month ago
|
||
Nope, this is an EWS (and Graph, presumably) bug, the patch I'm working on only affects Graph. I can take it on since it's also touching sync state token problems.
Benoit: Our Phabricator instance we normally use for code review isn't publicly accessible right now, but should be in the next week or so. Would you like to submit this your patch there once it's back, and go through the review process, or would you prefer to just treat it as part of the bug report and let me take over the fix?
Updated•28 days ago
|
| Assignee | ||
Comment 4•26 days ago
|
||
Thanks Justin! I'd like to take care of it. Phabricator is reachable for me now, so I'll submit the patch there shortly and go through the review process.
| Assignee | ||
Comment 5•26 days ago
|
||
When OpenFolderDB() fails, ExchangeFolder::GetDatabase() creates an empty
database but used to keep the folder's ewsSyncStateToken, so the next sync only
fetched changes and the folder stayed empty. It also never marked the new
summary valid, so with maildir the rebuilt database was discarded again on the
next startup.
Clear the sync state and call SetSummaryValid(true) when a new database is
created, and log the rebuild.
The resulting full resync treats the folder's messages as new (filters, junk
classification, notifications); avoiding that is left to a follow-up.
Updated•13 days ago
|
| Assignee | ||
Comment 6•13 days ago
|
||
D337981 is accepted, thanks! I can't set the target milestone on this bug, which Bugzilla requires for checkin-needed-tb. Could you add checkin-needed-tb, or assign the bug to me so I can request landing?
Comment 7•12 days ago
|
||
Oh, sorry about that.
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/87c438c61ecf
Reset the sync state and mark the summary valid when an Exchange folder's database is rebuilt. r=jtracey
Description
•