...
At the point a new reassignment is created we compute the value
top = len(original_assignment)
and store this in ZK. We also checktop >= min.insync.replicas
, logging a warning and ignore the reassignment if the check fails.- Then, initially, and each time the reassignment changes, (i.e. in
KafkaController.onPartitionReassignment()
):- Define a sorted list of out-of-sync replicas:
osr = sort( assigned -- isr, by_lag_ascending)
- Create a list of current replicas
existing = List(leader) ++ isr ++ osr
Remove duplicates from
existing
(keeping the first occurrence in the list)- Then, the set of replicas which can be dropped is:
drop = assigned --
existing[0:top-1]
- Define a sorted list of out-of-sync replicas:
...
- Since
top > 0
it is impossible to drop the leader, and thus it's impossible that a leader election will be needed at this point. By the assumption
top >= min.insync.replicas
it's impossible to shrink the ISR to a point where producers are blocked, assuming the ISR was already sufficifient.- If the controller knew how far behind the ISR each of the OSR replicas was, OSR could be sorted, which would result in dropping the furthest-behind replicas. But the controller doesn't know this.
In order to actually drop those replicas:
...