Azure / Azure/azure-functions-host
Inconsistent behavior of FixedDelayRetry in combination with queue messages using C#
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
#### 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:
- Function fails
- Waiting time for 1 minute
- Function fails a second time
-> Goes to the next stage
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:
- First run - First attempt (failure)
- Waits a minute
- First run - Second attempt (failure)
- Second run - First attempt (failure)
- Second run - Second attempt (failure)
- Goes to poison
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:
- First run - First attempt (failure)
- Waits a minute
- First run - Second attempt (failure)
- Waits a minute
- Second run - First attempt (failure)
- Waits a minute
- Second run - Second attempt (failure)
- Goes to poison
Please provide the following:
- Function App version: Local development
- Programming language used: C#
- Microsoft.Azure.Functions.Extensions: v.1.1.0
- Microsoft.NET.Sdk.Functions: 3.0.11
- Please note that I am using dependency injection for the functions. I have a simple example of the queue below
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
Contributor guide
Research direction
Reproduce the behavior with the shown C# QueueTrigger, FixedDelayRetry attribute, and host.json settings. Start by tracing how FixedDelayRetry interacts with queue message DequeueCount and maxDequeueCount. Done means the retry and poison-queue behavior is explained and any regression coverage reflects the expected sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100