Closed ericleigh007 closed 3 months ago
This can have a few different causes. First, check if the lock timeout on your entity (queue or topic / subscription) is set above the interval of calling RenewMessageLockAsync, keeping in mind that the call itself needs some time as well. Also, there might be a conflict between the AutoRenewLock of the function and your lock renewal, we would recommend using the AutoRenewLock of the function itself. Do note that these messages can still occur in that case, as described here. As such, the best option is to decide if the messages are actually not renewed, or if this is just noise.
@EldertGrootenboer thanks for your response. First of all, as stated in my problem report above, we're using batch receipt of messages, so there is no option for autorenew. The Message Lock Duration for all the subscriptions is 5 minutes When the function attempts to renew the lock, there are 2 minutes left in the lock time according to LockedUntil. On some of the locks, we get the error stated above when we call RenewMessageLockAsync on the message just scant milliseconds later.
@ericleigh007 Thank you for the feedback. In this case I would recommend opening a support request instead, so you can share all details on your namespace, functions runtime, etc, as this looks like it might be a combination of things coming together.
Description
Using the Batching service bus trigger, inability to reliably renew the message lock #233
We have an application that needs to ingest and aggregate messages from the service bus. In other words, we take in small bits of XML and ouput an aggregated XML, in a single invocation of a single service bus [batch] triggered function. The output of the aggregated message is a call with the data, to an Azure SQL PaaS stored procedure In some rare circumstances the stored procedure takes over one minute to process its input, and sometimes it can even take greater than 5 minutes. We are using a 1000 message batch of input to the aggregator and would not want to set aggregation lower than this for various reasons beyond the scope of this description. We have built a thread of execution in our function that calls the
messageActions.RenewMessageLockAsync(msg)
API in order to renew each of the messages in the batch. Most of the time, this works fine, but on some messages we get an error indicating a "plethura" of possible problems. 99.9% of the time, calling this API for 1000 messages works fine and takes around 70 seconds, which should keep the messages from expiring. However, that other 0.1% of the time, the lock cannot be renewed for some reason, and the error message states:We were relying on the service bus to allow us to either
Here's an example function:
Here's an excerpt from our host.json configuration for the function app.
Our lock renewal code looks like this. Although there are multiple functions running in a function app, each function will have unique message ID's with which to operate. Each function is connected to a service bus topic/subscription that sends it like messages to aggregate.
Unique ID's, subscriptions, etc, can be shared in private.
Actual Behavior
Expected Behavior