-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose current retry count in the context of the function #2595
Comments
And this would need to be piped into Java, Python, C#, PowerShell, and JavaScript context objects - not sure if additional work needed on the language libraries to support this |
I agree |
FWIW I think just the retry count would be good, retry count + defined maximum slightly better, but best case we pass in the entire |
Yes, we might surface RetryContext on ExecutionContext. We'd just have to add MaxRetries to RetryContext - it's not there now. Not sure yet if we should surface that raw type, or have a new type with the members needed. E.g. RetryContext currently has an IFunctionInstance member on it that we might not want to expose here. Need to think about it more. Another important thing - we need to be sure that users understand that there may actually be 2 levels of retries going on. In addition to the retries we're talking about (e.g. retry a single queue message dispatch N times), the queue trigger binding itself has a MaxDequeueCount which is the second level of retries. This is only an issue for triggers with retries already built in (Queue/ServiceBus). So applying this to your example above, you'd need to check both RetryCount as well as DequeueCount :) |
Moving comment from @casper-79 here: Azure/azure-functions-java-library#132 (comment)
|
(we may need to break out a few of these other issues but replying in bulk here): One thing worth noting is that the host retry policy layers on top of the trigger source - it doesn't know anything about the trigger source directly. So for Event Hubs this is easy because Event Hubs itself has no retry policy so this is the only one. However, queues is a bit more interesting. Let's imagine you have a service bus queue, you have a retry policy on the queue (from service bus) of 5 attempts. You then define a function app retry policy on top of it of 5 attempts. What will happen is:
So when you mention in one you are looking at the DeliveryCount, the delivery count between host retries will be the same on the queue message. it's the same queue message being retried. You are right on #2 that if you have long delays on something like a timer trigger, it's possible you'll get scaled down. There is some logic in the scale controller to look at queue length and execution logs, we are investigating it to create clear guidance but in general I'd say on the consumption plan you likely don't want a delay of longer than 5ish minutes (10 may be safe too, longer than 10 you are likely at risk of scale down). I don't believe retry attempts will matter, but I'll try to test this out as well. For the third point, that's where this issue sits. Given the above, I'd say you likely don't want to do maxDeliveryCount of 1 just in case something happens. We are planning to pass in the context so you could have logic like the original comment in this issue that could help as well. |
Thanks @jeffhollan Your description matches my own initial expectations, but even though i looked for signs of step 4/5 I have yet to observe this behaviour. It seems failed messages are just stuck on the queue after the first failure in step 3. When is step 4 supposed to take place? Up until now retries at the queue level have happened immediately, so this is what I have been looking for. Best regards, Casper |
merged #2658 |
Is this something that has been implemented in C# yet? If so, is there a link for documentation or some kind of resource for it? I see NodeJS, Java, and Powershell so far. We are trying to implement some final retry logic but have been unsuccessful through what we've found here and the links within. We currently have a private static retryCount = 0 and increment it on every retry and set to 0 on final retry or success. Which, I believe makes it somewhat stateful in a REST environment since it holds the value between Retries and calls. |
@LockpickingDev this should be available for C# in-proc. Is that what you're currently using? |
All we're doing is taking in a JSON request from an external source and storing it. Theres really not much to it. After reading, it sounds like that's not in-proc though. |
Per the new retry feature rolling out, one scenario that is desired is the ability to deadletter / capture something that is on its final retry. For example, if I have an event hub triggered function and define a retry policy of 5, on the 5th retry if it fails I want to catch that failure and store it in a deadletter queue or something so I can go inspect it later. However, today the context for the current retry count isn't surfaced directly, and using something like a local variable to increment may be tricky when multiple executions could be executing / retrying on the same host.
Proposal is that there is a new context passed into the
ExecutionContext
that includes information on the retry.// @pragnagopa @fabiocav @mathewc
The text was updated successfully, but these errors were encountered: