-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Pipeline order of Retry + Fallback in polly 8 #1694
Comments
Hey @isak1080, looking at your sample I think the behavior is correct. The thing to notice is that the fallback strategy immediately translates the So the retry strategy doesn't see |
Hmm, so are you saying that the following pipeline, the Fallback gets executed first and therefore hides the exception from Retry? I thought they were executed in the order they were added in the builder.
|
Yes, the strategies are executed in the order they were added, however, the wording and details might be improved. In your case, retry strategy receives the callback and executes it, passing it down to fallback strategy. Fallback strategy uses the fallback value. At this point the execution is finished and retry strategy evaluates the result and decided that no retries are required. |
Ah, I think I finally understand what you mean! :) I had the mental image wrong. Been thinking of it as a list of independent handlers which Polly would execute one by one like "Do the retry first and then if that gives up, do the fallback" Feel free to close this issue. But may I suggest you add an example somewhere in the docs for the "retry a few times and if that fails return a fallback value" use case, because I think that is a common scenario and I couldn't find such an example. And also some clarification on the migration guide page what it actually means to be "...executed in the same order they were added..." because even after knowing now how it works, that text confuses me. I keep thinking of "the order" as "the order they get to handle the error" which is not at all what it means. |
Thanks for the feedback. I have added a new info to the docs, hopefully clarifying the execution order. (#1698 ) |
Bug Report
Summary
I'm upgrading from polly 7 to 8 and follow the guide over at https://www.pollydocs.org/migration-v8.html
Specifically, the section about
Policy.Wrap
which says:I had a retry with fallback policy in 7.x that looked like
Running the above on v8 works fine.
My attempt to use the new
ResiliencePipelineBuilder
to achieve the same looks something like this:Executing with the new pipeline always immediately goes to the fallback. Retry is never called
Interestingly, swapping the order in the pipeline builder does in fact produce the correct result.
Steps / Code to reproduce the problem
The attached sample sets up a simple retry + fallback pipeline and shows how the retry is never called unless it is the last one added to the pipeline
This is the output I get on Polly 8.0.0
The text was updated successfully, but these errors were encountered: