Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.93k stars 440 forks source link

Inconsistent behavior of FixedDelayRetry in combination with queue messages using C# #7267

Open plamber opened 3 years ago

plamber commented 3 years ago

Check for a solution in the Azure portal

Hello, I am experiencing some unexpected behavior using following attribute on a Queue trigger written on C#.

[FixedDelayRetry(2, "00:01:00")]

My expectation is that the function does following:

Under next stage I understand that in case of a queue trigger it follows the maxDequeueCount value and follows the process above following the DequeueCount value.

I tried to configure host.json as follows:

{
  "version": "2.0",
  "queues": {
    "maxDequeueCount": "1",
    "maxPollingInterval": "00:00:02"
  },
  "logging": {
    "applicationInsights": {
      "httpAutoCollectionOptions": {
        "enableW3CDistributedTracing": true
      },
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  }
}

With this configuration I am expecting that it tries to follow only the FixedDelayRetry and puts after 2 failures the queue message into poison queue.

It indeed follows the FixedDelayRetry twice with the specified amount of time. But on the second failure it immediately triggers the queue 2 additional times without waiting:

But based on my configuration my expectation is that it just executes the first run and then putting the message immediately in the poison queue. Even if the second run would be ok, it is no more considering the configured fixeddelayretry timespan. If I I configure a maxDequeueCount of 2 I would expect following behavior for example:

Please provide the following:

Source ```csharp public class WebhookQueue { //constructor with dependency injection [FunctionName(nameof(WebhookQueue))] [FixedDelayRetry(2, "00:01:00")] public async Task RunAsync([QueueTrigger(IEasyLifeQueueEntry.WebhookEvent, Connection = "AzureWebJobsStorage")] string input, ILogger log) { throw new Exception() } } ```

Thank you for your feedback, Patrick

v-anvari commented 3 years ago

Hi @plamber, This feature is in preview mode and the team is actively working towards improving documentation on the expected behavior for functions that use retry and deploy to Azure. You can find related information here - https://github.com/Azure/azure-webjobs-sdk/issues/2624

plamber commented 3 years ago

Hi @v-anvari , Thank you for your feedback. I checked your reference but I am not understanding if what I described is as expected or not.

Could you share more insights?

Thank you

v-anvari commented 3 years ago

Hi @plamber, There are known in consistent behavior with the Retry policy while using C#. The team is working on the Product Fix. You can find the Document communication that had happened earlier here- https://github.com/MicrosoftDocs/azure-docs/issues/71628

hezite commented 2 years ago

are there any updates on the issue?