Kafka Exception NotEnoughReplicasAfterAppendException
org.apache.kafka.common.errors.NotEnoughReplicasAfterAppendException
Retriable
Broker
Number of insync replicas for the partition is lower than min.insync.replicas This exception is raised when the low ISR size is discovered *after* the message was already appended to the log. Producer retries will cause duplicates.
Common Causes
- Message was written to the leader's log but ISR shrank between the append and the ack phase — another broker left ISR during the window
- High write throughput causing followers to intermittently fall behind ISR threshold during peak load, triggering post-append ISR shrink
- Network instability causing brief follower disconnects that temporarily remove them from ISR after the write already succeeded on the leader
Solutions
- This is retriable: producer will resend; to avoid duplicates, enable idempotent producer ('enable.idempotence=true') which deduplicates retries via sequence numbers
- Investigate why followers are lagging — check replica fetcher thread count (num.replica.fetchers) and network bandwidth between brokers
- For consistent acks=all guarantees, tune 'min.insync.replicas' to be at most replication-factor minus 1 so a single follower hiccup does not block every write
Example Stack Trace
org.apache.kafka.common.errors.NotEnoughReplicasAfterAppendException: Messages are written to the log, but to fewer in-sync replicas than required.Diagnostic Commands
# Check for under-replicated partitions
kafka-topics.sh --describe --bootstrap-server localhost:9092 --under-replicated-partitions
# Check replica offset lag and status
kafka-log-dirs.sh --bootstrap-server localhost:9092 --broker-list <follower-broker-id> --describe | grep offsetLagRelated
Protocol error: NOT_ENOUGH_REPLICAS_AFTER_APPEND (code 20)
Related Broker exceptions: CorruptRecordException · FencedLeaderEpochException · LeaderNotAvailableException · NetworkException · NotEnoughReplicasException · NotLeaderOrFollowerException · TimeoutException · UnknownLeaderEpochException
Hitting
NotEnoughReplicasAfterAppendException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.