Adding replicas with `kafka-reassign-partitions.sh` while retaining partition leaders

When using kafka-reassign-partitions.sh to add more replicas, without removing any of the existing replicas, will it change leadership of those partitions or is it guaranteed to leave partition leaders as they are?

Leadership is never guaranteed. However there is a preferred leader, the first broker id in the replica set

Right, but if I generate a plan that’s identical to the current assignment, but with new replicas appended to the end of the array, will it still perform a leadership election?

I’m trying to avoid leadership changes during scale up, because changes in leadership crash our app due to a race condition in the broker.

It might. No real way to stop it

Chances are it won’t. But can’t force the controller to not

Yeah, I realise there are no guarantees, but I can’t see a reason that it would change leadership, just wondering if I’d missed anything?

Nope. There’s no way to force it. Best you can do is hope

changes in leadership crash our app due to a race condition in the broker.
What version broker and streams are you on?

Got it. We will try to replicate and look out for this in our soaks. Thanks!

It only seems to be a problem with a large number of partitions. We don’t see it on all leadership changes, but roughly 1 in every 1000 partition leadership changes will trigger a ProducerFencedException