Open Bug 1646451 Opened 4 years ago Updated 5 months ago

[RKV] get_or_create caches value for corrupted dbs

Categories

(Toolkit :: Storage, defect, P2)

defect

Tracking

()

People

(Reporter: agi, Unassigned)

References

Details

Attachments

(1 obsolete file)

While writing tests for Bug 1645907 I noticed that rkv retains state from a corrupted tabase. This is problematic because the usual way to recover from a corrupted db is to delete (or move) the corrupted files and re-create the database. This is not possible currently because even after moving the files get_or_create will fail with the cached error.

This is the test I'm using:

+  async recreateCorruptDatabase(path) {
+    try {
+      let uuid = gUUIDGenerator.generateUUID().toString().slice(1, -1);
+      const backupFolder = FileUtils.getDir("ProfD", ["extension-store.corrupt"], true);
+      backupFolder.append(uuid);
+      await OS.File.move(path, backupFolder.path, { noCopy: true });
+      await OS.File.removeDir(path);
+    } catch (ex) {
+      // At this point there's not a lot we can do
+      Cu.reportError(ex);
+    }
+
+    await OS.File.makeDir(path);
+    // Create new database file
+    this._store = await KeyValueService.getOrCreate(path, "permissions");
+  }
+

The last call to getOrCreate will fail even though the directory is empty.

Assignee: nobody → agi
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P2
Blocks: 1645907
Pushed by asferro@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e43c0a04679a
Clear rkv::get_or_create cache when an error occurs. r=vporof
Backout by ncsoregi@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/613e8419e9b5
Backed out 2 changesets (bug 1646451, bug 1645907) for failures on test_extension_permissions_corrupt.js . CLOSED TREE

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:agi, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(agi)
Depends on: 1597898
Flags: needinfo?(agi)
Attachment #9157384 - Attachment is obsolete: true
Assignee: agi → nobody
Status: ASSIGNED → NEW

It seems that this may have been already covered on the rkv side in https://github.com/mozilla/rkv/pull/207 (which I just linked as a seealso).

I think that it would be still better to confirm with Lina if that is actually the case as it seems and and if there is anything else that may still be needed to be done on the mozilla-central side in Bug 1645907 comment 9, and so I'm leaving the issue status unchanged.

Summary: get_or_create caches value for corrupted dbs → [RKV] get_or_create caches value for corrupted dbs
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: