Ensure that XPI and AddonRepository JSON is completely written before shutdown

RESOLVED DUPLICATE of bug 911621

Status

()

Toolkit
Add-ons Manager
RESOLVED DUPLICATE of bug 911621
4 years ago
4 years ago

People

(Reporter: Irving, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

The AddonRepository and XPIDatabase conversion to JSON added asynchronous writes of the databases, which could happen at shutdown time. I'm not sure how strongly we can guarantee that the write has completed before shutdown; we may need to add something (either a nested event loop or a hook in the main event loop) to wait for these writes to complete.

The async writes may start during profile-before-change, and it's possible for there to be a second write. The worst case scenario is:

First write starts
Data is modified again
profile-before-change notification comes
  Flush JSON; queues a promise to start a second write after the
  first write completes
profile-before-change done
First write completes
Second write begins

The more common (but still rare) cases would be for a single write to be in progress when profile-before-change comes, or for a single write to be triggered by profile-before-change.

My understanding, and Yoric should correct me here if necessary, is that when OS.File shuts down (during xpcom-shutdown) it blocks until all in progress writes have finished. This would mean we're safe in every case *except* my worst case scenario above, if what happens is:

Write starts
Data is modified again
profile-before-change
  set up delayed second write
profile-before-change ends
xpcom-shutdown starts
  OS.File blocks until first in-progress write completes
xpcom-shutdown ends
Second write is attempted, but fails because OS.File is gone
Flags: needinfo?(dteller)
I confirm.
Flags: needinfo?(dteller)
Blocks: 853388, 853389
No longer depends on: 853388, 853389
Blocks: 911820
Depends on: 911621
Work on this is being done in bug 911621.
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 911621
You need to log in before you can comment on or make changes to this bug.