alpakka icon indicating copy to clipboard operation
alpakka copied to clipboard

Error shutting down JMS consumer with materialized KillSwitch

Open dwickern opened this issue 3 years ago • 0 comments

Versions used

Akka version: 2.6.17 Alpakka version: 3.0.4

Relevant logs

I've seen this error occasionally in logs. It seems to happen during shutdown.

java.lang.IllegalStateException: not yet initialized: only setHandler is allowed in GraphStageLogic constructor. To access materializer use Source/Flow/Sink.fromMaterializer factory
	at akka.stream.stage.GraphStageLogic.interpreter(GraphStage.scala:379)
	at akka.stream.stage.GraphStageLogic.materializer(GraphStage.scala:389)
	at akka.stream.stage.StageLogging.log(StageLogging.scala:31)
	at akka.stream.stage.StageLogging.log$(StageLogging.scala:28)
	at akka.stream.alpakka.jms.impl.SourceStageLogic.log(SourceStageLogic.scala:40)
	at akka.stream.alpakka.jms.impl.JmsConnector.updateStateWith(JmsConnector.scala:110)
	at akka.stream.alpakka.jms.impl.JmsConnector.updateState(JmsConnector.scala:101)
	at akka.stream.alpakka.jms.impl.JmsConnector.updateState$(JmsConnector.scala:95)
	at akka.stream.alpakka.jms.impl.SourceStageLogic.updateState(SourceStageLogic.scala:40)
	at akka.stream.alpakka.jms.impl.SourceStageLogic.akka$stream$alpakka$jms$impl$SourceStageLogic$$stopSessions(SourceStageLogic.scala:112)
	at akka.stream.alpakka.jms.impl.SourceStageLogic$$anon$2.shutdown(SourceStageLogic.scala:139)
	at akka.stream.alpakka.jms.scaladsl.JmsConsumer$$anon$1.shutdown(JmsConsumer.scala:115)

The JmsConsumer materializes a KillSwitch (JmsConsumerControl). The KillSwitch shutdown/abort methods call directly into the GraphStage without any async callback. We ultimately reference StageLogging.log which is not supported:

Make sure to only access log from GraphStage callbacks (such as pull, push or the async-callback).

I haven't been able to replicate it in a test.

dwickern avatar Feb 03 '22 01:02 dwickern