azure-functions-host: Service bus message actions throwing Grpc.Core.RpcException when sending multiple requests
Description
This occurs with a C# isolated function, using .NET 8 and latest versions of all libraries.
For some reason, when using the message actions with batched service bus messages- some of them will fail with the following error:
Call failed with gRPC error status. Status code: 'Unimplemented', Message: 'Service is unimplemented.
This looks similar to Azure/azure-functions-dotnet-worker#1974, however only occurs after multiple requests have been made within one function execution.
My best guess is some kind of limit, be it connections / pooling not being handled correctly.
Steps to reproduce
- Have a function app which receives a large batch of messages (experienced with ~100).
- Use message actions to deadletter, abandon or complete a large number of the messages.
- Have multiple function executions occurring in short time of each other.
- Short cut could be to fill service bus with a decent number of messages, then call abandon on each message with a large retry set.
Some of the requests will then fail with the GRPC error.
My specific scenario was a function which:
- Receives a batch of messages.
- Tries to bulk insert messages into cosmos.
- Completes successful requests, and abandons failed requests
- This is because comos can hit rate limits, and only allow a portion of the records to be created. Simply allowing the function to retry or complete would cause issues, as either requests would be duplicated or missed.
Happy to provide more info / source code as needed.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 40 (6 by maintainers)
A mitigation for the primary cause (host shutdown) has been checked in and will be part of host release 4.1037.
Issue #10540 has been opened to track the remaining work.
Believe I have found the cause and am working on the fix. On job host shutdown we are unregistering the gRPC endpoints before function invocations have finished.
Was this issue fixed? I still getting this error. Any permanent fix for this issue?
Also seeing this in logs of a batched servicebus triggered function using message actions to manually complete/abandon/deadletter all messages. Our logging makes it difficult to trackdown where exactly the issue is cropping up.
.net 8 isolated service bus triggered batch azure function.
partial stack trace
I’m using ~4 and still getting this problem occasionally, so it doesn’t appear that the fix on the host side worked. Do we know if the rpc exception is transient, so that we can at least mitigate the issue by wrapping the call with a retry policy?
We have also seen this with low volumes of single messages. Running some tests yesterday (4/16), I saw 2 failures out of 20 test messages right after deploying a minor update in our development environment. Since then I’ve been unable to reproduce the exception intentionally after running several thousand messages through the function.
We just upgraded the function to .NET 8 Isolated and running the latest release version of all libraries:
Example Full Stack Trace:
Is the Fix released?? If yes, Please mention which package to update and to which version
After 8 years of ServiceBusHell I just stopped.
I stopped using Service Bus Queue/ Topics, and just developed my own queue using Sql Server and an Eventgrid Topic as trigger. Now I don’t face the endless polling for queue messages, I can see exactly what is in the queue table and retry on demand, isolate messages, sessions is working perfect.
I know exactly what happens and when.
I will try to avoid this weird technology in the future, it gives me headache. 8 years was probably enough 😁😁😁
@MaxEngberg I don’t have an exact date, but I believe Jan/Feb is the current estimate
We also experience the same issue, please give an ETA on when we can expect a solution.
Please advice if this is fixed. We are still getting this error.
Still no fix/workaround? I am facing this issue occasionally when trying to call method
DeadLetterMessageAsyncand internally this error is raised fromDeadletterAsyncfromSettlementClientwhen is this planned to happen?
Apologies for the delayed response here.
Thank you for the information shared so far, this gives us a good idea of what the potential issue is and will be investigating and posting updates here as we make progress.
This is looking like a host problem, so we’ll be transferring this issue to that repo.
As others have mentioned, I’m also encountering this issue for a couple of weeks. Whether I’m using
CompleteMessageAsync,DeadLetterMessageAsyncor letting the function autocomplete messages without usingServiceBusMessageActions, I’m encountering theseRpcExceptions with status “Unimplemented” or “Unavailable”.Due to the fact that my functions create side effects (update database records, file creation, etc.), not being able to rely on message completion/dead-lettering after processing them causes multiple issues. I’d appreciate any help 🙂.
We are also experiencing the same issue when executing an Azure Function via a Service Bus Trigger (.Net 8 Isolated) when Cosmos returns a number of 429s.
Messages are not placed on the DLQ but a RpcExceptions is thrown.
There seems to be a possible correlation with the RpcExceptions and our function initializing. Since we are in consumption plan, our function is often not running during periods of downtime. The following telemetry is a 6 hour snapshot from Azure showing RpcExceptions overlayed with Process CPU.
What is interesting here is that all of the exceptions overlap with periods where the function was not reporting Process CPU yet, likely because it was initializing. There may be some time variation between the reporting of these individual metrics that could invalidate this. However, I thought it might be significant enough to share here.