Currently, there is an inconsistency in handling the non-existing of the usage file, which seems to cause a large number (ca. 50%) of temporary storage initialization failures. It is first checked if the usage file exists at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#8763 (possibly removing it afterwards, depending on the existing of the usage journal file). However, even if it did not exist (or was removed), it is attempted to load it at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#8792, if a database file exists. This necessary fails. In that case, `CreateStorageConnection` is called at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#8798. If that detects a corrupted database file, it will attempt to remove the usage file at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#508, which necessarily fails, causing the error to be propagated. This doesn't seem to be the right handling of this case. Instead, removing the usage file in `CreateStorageConnection` should only be attempted if it existed, or failure to remove it because it did not exists should be ignored.
Bug 1684854 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Currently, there is an inconsistency in handling the non-existing of the usage file, which seems to cause a large number (ca. 50%) of temporary storage initialization failures. It is first checked if the usage file exists at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#8763 (possibly removing it afterwards, depending on the existing of the usage journal file). However, even if it did not exist (or was removed), it is attempted to load it at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#8792, if a database file exists. This necessary fails. In that case, `CreateStorageConnection` is called at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#8798. If that detects a corrupted database file, it will attempt to remove the usage file at https://searchfox.org/mozilla-central/rev/2fcab997046ba9e068c5391dc7d8848e121d84f8/dom/localstorage/ActorsParent.cpp#508, which necessarily fails, causing the error to be propagated. This doesn't seem to be the right handling of this case. Instead, removing the usage file in `CreateStorageConnection` should only be attempted if it existed (or a failure to remove it because it did not exist should be ignored).