Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

Kafka Troubleshooting

Diagnostic procedures and solutions for common Apache Kafka issues.


Kafka troubleshooting workflow from symptoms to documentationKafka troubleshooting workflow from symptoms to documentationError messages, metrics, behaviorIdentify SymptomsLogs, metrics, configsRecent changesAffected scopeGather InformationBroker, producer, consumerNetwork, disk, memoryIsolate ComponentAnalyze Root CauseApply FixVerify ResolutionDocument
CategoryInformation to Collect
ErrorsException messages, error codes
MetricsRelevant JMX metrics, lag, throughput
LogsBroker logs, client logs
ConfigurationBroker, producer, consumer configs
Recent changesDeployments, config changes, scaling
ScopeAll topics/partitions or specific ones
TimelineWhen did issue start, pattern

Symptoms:

  • UnderReplicatedPartitions metric > 0
  • kafka-topics.sh --describe --under-replicated-partitions shows partitions

Causes:

CauseInvestigation
Broker downCheck broker status, logs
Slow brokerCheck disk I/O, CPU, network
Network issuesCheck connectivity between brokers
Large messagesCheck replica.fetch.max.bytes
High loadCheck throughput, add capacity

Resolution:

Terminal window
# Check which partitions are under-replicated
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --under-replicated-partitions
# Check broker status
kafka-broker-api-versions.sh --bootstrap-server kafka1:9092
# Check replica lag
kafka-replica-verification.sh --broker-list kafka1:9092,kafka2:9092 \
--topic-white-list ".*"

Symptoms:

  • OfflinePartitionsCount metric > 0
  • Producers fail with NotLeaderForPartitionException

Causes:

CauseResolution
All replicas downRestart brokers with replicas
Unclean leader election disabledEnable unclean.leader.election.enable (data loss risk) or recover broker
Disk failureReplace disk, restore from replica

Resolution:

Terminal window
# Find offline partitions
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --unavailable-partitions
# Check replica status
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --topic <topic>
# Force leader election (if unclean election is acceptable)
kafka-leader-election.sh --bootstrap-server kafka:9092 \
--election-type UNCLEAN \
--topic <topic> --partition <partition>

Symptoms:

  • Consumer lag growing
  • Processing falling behind

Diagnosis:

Terminal window
# Check consumer lag
kafka-consumer-groups.sh --bootstrap-server kafka:9092 \
--describe --group <group>
# Output shows:
# TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG

Causes and Resolutions:

CauseResolution
Slow processingOptimize processing logic, add consumers
Too few consumersAdd consumers (up to partition count)
RebalancingUse cooperative rebalancing, static membership
Large messagesIncrease fetch size, processing capacity
External dependency slowOptimize external calls, add buffering

Symptoms:

  • TimeoutException in producer
  • delivery.timeout.ms exceeded

Causes:

CauseInvestigation
Broker unavailableCheck broker health, connectivity
No leaderCheck partition leadership
ISR too smallCheck ISR, min.insync.replicas
Network issuesCheck network latency, packet loss
Overloaded brokerCheck broker metrics, request queue

Resolution:

Terminal window
# Check broker availability
kafka-broker-api-versions.sh --bootstrap-server kafka:9092
# Check partition leaders
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --topic <topic>
# Check request metrics (JMX)
# kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Produce

Symptoms:

  • Producer fails with NotEnoughReplicasException
  • min.insync.replicas not satisfied

Cause: ISR size < min.insync.replicas

Resolution:

Terminal window
# Check ISR for topic
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --topic <topic>
# Check under-replicated partitions
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --under-replicated-partitions
# Resolution options:
# 1. Fix unhealthy brokers to restore ISR
# 2. Temporarily reduce min.insync.replicas (reduces durability)
kafka-configs.sh --bootstrap-server kafka:9092 \
--entity-type topics --entity-name <topic> \
--alter --add-config min.insync.replicas=1

Symptoms:

  • Frequent rebalances
  • Consumer frequently in REBALANCING state
  • High latency, processing gaps

Causes:

CauseResolution
Processing too slowIncrease max.poll.interval.ms, optimize processing
GC pausesTune JVM GC
Heartbeat issuesEnsure heartbeat.interval.ms < session.timeout.ms / 3
Consumer crashesFix consumer stability
Network instabilityFix network issues

Resolution:

# Consumer configuration
max.poll.interval.ms=600000 # Increase if processing is slow
session.timeout.ms=45000 # Default
heartbeat.interval.ms=3000 # Should be < session.timeout.ms / 3
# Use cooperative rebalancing
partition.assignment.strategy=org.apache.kafka.clients.consumer.CooperativeStickyAssignor
# Use static membership
group.instance.id=consumer-host-1

