Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@cesarzc
Copy link
Contributor

@cesarzc cesarzc commented Dec 9, 2020

This change adds remarks to constructors and methods that must not be invoked through a Task because it could cause a deadlock if the thread pool is already full when they are invoked.

@bamarsha
Copy link
Contributor

Could you explain a bit more what the deadlock condition is for these methods?

@cesarzc
Copy link
Contributor Author

cesarzc commented Dec 12, 2020

Could you explain a bit more what the deadlock condition is for these methods?

These methods queue (or might queue) Tasks to initialize Bond serializers/deserializers, and at some point, the thread that queued the Task waits for it to complete.

By default, a Task is executed in a threadpool thread. If a Task is queued from a threadpool thread and the threadpool does not have any available threads for the Task to be executed on, the thread from which the Task was queued would be blocked waiting for the Task to complete but the Task would not complete until there is an available thread in the threadpool. An extreme example would be calling one of these methods from a threadpool thread when the size of the threadpool is fixed at one.

The scenario in which this happens is not a common one but it is a possible one under high workload conditions.

@bamarsha
Copy link
Contributor

Thanks for the explanation! Is this something that's specific to the way these methods use tasks, or does it apply to any method that uses tasks internally?

@cesarzc
Copy link
Contributor Author

cesarzc commented Dec 15, 2020

Thanks for the explanation! Is this something that's specific to the way these methods use tasks, or does it apply to any method that uses tasks internally?

It applies to any method that use Tasks internally with the default TaskScheduler and that do an explicit or implicit Wait on the Task.

cesarzc and others added 2 commits December 15, 2020 12:45
Co-authored-by: Sarah Marshall <33814365+samarsha@users.noreply.github.com>
@cesarzc cesarzc merged commit 0ed231e into main Dec 15, 2020
@cesarzc cesarzc deleted the cesarzc/compilationloader-remarks branch May 4, 2021 00:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants