conduktor.io ↗

Kafka Exception TaskMigratedException

org.apache.kafka.streams.errors.TaskMigratedException
Non-retriable Streams

Indicates that all tasks belongs to the thread have migrated to another thread. This exception can be thrown when the thread gets fenced (either by the consumer coordinator or by the transaction coordinator), which means it is no longer part of the group but a "zombie" already

Common Causes

Solutions

Example Stack Trace

org.apache.kafka.streams.errors.TaskMigratedException: Producer got fenced trying to commit a transaction [stream-thread [my-app-StreamThread-1]]; it means all tasks belonging to this thread should be migrated. at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.recordSendError(RecordCollectorImpl.java:322) at org.apache.kafka.streams.processor.internals.StreamsProducer.commitTransaction(StreamsProducer.java:307) at org.apache.kafka.streams.processor.internals.TaskManager.commitOffsetsOrTransaction(TaskManager.java:1314) at org.apache.kafka.streams.processor.internals.TaskExecutor.commitOffsetsOrTransaction(TaskExecutor.java:171) at org.apache.kafka.streams.processor.internals.StreamThread.runOnceWithProcessingThreads(StreamThread.java:917) at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:711) at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:671) Caused by: org.apache.kafka.common.errors.InvalidProducerEpochException: Producer attempted to produce with an old epoch.

Diagnostic Commands

kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group <application.id> # check for frequent generation/owner churn and lag grep -E 'TaskMigrated|being fenced|got migrated|InvalidProducerEpoch|ProducerFenced' streams.log # confirm fencing vs. timeout vs. loop kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --all --describe | grep transaction.max.timeout.ms # ceiling for producer transaction.timeout.ms

Related

Related Streams exceptions: BrokerNotFoundException · InternalTopicsAlreadySetupException · InvalidStateStoreException · InvalidStateStorePartitionException · LockException · MisconfiguredInternalTopicException · MissingInternalTopicsException · MissingSourceTopicException

Hitting TaskMigratedException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.