Kafka Error INVALID_REPLICA_ASSIGNMENT
Error code 39 · Non-retriable Admin
Replica assignment is invalid.
Common Causes
- Manual replica assignment specifies broker IDs that do not exist or are offline in the current cluster
- Assignment array has duplicate broker IDs in the same partition replica list
- Number of partitions implied by the assignment array does not match --partitions argument, or partition indices are non-contiguous
Solutions
- List all active broker IDs first (kafka-broker-api-versions.sh) and construct the assignment using only those IDs
- Ensure each partition's replica list has no duplicate broker IDs and the count matches the desired replication factor
- Use kafka-reassign-partitions.sh --generate to produce a valid assignment JSON rather than constructing it manually
Diagnostic Commands
# Count online brokers in the cluster
kafka-broker-api-versions.sh --bootstrap-server localhost:9092 2>&1 | grep 'id:' | awk '{print $2}' | sort -n
# Describe topic replicas and ISR status
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic <topic> 2>&1 | grep -E 'Partition|Leader|Replicas'
Debugging Kafka errors? Conduktor Console gives you real-time visibility into your cluster. Explore all errors in the Error Decoder.