Suppose topic with a partition P0.
- Producer PR1 publishes a message to P0 with required acks = 2 (two peers from the replicas set, aside from leader, needs to ack. it before the update is considered committed). Producer PR1 is waiting for ack from the leader. That message’s LSN is going to be 100.
- Producer PR2 publishes a message to P0 with required acks = 1(one peer from the replicas set, aside from the leader, needs to ack. it before the update is considered committed). Producer PR2 is waiting for ack from the leader. That message’s LSN is going to be 101
- One Peer asks to consume from x(< 100) and then immediately asks to consume from 102. Other peers in the replicas set are busy and haven’t gotten to consume any updates yet(but not too busy as to be expelled from the ISR).
What happens now? Is PR2 getting acknowledged (because one peer consumed > 101 and acks == 1 and PR's message LSN = 101) ? Or, will Kafka wait for all messages before it to be aknowledgd (e.g the message from PR1 with LSN 100) before acknowledging the message from PR2 with LSN 101?` That is to say, will it respond to PR2 with an acknowledgement before PR1 is provided an acknowledgement, considering that PR1's message LSN < PR2's message LSN?
Nice scenario :)
Since acks=1 means "ack only from leader" and acks=2 is unsupported :)
I am translating the scene to: acks=all with "min.isr=3" in first case (PR1) (leader + 2 replica) and "min.isr=2" in second case (PR2).
Also, replicas consume in order, always. Replicas can't skip from 100 to 102 when fetching events.
Basically, the high watermark advances based on "last offset replicated by the entire ISR". And it doesn't depend on acks.
Lets assume that one follower consumed all the way to 102 (because it can't consume 102 without consuming 101 and 100), and the others haven't consumed anything yet.
Fast forward 10 seconds.
If the remaining replicas still didn't consume the updates, they will be removed from ISR and HWM will move to 102. And then:
If the remaining replicas managed to catch up, then PR1 will finally get its ack and consumers will be able to see 100, 101 and 102.
The point of shrinking the ISR is unblocking consumers.