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

* Race condition in lazy sink on immediate failure #25410
This commit is contained in:
Johan Andrén 2019-03-18 14:28:31 +01:00 committed by Patrik Nordwall
parent d358a0c3b5
commit 17c80b3be9
2 changed files with 26 additions and 6 deletions

View file

@ -588,7 +588,11 @@ import akka.util.ccompat._
override def onUpstreamFailure(ex: Throwable): Unit = {
// propagate exception irrespective if the cached element has been pushed or not
subOutlet.fail(ex)
maybeCompleteStage()
// #25410 if we fail the stage here directly, the SubSource may not have been started yet,
// which can happen if upstream fails immediately after emitting a first value.
// The SubSource won't be started until the stream shuts down, which means downstream won't see the failure,
// scheduling it lets the interpreter first start the substream
getAsyncCallback[Throwable](failStage).invoke(ex)
}
})