Hi Kaspar,

Worst case scenario is that all 100 fails, they will then loop around the
retry loop until you filter them out, during this time no elements from s
will be consumed but the stream will not dead lock thanks to the preferred
merge that is unfair and ignores s if there are elements coming from 
the feedback loop.

As the elements will be processed sequentially and retried it might
take a long while before a new element from s is consumed upon
failures (it will need to wait for the next 99 * 1s of delay 9 times).

--
Johan Andrén
Typesafe -  Reactive apps on the JVM
Twitter: @apnylle


On Thursday, December 17, 2015 at 10:07:11 PM UTC+1, hbf wrote:
>
> Hey everybody,
>
>
> I'm trying to convince myself that a flow I'm building with Akka Streams 
> is deadlock-free. Here's what I'm trying to do:
>
>    - I have an infinite source *s* of some kind of requests *r1, r2, ... 
> *that I 
>    need "execute". 
>    - In case such an execution fails, I'd like to wait a bit (1s, say) 
>    and try again. 
>    - If a request cannot be executed for 10 times, it will be dropped. 
>
> To keep resource consumption bounded, I thought I'd limit the number of 
> requests (to 100, say). So when there are around 100 requests in the 
> pipeline, the pipeline should not ask the source *s* for new elements but 
> just continue retrying until we have again only 99 or fewer requests.
>
>
> I implemented this pseudo code:
>
>
>    s ~> PreferredMerge        ~> Delay ~> buffer(100) ~> ExecuteRequest ~> 
> Broadcast ~> Report
>
>         PreferredMerge.pref()  <~  RetriedOnceMore    <~  FilterFail    <~ 
> Broadcast
>
>
> Here, the source *s* emits Retry(request, retryCount) objects. These 
> enter a PreferredMerge stage on the un-preferred port, get delayed (using 
> a mapAsync) and then buffered. ExecuteRequest executes the request. The 
> result of this goes to a broadcast, one of whose outputs emits results 
> (succeeded or failed). In FilterFail, requests that failed for less than 
> 10 times are kept and get their retryCount incremented in RetriedOnceMore 
> before 
> they enter the PreferredMerge stage on the preferred port.
>
>
> This works. But could it deadlock?
>
>
> – Kaspar
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to