PatternMeaning
ERRORError requiring attention
WARNWarning, potential issue
Marking partition.*offlinePartition lost leadership
ISR.*shrunkReplica fell out of sync
ISR.*expandedReplica rejoined ISR
NotLeaderForPartitionLeader changed during request
ReplicaFetcherThread.*shutdownReplication stopped
Connection to node.*could not be establishedNetwork connectivity issue
ComponentDefault Location
Broker/var/log/kafka/server.log or $KAFKA_HOME/logs/server.log
Controller/var/log/kafka/controller.log
State change/var/log/kafka/state-change.log
Request log/var/log/kafka/kafka-request.log (if enabled)
Terminal window
# Increase log level dynamically
kafka-configs.sh --bootstrap-server kafka:9092 \
--entity-type broker-loggers \
--entity-name 1 \
--alter \
--add-config kafka.server=DEBUG
# Reset to default
kafka-configs.sh --bootstrap-server kafka:9092 \
--entity-type broker-loggers \
--entity-name 1 \
--alter \
--delete-config kafka.server

Terminal window
# List brokers
kafka-broker-api-versions.sh --bootstrap-server kafka:9092
# Check cluster metadata (KRaft)
kafka-metadata.sh --snapshot /var/kafka/data/__cluster_metadata-0/00000000000000000000.log \
--command "describe"
# Check under-replicated partitions
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --under-replicated-partitions
# Check offline partitions
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --unavailable-partitions
Terminal window
# Describe topic
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --topic <topic>
# Check topic configuration
kafka-configs.sh --bootstrap-server kafka:9092 \
--entity-type topics --entity-name <topic> --describe
# Verify replica assignment
kafka-topics.sh --bootstrap-server kafka:9092 \
--describe --topic <topic>
Terminal window
# List consumer groups
kafka-consumer-groups.sh --bootstrap-server kafka:9092 --list
# Describe consumer group
kafka-consumer-groups.sh --bootstrap-server kafka:9092 \
--describe --group <group>
# Check group state
kafka-consumer-groups.sh --bootstrap-server kafka:9092 \
--describe --group <group> --state
# Check members
kafka-consumer-groups.sh --bootstrap-server kafka:9092 \
--describe --group <group> --members --verbose
Terminal window
# Dump log segment
kafka-dump-log.sh --files /var/kafka-logs/<topic>-<partition>/00000000000000000000.log \
--print-data-log
# Check log segment metadata
kafka-dump-log.sh --files /var/kafka-logs/<topic>-<partition>/00000000000000000000.log \
--deep-iteration
# Verify log integrity
kafka-log-dirs.sh --bootstrap-server kafka:9092 \
--describe --topic-list <topic>

ExceptionCauseResolution
TimeoutExceptionDelivery timeout exceededCheck broker health, network, increase timeout
NotLeaderForPartitionExceptionLeader changedRetry (usually automatic)
NotEnoughReplicasExceptionISR < min.insync.replicasFix broker health
RecordTooLargeExceptionMessage exceeds max sizeIncrease max.request.size or reduce message size
SerializationExceptionSerialization failedFix serializer configuration
AuthorizationExceptionACL denied accessGrant required ACLs
SaslAuthenticationExceptionAuthentication failedCheck credentials
ExceptionCauseResolution
CommitFailedExceptionRebalance during commitHandle in rebalance listener
WakeupExceptionwakeup() calledNormal for graceful shutdown
OffsetOutOfRangeExceptionOffset no longer availableReset offset or handle with auto.offset.reset
DeserializationExceptionDeserialization failedFix deserializer, handle poison pills
GroupAuthorizationExceptionNo access to consumer groupGrant group ACL
TopicAuthorizationExceptionNo access to topicGrant topic ACL
ErrorCauseResolution
OutOfMemoryErrorHeap exhaustedIncrease heap, check for leaks
IOException: No space leftDisk fullAdd storage, adjust retention
Too many open filesFile descriptor limitIncrease ulimit
Connection refusedBroker down or listener misconfiguredCheck broker status, listener config

Investigation:

Terminal window
# Check request latency (JMX)
# kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Produce
# kafka.network:type=RequestMetrics,name=TotalTimeMs,request=FetchConsumer
# Check request queue
# kafka.network:type=RequestChannel,name=RequestQueueSize

Common causes:

CauseResolution
Slow diskUse SSDs, check I/O wait
High CPUAdd capacity, optimize
Network congestionCheck bandwidth, optimize
GC pausesTune JVM GC settings
Large batchesReduce batch size

Investigation:

  • Check producer batching (batch.size, linger.ms)
  • Check compression settings
  • Check consumer fetch settings
  • Check broker I/O capacity

Common causes:

CauseResolution
Small batchesIncrease batch.size, linger.ms
No compressionEnable compression
Small fetchIncrease fetch.min.bytes
Disk I/O bottleneckAdd disks, use faster storage
Network bottleneckAdd bandwidth

When seeking help, include:

  1. Kafka version
  2. Error messages (full stack trace)
  3. Relevant configuration
  4. Metrics (throughput, latency, lag)
  5. Cluster size (brokers, partitions)
  6. Recent changes
  7. Steps to reproduce