Skip to content

Commit

Permalink
Fixing race during language worker start
Browse files Browse the repository at this point in the history
  • Loading branch information
alrod committed Dec 13, 2021
1 parent 6aac496 commit 5fe7711
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- Please add your release notes in the following format:
- My change description (#PR)
-->
- Fixing race during language worker start (#7979)

**Release sprint:** Sprint 113
[ [bugs](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+113%22+label%3Abug+is%3Aclosed) | [features](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+113%22+label%3Afeature+is%3Aclosed) ]
Expand Down
1 change: 1 addition & 0 deletions src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ protected virtual void Dispose(bool disposing)
{
_startLatencyMetric?.Dispose();
_startSubscription?.Dispose();
_workerInitTask?.TrySetCanceled();
_timer?.Dispose();

// unlink function inputs
Expand Down
13 changes: 13 additions & 0 deletions test/WebJobs.Script.Tests/Workers/Rpc/GrpcWorkerChannelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ public void Dispose()
_sharedMemoryManager.Dispose();
}

[Fact]
public async Task StartWorkerProcessAsync_ThrowsTaskCanceledException_IfDisposed()
{
var initTask = _workerChannel.StartWorkerProcessAsync(CancellationToken.None);
_workerChannel.Dispose();
_testFunctionRpcService.PublishStartStreamEvent(_workerId);
_testFunctionRpcService.PublishWorkerInitResponseEvent();
await Assert.ThrowsAsync<TaskCanceledException>(async () =>
{
await initTask;
});
}

[Fact]
public async Task StartWorkerProcessAsync_Invoked_SetupFunctionBuffers_Verify_ReadyForInvocation()
{
Expand Down

0 comments on commit 5fe7711

Please sign in to comment.