Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrpcWorkerChannel.LoadResponse is not threadsafe #10352

Closed
paulbatum opened this issue Jul 31, 2024 · 0 comments · Fixed by #10363
Closed

GrpcWorkerChannel.LoadResponse is not threadsafe #10352

paulbatum opened this issue Jul 31, 2024 · 0 comments · Fixed by #10363
Assignees

Comments

@paulbatum
Copy link
Member

There is a race in GrpcWorkerChannel that results in failed function executions on this codepath:

System.ArgumentOutOfRangeException : capacity was less than the current size. (Parameter 'value')
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument,ExceptionResource resource)
at System.Collections.Generic.List1.set_Capacity(Int32 value) at System.Collections.Generic.List1.AddWithResize(T item)
at Microsoft.Azure.WebJobs.Script.Grpc.GrpcWorkerChannel.LoadResponse(FunctionLoadResponse loadResponse) at /src/azure-functions-host/src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs : 835
at Microsoft.Azure.WebJobs.Script.Grpc.GrpcWorkerChannel.PendingItem.SetResult(InboundGrpcEvent message) at /src/azure-functions-host/src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs : 1777

The problem is here:

There can be concurrent calls to LoadResponse and they race to call List.Add(..). I suggest using a threadsafe collection for _inputLinks instead of List.

Investigative information

FunctionsLogs
| where PreciseTimeStamp >= datetime(2024-07-30T22:30:00.0000000Z) and PreciseTimeStamp <= datetime(2024-07-30T23:00:00.0000000Z)
| where RoleInstance == "5986acec-de97-44ab-852a-2f23dd8cb503"

Repro steps

Hard to repro due to the race - in general it seems to require very large scale before you get unlucky with the timing and hit this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants