- Wait for an ISR to come back online. This is the default behavior, and this makes you run the risk of the topic becoming unavailable.
- Enable
unclean.leader.election.enable=true
and start producing to non-ISR partitions. We are going to lose all messages that were written to the old leader while that replica was out of sync and also cause some inconsistencies in consumers.
Trade-off
If we allow out-of-sync replicas to become leaders, we will have data loss and data inconsistencies. If we don’t allow them to become leaders, we face lower availability as we must wait for the original leader to become available before the partition is back online. Overall this is a very dangerous setting and its implication must be understood fully before enabling it. For beginners, it is advisable to leave it to its default value of false. However, this configuration can be enabled for some use cases including - metrics collection, log collection, and other cases where data loss is somewhat acceptable, at the trade-off of availability.Should you enable unclean leader election?
This in-depth blog can help you answer this question: https://www.datadoghq.com/blog/kafka-at-datadog/#unclean-leader-elections-to-enable-or-not-to-enableSetting “unclean.leader.election.enable=true” for a topic
Using thekafka-configs
command it is possible: