Skip to content
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

Stream hang with concatted lazy failed source fed into lazy inited sink #25410

Closed
jroper opened this Issue Jul 31, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@jroper
Copy link
Contributor

commented Jul 31, 2018

The following is a very round about way of achieving not much, but it's the best minimizer that I've been able to come up with:

  case object MyException extends Exception
  Await.result(
    Source(List(1, 2, 3))
      .concat(Source.lazily(() => Source.failed(MyException)))
      .runWith(Sink.lazyInitAsync(() => Future.successful(Sink.seq[Int])))
      .flatMap {
        case Some(future) => future
        case None => Future.successful(Seq())
      }.recover {
        case MyException => Seq()
      },
    1.second
  )

I expect the above program to finish with no error due to the Future.recover from MyException. However, it fails with a TimeoutException in Akka 2.5.14 on Scala 2.12.

@johanandren

This comment has been minimized.

Copy link
Member

commented Jul 31, 2018

Haven't figured it out yet, but it could be related to the IMO very surprising behavior of concat #23044 (pulling eagerly on all inputs, so the Source.lazily is in fact not lazy in this case).

The consequence from that in this case should be that the failed source will be materialized quite immediately, and could fail the stream before all the initial elements are emitted.

johanandren added a commit to johanandren/akka that referenced this issue Jul 31, 2018

johanandren added a commit to johanandren/akka that referenced this issue Dec 21, 2018

johanandren added a commit to johanandren/akka that referenced this issue Mar 18, 2019

patriknw added a commit that referenced this issue Mar 18, 2019

Race condition in lazy sink on immediate failure (#25413)
* Race condition in lazy sink on immediate failure #25410

@patriknw patriknw added this to the 2.5.22 milestone Mar 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.