Open Bug 1686060 Opened 3 years ago Updated 3 years ago

Have a recovery path in case removal of .sqlite-shm file fails

Categories

(Core :: Storage: IndexedDB, task)

task

Tracking

()

People

(Reporter: sg, Unassigned)

References

(Blocks 1 open bug)

Details

There are a number of temporary storage initialization failures due to NS_ERROR_FILE_ACCESS_DENIED failures when trying to remove the temporary .sqlite-shm file at https://searchfox.org/mozilla-central/rev/31ddf859c57e812878a5f817e4097efb06de4d97/dom/indexedDB/ActorsParent.cpp#6096.

Would it make sense to retry removal?

Hm, we should try to find out, why it fails after closing sqlite database.

Could this happen because another process that accesses it is still shutting down?

Only the main process can access it, but maybe you meant some other app (not FF). Yes that can probably happen, maybe it's the same issue as in https://searchfox.org/mozilla-central/rev/31ddf859c57e812878a5f817e4097efb06de4d97/dom/quota/ActorsParent.cpp#9743

(In reply to Jan Varga [:janv] from comment #3)

Only the main process can access it, but maybe you meant some other app (not FF). Yes that can probably happen, maybe it's the same issue as in https://searchfox.org/mozilla-central/rev/31ddf859c57e812878a5f817e4097efb06de4d97/dom/quota/ActorsParent.cpp#9743

I was thinking of another main firefox process. Not sure if that's possible?

Actually, it's not clear to me how NS_ERROR_FILE_ACCESS_DENIED and NS_ERROR_FILE_IS_LOCKED are related. The latter clearly sounds like a temporary condition, but the former literally sounds more like an issue with access rights. If that were true, then the condition will probably not resolve. But maybe the distinction is not that clear, but the different error codes are returned depending on which Windows API function was called?

Another main firefox process can't access it. There's a guard that prevents sharing the same profile by multiple FF instances.
Once https://searchfox.org/mozilla-central/rev/31ddf859c57e812878a5f817e4097efb06de4d97/dom/quota/ActorsParent.cpp#9743 is converted to QM_TRY, we can check the error codes, if they are the same.

Unfortunately, I don't have any other suggestions for this at the moment.

See Also: → 1686191

FWIW, NS_ERROR_FILE_ACCESS_DENIED is happening on both Windows and Mac, but NS_ERROR_FILE_IS_LOCKED only on Windows.

I wonder why we have -shm files at all. According to https://sqlite.org/tempfiles.html, these are only required to handle accesses from multiple processes. But as you said, we don't use/allow this. We don't seem to set PRAGMA locking_mode = EXCLUSIVE though. Could we?

Actually, developer tools or the user can open the database file while it's used by FF.
However, we could try to prohibit that. We would then need to provide APIs for developer tools and verify what happens when the database is being used by FF and user tries to open it manually. New APIs for developer tools sounds like a lot of work.

Note that I'm not completely sure what developer tools do with IndexedDB files these days, but I remember they were scanning directories manually and opening the database files. That is also the reason why we keep origin string in each IndexedDB database file, IIRC.

Do the developer tools open the database from outside the main process?

(In reply to Simon Giesecke [:sg] [he/him] from comment #9)

Do the developer tools open the database from outside the main process?

As I said, I'm not sure what the current status, it needs to be verified, maybe :asuth remembers more.
A starting point can be: https://searchfox.org/mozilla-central/rev/31ddf859c57e812878a5f817e4097efb06de4d97/devtools/server/actors/storage.js#2952

You need to log in before you can comment on or make changes to this bug.