Closed Bug 1897376 Opened 1 year ago Closed 1 year ago

nsThreadPool: Make sure we drain all events correctly on shutdown

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: jstutte, Assigned: jstutte)

References

Details

Attachments

(2 obsolete files)

Once a thread pool is asked to shutdown, it will refuse to accept any further events even if those come from a thread running inside the same pool while we are draining the remaining events (the loop continues until there are events). That means, that any processing that relies on a sequence of

  1. "A on other thread dispatches B to the pool"
  2. "B runs on pool and dispatches C to the same pool"
  3. "C runs on pool and dispatches D to original thread to resolve some promise/close some callback roundtrip/whatever"

would break, if the pool is asked to shutdown after 1. but before 2. I think it is worth filing a bug to rule this out.

The above sequence would happen for example if a TaskQueue that refers to that pool has still events in its internal queue when the pool is asked to shutdown. We would want TaskQueues to shutdown before the pools, but there is probably not a too easy way to enforce this, so we want to be resilient.

I think this would be complementary to this check in TaskQueue, as the dispatch would most likely go through a task queue.

Severity: -- → S3
Priority: -- → P3
Assignee: nobody → jstutte
Status: NEW → ASSIGNED
No longer blocks: RunWatchdogShutdownhang
Attachment #9402614 - Attachment description: Bug 1897376 - Add failing ThreadPool.ShutdownCheckDrainAll gtest. r?#xpcom-reviewers → WIP: Bug 1897376 - Add failing ThreadPool.ShutdownCheckDrainAll gtest. r?#xpcom-reviewers
Attachment #9402435 - Attachment description: Bug 1897376 - Allow dispatch from a pool thread to the pool even after shutdown. r?#xpcom-reviewers → WIP: Bug 1897376 - Allow dispatch from a pool thread to the pool even after shutdown. r?#xpcom-reviewers
Attachment #9402614 - Attachment description: WIP: Bug 1897376 - Add failing ThreadPool.ShutdownCheckDrainAll gtest. r?#xpcom-reviewers → Bug 1897376 - Add failing ThreadPool.ShutdownCheckDrainAll gtest. r?#xpcom-reviewers
Attachment #9402435 - Attachment description: WIP: Bug 1897376 - Allow dispatch from a pool thread to the pool even after shutdown. r?#xpcom-reviewers → Bug 1897376 - Allow dispatch from a pool thread to the pool even after shutdown. r?#xpcom-reviewers
Attachment #9402435 - Attachment is obsolete: true
Attachment #9402614 - Attachment is obsolete: true

We discussed this shortly (again) in the XPCOM meeting and while this patch would increase consistency with the behavior of a single nsThread during shutdown, it might create a subtle footgun for events that actually expect to dispatch and run something in parallel while we disallow the creation of new threads.

Given there is no known problem this would solve, we prefer to keep the evident way of failing the dispatch always which forces consumers to be mindful about shutdown.

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: