Closed Bug 1701414 Opened 5 years ago Closed 5 years ago

Occasional loss of feeds.json data

Categories

(MailNews Core :: Feed Reader, defect)

defect

Tracking

(thunderbird_esr78+ fixed, thunderbird89 fixed)

RESOLVED FIXED
90 Branch
Tracking Status
thunderbird_esr78 + fixed
thunderbird89 --- fixed

People

(Reporter: jwkbugzilla, Assigned: benc)

References

Details

(Keywords: dataloss, regression)

Attachments

(1 file)

So far I’ve lost feeds.json data three times after bug 1534163 landed. I see a “folder” feeds.json.corrupted appear in Thunderbird, it’s a zero-sized file. All RSS subscriptions are gone and have to be restored manually. This never happened with feeds.rdf.

The way I see this, the issue is JSONFile using OS.File.writeAtomic() to save the data. The flush option isn’t being passed here, but it is required to prevent data loss should Thunderbird crash.

Incredibly, this just happened today to a test account. One of the ancient feed renovations added an rdf flush() everywhere but this wasn't carried over to JSONFile. It seems that

 let ds = new JSONFile({ path: feedsFile.path });
+ds._options.flush = true;

and

 let ds = new JSONFile({ path: itemsFile.path });
+ds._options.flush = true;

in FeedUtils.jsm should do it. OS.File is being replaced slowly but they haven't updated JSONFile yet. It seems IOUtils.write() takes the same options as OS.File.writeAtomic() though.

Flags: needinfo?(benc)
Keywords: dataloss

tmpPath is passed though, which is supposed to make it very safe. With tmpPath you will NOT get an incomplete file for process crash, but can get one for an OS crash. backupTo could give some extra safety.
https://searchfox.org/mozilla-central/rev/fa48ebee58d59fa846919c3e2c3122b08db57c9c/toolkit/modules/JSONFile.jsm#464

Also adds the .tmp and .corrupt name variants to the hacky whitelist of
files-to-not-treat-as-mboxes.

Assignee: nobody → benc
Status: NEW → ASSIGNED

I think backupTo is the way to go. It seems to have improved a lot since the last time I looked at it (from memory I seem to recall it didn't play nice with tmpPath).

I think flush is too heavyweight - it extends way beyond the process to stall the whole OS filesystem (and can still have issues with abrupt power-off).

JSONFile already uses tmpFile behind the scenes, so I added the .tmp (and the .corrupt) variant to the icky not-an-mbox lists (which should fix the bogus-folder issue in Wladimir's original comment).

As an aside: looks like JSONFile was already converted from OS.File to IOUtils a couple of times, but reverted each time. I can't imagine it'll be long before the conversion sticks. Shouldn't affect anything here though.

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

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/7aa4bcaad0b5
Use backup file for RSS feeds.json/feeditems.json. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED

Comment on attachment 9217618 [details]
Bug 1701414 - Use backup file for RSS feeds.json/feeditems.json. r?mkmelin

[Approval Request Comment]
Regression caused by (bug #): 1534163
User impact if declined: possible data loss on crash
Testing completed (on c-c, etc.):
Risk to taking this patch (and alternatives if risky):
Low risk patch as this is creating backup files of feeds.json.

Attachment #9217618 - Flags: approval-comm-beta?

Comment on attachment 9217618 [details]
Bug 1701414 - Use backup file for RSS feeds.json/feeditems.json. r?mkmelin

[Triage Comment]
Approved for beta

Attachment #9217618 - Flags: approval-comm-beta? → approval-comm-beta+

Comment on attachment 9217618 [details]
Bug 1701414 - Use backup file for RSS feeds.json/feeditems.json. r?mkmelin

[Approval Request Comment]
User impact if declined: may lose feed data
Testing completed (on c-c, etc.): c-c and beta
Risk to taking this patch (and alternatives if risky): low

Attachment #9217618 - Flags: approval-comm-esr78?

Comment on attachment 9217618 [details]
Bug 1701414 - Use backup file for RSS feeds.json/feeditems.json. r?mkmelin

[Triage Comment]
Approved for esr78

Attachment #9217618 - Flags: approval-comm-esr78? → approval-comm-esr78+

Comment on attachment 9217618 [details]
Bug 1701414 - Use backup file for RSS feeds.json/feeditems.json. r?mkmelin

This patch does not apply on comm-esr78. It looks like the SPECIAL_FILES code is quite different so it's probably better to leave this wontfix for 78.

Specifically, the SPECIAL_FILES constant is not present in converterWorker.js. It looks like that was originally created in bug 1694942 to fix a mailstore conversion bug.

Flags: needinfo?(mkmelin+mozilla)
Attachment #9217618 - Flags: approval-comm-esr78+

Ah, let's wontfix for 78 then.

Flags: needinfo?(mkmelin+mozilla)

Please apply this to 78ESR. All you have to do is skip the hunk in converterWorker.js.

Flags: needinfo?(rob)

Comment on attachment 9217618 [details]
Bug 1701414 - Use backup file for RSS feeds.json/feeditems.json. r?mkmelin

[Triage Comment]
Previously accepted for esr78, will make another attempt based on comment 13.

Flags: needinfo?(rob)
Attachment #9217618 - Flags: approval-comm-esr78+
See Also: → 1726715
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: