Kafka - Fault tolerance with two phase commits

Hi, guys. I’m confused with a situation these days. Imagine there is a single-partition topic with two replicas. If a message is produced with acks=-1, and min.insync.replicas=2 is set on brokers. The right time the message arrived ISR size is two, but after log is appended on the leader, the follower went down. What will happened then? I think write failure will be returned to the producer, but will the message on the leader roll back?

Yes. It has to be positively ack’d as written from two brokers due to min.insync=2.

It gets a litlte more complex as to what a “write” is after that ack. Since kafka doesn’t immediately fsync to disk on every message. See "flush.**" and "log.flush.**" configs

Another problem you may hit with RF=2 and min.insync=2 is you have no fault tolerance. either broker goes down and you’ll get exceptions

Thanks for the reply! So there is a 2-phase-commit process while producing messages on the occasion, am I right?

I’m not going to agree or disagree. 2-phase-commit is like shouting fire in a theater

But there can be something someone COULD look at a 2pc. Transactional producer

https://www.confluent.io/blog/transactions-apache-kafka/#:~:text=After%20the%20producer%20initiates%20a,be%20committed%20no%20matter%20what

Hah this is exactly what I’m looking for! Thank you!!