Open ilinandrii opened 1 month ago
Here's test log that shows that consumer and sink actually stopped.
9926 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] ERROR akka.actor.RepointableActorRef Error in stage [akka.kafka.internal.CommittingProducerSinkStage@48ae68c8]: failure in serializer
java.lang.RuntimeException: failure in serializer
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:903)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:865)
at akka.kafka.internal.CommittingProducerSinkStageLogic.$anonfun$produce$1(CommittingProducerSinkStage.scala:110)
at scala.collection.immutable.List.foreach(List.scala:431)
at akka.kafka.internal.CommittingProducerSinkStageLogic.akka$kafka$internal$CommittingProducerSinkStageLogic$$produce(CommittingProducerSinkStage.scala:109)
at akka.kafka.internal.CommittingProducerSinkStageLogic$$anon$1.onPush(CommittingProducerSinkStage.scala:223)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:523)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:409)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:606)
at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:485)
at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:581)
at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:749)
at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:764)
at akka.actor.Actor.aroundReceive(Actor.scala:539)
at akka.actor.Actor.aroundReceive$(Actor.scala:537)
at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:671)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:614)
at akka.actor.ActorCell.invoke(ActorCell.scala:583)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)
at akka.dispatch.Mailbox.run(Mailbox.scala:229)
at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
9926 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-17] DEBUG o.a.k.c.consumer.KafkaConsumer [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Pausing partitions [consumer-test-topic-0]
9926 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] DEBUG a.k.i.CommittingProducerSinkStage [cb534] CommittingProducerSink stopped
9926 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] DEBUG a.kafka.internal.KafkaConsumerActor received handled message Poll(akka.kafka.internal.KafkaConsumerActor@132090ca,true) from Actor[akka://ProducerCommitterSinkTest/deadLetters]
9938 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] DEBUG a.k.i.CommittingProducerSinkStage [cb534] Producer closed
9939 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] INFO a.kafka.internal.SingleSourceLogic [1aae0] Completing
9940 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] DEBUG a.kafka.internal.KafkaConsumerActor received handled message StopFromStage(1aae0) from Actor[akka://ProducerCommitterSinkTest/system/StreamSupervisor-0/$$a#-2087746625]
9940 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] DEBUG a.kafka.internal.KafkaConsumerActor [5db21] Received Stop from StageId [1aae0], stopping
9947 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-2] DEBUG a.kafka.internal.KafkaConsumerActor stopping
9949 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-2] DEBUG a.kafka.internal.ConnectionChecker stopped
9950 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-21] DEBUG o.a.k.c.consumer.KafkaConsumer [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Pausing partitions [consumer-test-topic-0]
9950 [kafka-coordinator-heartbeat-thread | producer-committer-sink-test] DEBUG o.a.k.c.c.i.AbstractCoordinator [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Heartbeat thread has closed
9950 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-21] DEBUG o.a.k.c.c.i.ConsumerCoordinator [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Executing onLeavePrepare with generation Generation{generationId=1, memberId='producer-committer-sink-test-5ee99cef-34f4-4fb2-b2d3-3909007cdb94', protocol='range'} and memberId producer-committer-sink-test-5ee99cef-34f4-4fb2-b2d3-3909007cdb94
9950 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-21] INFO o.a.k.c.c.i.ConsumerCoordinator [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Revoke previously assigned partitions consumer-test-topic-0
9951 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-21] INFO o.a.k.c.c.i.AbstractCoordinator [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Member producer-committer-sink-test-5ee99cef-34f4-4fb2-b2d3-3909007cdb94 sending LeaveGroup request to coordinator localhost:50240 (id: 2147483646 rack: null) due to the consumer is being closed
9951 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] DEBUG a.kafka.internal.SingleSourceLogic [1aae0] Revoked partitions: Set(consumer-test-topic-0). All partitions: Set()
9952 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-21] DEBUG o.a.k.c.c.i.AbstractCoordinator [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Resetting generation due to consumer pro-actively leaving the group
9958 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-21] DEBUG o.a.k.c.c.i.AbstractCoordinator [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] LeaveGroup request returned successfully
9959 [ProducerCommitterSinkTest-akka.kafka.default-dispatcher-21] DEBUG o.a.k.c.consumer.KafkaConsumer [Consumer clientId=producer-committer-sink-test, groupId=producer-committer-sink-test] Kafka consumer has been closed
9961 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-3] DEBUG a.kafka.internal.KafkaConsumerActor stopped
9962 [ProducerCommitterSinkTest-akka.actor.default-dispatcher-4] INFO akka.actor.RepointableActorRef Message [akka.kafka.internal.KafkaConsumerActor$Internal$StopFromStage] from Actor[akka://ProducerCommitterSinkTest/system/StreamSupervisor-0/$$a#-2087746625] to Actor[akka://ProducerCommitterSinkTest/system/kafka-consumer-1#860674792] was not delivered. [1] dead letters encountered. If this is not an expected behavior, then [Actor[akka://ProducerCommitterSinkTest/system/kafka-consumer-1#860674792]] may have terminated unexpectedly, This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
The CommittingProducerSinkStage
as seen a large number of improvements since version 2.0.5. Please update to recent versions.
Akka version:
2.5.32
Alpakka version:2.0.5
Scala version:2.12.17
Testcontainers Kafka1.19.0
Expected Behavior
Future[Done]
materialized fromProducer.committableSink
is completed whenCommittingProducerSinkStage
finishes because of a producer exception.Actual Behavior
Future[Done]
materialized fromProducer.committableSink
never completes whenCommittingProducerSinkStage
finishes because of a producer exception.Additional information
In my particular case a producer used within
CommittingProducerSinkStage
failed to register schema, this caused sink and consumer to complete, howeverisShutdown
future on stream'sDrainingControl
built from sink'sFuture[Done]
andConsumer.Control
never completes, therefore shutdown hook I set up based onisShutdown
never fired.Reproducible Test Case
Here's a test. I emulate producer serialization error with mock serializer.
control.isShutdown.futureValue
completes successfullycompletion.futureValue
runs forever, however stream is dead. Hence if I buildDrainingControl
fromcontrol
andcompletion
it'sisShutdown
will also never be completed.Looking into implementation I suppose promise never completes in case of
producer.send
failure.