kafka replication_error ai_generated true

org.apache.kafka.common.errors.NotEnoughReplicasException: Messages are rejected since there are fewer in-sync replicas than required

ID: kafka/not-enough-replicas

Also available as: JSON · Markdown
82%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3 active

Root Cause

min.insync.replicas not met. Too many brokers are down or lagging behind the leader.

generic

Workarounds

  1. 92% success Bring the down brokers back online to restore ISR
    sudo systemctl start kafka  # on each down broker; check: kafka-topics.sh --describe --topic my_topic

    Sources: https://kafka.apache.org/documentation/#brokerconfigs

  2. 88% success Verify ISR membership and wait for replicas to catch up
    kafka-topics.sh --describe --topic my_topic --bootstrap-server localhost:9092  # check Isr column
  3. 82% success Set appropriate min.insync.replicas for your replication factor
    For replication-factor=3, set min.insync.replicas=2. Allows 1 broker failure while maintaining durability.

Dead Ends

Common approaches that don't work:

  1. Lower min.insync.replicas to 1 85% fail

    min.insync.replicas=1 with acks=all provides no durability guarantee. A single broker failure can lose acknowledged writes.

  2. Switch producer to acks=0 or acks=1 to bypass ISR check 88% fail

    Bypasses the safety net. Messages are acknowledged before replication, risking data loss on broker failure.