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
Misconfiguration of blocking IO dispatcher for akka streams #24357
Comments
Good catch! The reason why it was not noticed that the The correct fix for this would be to leave the config as is, change that |
This is starting to look like one of those cases where you come across a seemingly simple bug, only to find yourself stumbling upon a wall. I went through the akka configuration (
and the consuming code does something like this: val dispatcherId = system.settings.config.getString("someconf.default-dispatcher-name")
val dispatcher = system.dispatchers.lookup(dispatcherId) Thus, your suggestion @johanandren to leave the config intact is correct, as it is on par with what users would expect from such a configuration property (it's actually public API, so any change to it is a breaking one). However, modifying how the object ActorAttributes {
import Attributes._
final case class Dispatcher(dispatcher: String) extends Attribute
final case class SupervisionStrategy(decider: Supervision.Decider) extends Attribute
val IODispatcher: Dispatcher = ActorAttributes.Dispatcher("akka.stream.default-blocking-io-dispatcher")
/**
* Specifies the name of the dispatcher. This also adds an async boundary.
*/
def dispatcher(dispatcher: String): Attributes = Attributes(Dispatcher(dispatcher))
// ... Consumers of this class (i.e. someSink.withAttributes(ActorAttributes.dispatcher("my.conf.dispatcher")) with a configuration that would look like this:
Changing the akka internals to treat the
in order for the Scala snippet above to work with the "new" underlying resolution strategy. Besides breaking the public API (which is a big deal by itself), such a change would also make the API counter-intuitive (due to the "inception" stuff mentioned above), and all that hassle would be only to provide a small configuration benefit which probably nobody has ever attempted to make use of (or at least no-one has ever complained about it not working...). As an added bonus, the dispatcher resolution does not occur only in one place; there's actually three places that make use of the
which effectively means that any new resolution logic would have to be used on all three of them, as well as any new point in the future. The only sound approach to solving this issue would have been to some-how manage to resolve the value of the object ActorAttributes {
import Attributes._
final case class Dispatcher(dispatcher: String) extends Attribute
final case class SupervisionStrategy(decider: Supervision.Decider) extends Attribute
val IODispatcher: Dispatcher = ActorAttributes.Dispatcher(magic-resolution("akka.stream.blocking-io-dispatcher")) However, resolving the property value at that point does not seem possible, as Given all the above I cannot think of any reasonable modification to the current implementation. Perhaps it should be that the documentation (and corresponding comments in the source code) should be updated by removing the claim that the API supports parameterization of the default I would be interested to hear your thoughts on this. |
* Remove docs and have only deprecation comment on old setting * ConfigFactory.load fixed
It must still have a valid value becuase used from Akka HTTP.
…cher-patriknw fix blocking-io-dispatcher setting, #24357
While working with akka streams API, I came across an issue when I used the following statement:
That call resulted to the following exception:
I went through the akka sources, and the configuration at reference.conf is as follows:
So it would seem that the configuration should probably be like this:
This finding however made me wonder why this error doesn't occur in the akka-stream library in general. Theoretically, according to the akka docs:
so I went a little bit further with the research, and came across this inside
akka.stream.ActorAttributes
:This effectively means that the stream IO dispatcher is fixed to the default one (i.e.
akka.stream.default-blocking-io-dispatcher
) and cannot be overridden viaakka.stream.blocking-io-dispatcher
setting, which is the reason however that the dispatcher resolution works in the first place (default-blocking-io-dispatcher
is a valid Config object as demonstrated above)To sum up, the issues that need to be tackled are as follows:
akka.stream.blocking-io-dispatcher
propertyakka.stream.blocking-io-dispatcher
instead ofakka.stream.default-blocking-io-dispatcher
within the akka-stream library.If you approve of the issue and the suggested approach for fixing this, I'll be happy to PR the fix.
The text was updated successfully, but these errors were encountered: