Closed Bug 1700676 Opened 3 years ago Closed 3 years ago

Updating if an origin is accessed on the in-memory object is not guaranteed to be done before shutting down storage

Categories

(Core :: Storage: Quota Manager, defect, P2)

defect

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: tt, Assigned: tt)

References

Details

Attachments

(1 file)

I found this while running originInit.js with my patches in the verify mode (more accurately in the chaos mode).

The test cases basically create a normal cache origin and then check files in the testing cache directory.
In short, the steps roughly are:

  1. Running a script with some normal cache operations.
  2. Resetting.
  3. Checking files.
  4. Initializing.
  5. Checking files again.

In step 4, I expected that the testing origin should be initialized (In other words, InitOrigin should be called).

However, actually, in some extreme cases, that InitOrigin wasn't called and thus some test cases fail because of that.

After looking into it, I think what happened was:
a. In step 1, on the Background thread, Cache registers a directory lock.
b. In step 2, on the Background thread, the Reset operation registers a directory lock and it waits for the blocking lock in step 1 to be released.
c. In steps 2, after the lock is destructed, on the IO thread, the Reset operation shuts down the storage and then writes whether the origin is accessed into database.
d. In steps 2, on the Background thread, the access time and if the origin has been accessed are updated when unregistering the directory lock.
e. In step 4, on the Background thread, it only initializes the origins that are marked as accessed.

In general case, the sequence is like: a->b->d>c->e.
However, it's possible to be like: a->b->c->d->e. It's possible that the origin isn't marked as accessed on the Background thread before shutting down the storage on the IO thread.

For the fix, I think we should unregister the lock before unlocks other blocked locks. So that whether an origin is accessed is updated before updating the SQL statement.

Assignee: nobody → shes050117
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P2
Attachment #9211298 - Attachment description: Bug 1700676 - Unregister the lock itself before unblock other locks; → WIP: Bug 1700676 - Unregister the lock itself before unblock other locks;
Attachment #9211298 - Attachment description: WIP: Bug 1700676 - Unregister the lock itself before unblock other locks; → Bug 1700676 - Unregister the lock itself before unblock other locks;
Attachment #9211298 - Attachment description: Bug 1700676 - Unregister the lock itself before unblock other locks; → WIP: Bug 1700676 - Unregister the lock itself before unblock other locks;
Attachment #9211298 - Attachment description: WIP: Bug 1700676 - Unregister the lock itself before unblock other locks; → Bug 1700676 - Unregister the lock itself before unblock other locks;
Pushed by shes050117@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/10f3e7d643a7
Unregister the lock itself before unblock other locks; r=dom-storage-reviewers,sg,janv
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: