Describe the bugReadManyTaskHelperAsync code has suspicious Task.Run call that looks as a potential issue: Task.Run schedules task on thread pool's thread and potentially can cause thread pool being exhausted.
This Task.Run call looks unnecessary and instead of wrapping async code into Task.Run (that can put higher pressure on thread pool) ReadManyTaskHelperAsync -> for loop -> tasks.Add(Task.Run(async () => why code doesn't do this instead:
ReadManyTaskHelperAsync -> for loop -> tasks.Add(DoStuffAsync(params, semaphore))
Expected behaviorTask.Run is not called in ReadManyItemsAsync execution. Thread pool is not used.
Actual behaviorTask.Run is called in ReadManyItemsAsync execution. Thread pool is used.
Environment summary
SDK Version: 3.39.1
OS Version: Windows
Additional context
There was potential issue reported here but it was not really proven that issue came out of this method call and reporter eventually mitigated with other solution.
Describe the bug
ReadManyTaskHelperAsync
code has suspicious Task.Run call that looks as a potential issue:Task.Run
schedules task on thread pool's thread and potentially can cause thread pool being exhausted.This
Task.Run
call looks unnecessary and instead of wrapping async code intoTask.Run
(that can put higher pressure on thread pool)ReadManyTaskHelperAsync -> for loop -> tasks.Add(Task.Run(async () =>
why code doesn't do this instead:ReadManyTaskHelperAsync -> for loop -> tasks.Add(DoStuffAsync(params, semaphore))
To Reproduce Run ReadManyTaskHelperAsync
Expected behavior
Task.Run
is not called inReadManyItemsAsync
execution. Thread pool is not used.Actual behavior
Task.Run
is called inReadManyItemsAsync
execution. Thread pool is used.Environment summary SDK Version: 3.39.1 OS Version: Windows
Additional context There was potential issue reported here but it was not really proven that issue came out of this method call and reporter eventually mitigated with other solution.
cc @ealsur