IBM Support

KAFKA_50 - NotLeaderForPartitionException: This server is not the leader for that topic-partition

Troubleshooting


Problem

The NotLeaderForPartitionException is an exception in Apache Kafka that indicates that the Kafka broker handling a particular request is not the leader for the specified topic-partition.

Each topic partition is stored by one or multiple brokers. One broker is the leader and the remaining brokers are called followers. A producer needs to send new messages to the leader broker for that topic partition data replication follows internally from there. If a producer client does not connect to the correct broker, i.e. to a follower instead of the leader (or to a broker that is not even a follower any longer), then this broker will reject the send request and throws the error.

Symptom

Kafka producer pipeline will fail to send messages to the Kafka topic, resulting in the NotLeaderForPartitionException error, and the SDC logs will contain the error message: "NotLeaderForPartitionException: This server is not the leader for that topic-partition."

Resolving The Problem

Review the health of the Kafka topic:

  • Review the topic has all replication factors and leaders to all partitions.

    • bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic <topic_name>

  • Try to write few messages to the same topic from outside of SDC with kafka-console-producer:

    • bin/kafka-console-producer.sh --broker-list localhost:9092 --topic <topic_name>

If network side of things looks good then another possibility is that records are coming in at a faster rate into the queue before the client can send those to Kafka. There are few knobs you can turn to address this on Kafka side. You can increase the batch.size, and if you do that you'll need to increase the buffer.memory as well. We would suggest trying increasing request.timeout.ms first and before making any changes, please check with your Kafka vendor to fully understand the impact of these changes. 

  • Also, you could try setting up the retries and retry.backoff.ms in producer configurations. Both of these properties, you can configure in the Kafka Producer destination --> Kafka tab --> Kafka Configuration.

Kafka documentation

Document Location

Worldwide


[{"Line of Business":{"code":"LOB76","label":"Data Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSM7CU","label":"IBM StreamSets Data Collector"},"ARM Category":[{"code":"","label":""}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Document Information

More support for:
IBM StreamSets Data Collector

Software version:
All Version(s)

Document number:
7186109

Modified date:
15 March 2025

UID

ibm17186109