Closed Bug 1543030 Opened 5 years ago Closed 4 years ago

Consider changing the way how we call AbortOperationsForProcess

Categories

(Core :: Storage: Quota Manager, task, P3)

task

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox68 --- affected

People

(Reporter: janv, Unassigned)

Details

Attachments

(1 obsolete file)

There are two bugs which are related, bug 1542706 and bug 1542675.
Both needs to be fixed (although it's probably the same issue), but we should consider changing AbortOperationsForProcess to be called differently.

The stack trace and especially treeherder log shows that we got AbortOperationsForProcess call on the PBackground thread, but the channel was already closed, so many IPC messages triggered by AbortOperationsForProcess fail to send. For example SendRequestAllowToClose. Our code should handle that to have protection for an unexpected channel close, but in normal situations we should try to call stuff in order.
I think, there's currently a race in normal content parent shutdown procedure between channel closing and RecvAbortOperationsForProcess.

QuotaManagerService::AbortOperationsForProcess is currently called here:
https://searchfox.org/mozilla-central/rev/8d78f219702286c873860f39f9ed78bad1a6d062/dom/ipc/ContentParent.cpp#1385

Close() is called few lines below. That closes the IPC channel. The close method actually sends a message to the child and blocks the thread until the state is changed to closed.

So if we synchronously call AbortOperationsForProcess it should work better I guess.

The problem is that I'm not sure if there are separate channels for PContent and PBackground. If there are separate channels then sync AbortOperationsForProcess wouldn't help.
There's another possibility that the channel for PBackground is closed somewhere else.

We should definitely investigate this more.

There are separate channels. In non-debug builds, PBackground will never get shutdown cleanly because the content process will self-terminate for speed so only OnChannelError shutdown will happen. In debug builds, the child process goes through full XPCOM shutdown. I have some notes at https://github.com/asutherland/asuth-gecko-notes/blob/master/ipc/SHUTDOWN.md that are not perfect but may be helpful or at least confirm your own code-reading.

The priority flag is not set for this bug.
:overholt, could you have a look please?

Flags: needinfo?(overholt)
Type: defect → task
Priority: -- → P3
Flags: needinfo?(overholt)

(In reply to Andrew Sutherland [:asuth] (he/him) from comment #1)

There are separate channels. In non-debug builds, PBackground will never get shutdown cleanly because the content process will self-terminate for speed so only OnChannelError shutdown will happen. In debug builds, the child process goes through full XPCOM shutdown. I have some notes at https://github.com/asutherland/asuth-gecko-notes/blob/master/ipc/SHUTDOWN.md that are not perfect but may be helpful or at least confirm your own code-reading.

Hm, that's really good description of browser shutdown and especially content shutdown.
Anyway, what do you think about the patch I just submitted ?
Can we call AbortOperationsForProcess in the first turn of ShutDownProcess ?
Quota manager would have a better chance to abort stuff this way.

I tested the patch on try server, looks good:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=e89baae86dd17f23d1764499177255d9cf826bf7

Flags: needinfo?(bugmail)
Flags: needinfo?(bugmail)

:janv, do you still think, this helps? Then assign it to dom-workers-and-storage-reviewers to be reviewed. Thank you!

Flags: needinfo?(jvarga)

We don't this for now. We may actually remove this call in future.

Status: NEW → RESOLVED
Closed: 4 years ago
Flags: needinfo?(jvarga)
Resolution: --- → WONTFIX
Attachment #9065870 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: