Closed Bug 1879259 Opened 1 year ago Closed 1 year ago

IDBFactory does not notice worker global shutdown which can result in empty IDB databases created without letting the upgradeneeded event run

Categories

(Core :: Storage: IndexedDB, defect, P2)

defect

Tracking

()

RESOLVED FIXED
124 Branch
Tracking Status
firefox124 --- fixed

People

(Reporter: asuth, Assigned: asuth)

References

Details

Attachments

(1 file)

As observed in https://bugzilla.mozilla.org/show_bug.cgi?id=1877619#c2, correct handling of situations where the global is shutting down while an openDatabase call is in flight require us to notice when the global is being torn down. Unfortunately, we only have logic in place for this on windows, not workers. This can result in IDB in the parent process thinking the database has been successfully populated despite nothing happening in the version change transaction because the upgradeneeded event never actually was triggered in content code. Excerpting the details about the specific problem from that comment:

That we try and move forward with the version change transaction on workers is somewhat surprising because we intend to handle this through the call to !EnsureDOMObject(). In particular, we would hope the !factory.GetParentObject() check would detect this. But IDBFactory is not a DOMEventTargetHelper subclass; it only clears mGlobal in IDBFactory::DisconnectFromGlobal but this is only called from nsGlobalWindowInner and never on workers. The good news is that :saschanaz introduced GlobalTeardownObserver for cases like this, and we can use that to replace the window-specific logic IDBFactory::DisconnectFromGlobal.

Assignee: nobody → bugmail
Status: NEW → ASSIGNED

Maybe it would require less refactoring if you added:

  if (mIndexedDB) {
    mIndexedDB->DisconnectFromGlobal(this);
    mIndexedDB = nullptr;
  }

to WorkerGlobalScope::NoteShuttingDown

(Bug 1653276 fixed this for windows, but not workers.)

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

Maybe it would require less refactoring if you added:

I already have a working fix using GlobalTeardownObserver which isn't too large and does simplify some things. Also it's arguably nicer/cleaner! Looking at how easy it is to add a test. (test_abort_on_reload.html is what bug 1653276 added.)

Depends on: 1653276
Attachment #9379143 - Attachment description: WIP: Bug 1879259 - Use GlobalTeardownObserver for consistency on workers. r=#dom-storage! → Bug 1879259 - Use GlobalTeardownObserver for consistency on workers. r=#dom-storage!
Pushed by bugmail@asutherland.org: https://hg.mozilla.org/integration/autoland/rev/def4a6f94713 Use GlobalTeardownObserver for consistency on workers. r=dom-storage-reviewers,janv
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/44629 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: