---
title: "Kafka KRaft dynamic quorum: add and remove controllers"
description: "Replace a lost KRaft controller online (KIP-853): a new controller joins as an observer, becomes a voter, the dead one is removed. The majority moves 2, 3, 2."
url: https://monedula.dev/kafka-simulator/scenarios/dynamic-quorum/
---

# Kafka KRaft dynamic quorum: add and remove controllers

Scenario 15.1.5 · Dynamic quorum: replace a lost controller. KRaft · Advanced · about 5 min · Apache Kafka 4.4.

A KRaft voter's machine is lost. A new controller joins as an observer, catches up on the metadata log and is added as a voter (4 voters, majority 3); the dead voter is removed (3 voters, majority 2). Leader elections keep completing throughout.

Run it: https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5

## What you start with

Since Kafka 3.9 (KIP-853) a KRaft quorum can be dynamic: the voter set is stored in the __cluster_metadata log, so controllers are added and removed online with kafka-metadata-quorum add-controller and remove-controller. A new controller first joins as an observer and replicates the log; the leader adds it as a voter only once it has caught up. The majority is always counted over the current voters, floor(voters/2)+1, so it moves with each change.

## Step by step

1. **Three voters, majority 2** (t+0.400s): Three KRaft voters run the __cluster_metadata log: c0 is the active controller, c1 and c2 follow. The quorum is dynamic (kraft.version 1), so the voter set itself is a record in that log. With 3 voters a majority is floor(3/2)+1 = 2. O1 is committed to orders-0 (HW 1). [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=0)
2. **Voter c2's machine fails** (t+1.300s): c2 is killed: its machine is gone and its log stops at offset 1. 2 of 3 voters are still up, which is the majority of 2, so c0 keeps serving. The dead voter still counts toward the quorum size: a voter set never shrinks on its own. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=1)
3. **Elections still complete** (t+2.100s): The partition leader broker-1 died at 1500. The controller is serving with 2 of 3 voters, so the election completes: broker-2 becomes leader of orders-0. Meanwhile c0 appended a second metadata record (offset 2) and c1 replicated it. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=2)
4. **c3 joins as an observer** (t+2.300s): A replacement controller, c3, is formatted with --no-initial-controllers and started. It joins the quorum as an OBSERVER: it fetches __cluster_metadata from the leader but has no vote, so the voters are still c0, c1, c2 and the majority is still 2. c3 starts at offset 0, two records behind the leader. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=3)
5. **Too early: add-controller refused** (t+2.600s): kafka-metadata-quorum add-controller is run for c3 before it has caught up. The leader refuses (REQUEST_TIMED_OUT): it adds a voter only once that replica holds the log up to the leader's end offset. Nothing changed. broker-1 has meanwhile restarted and rejoined the ISR. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=4)
6. **c3 has caught up** (t+3.100s): On the next replication round c3 fetches the records it was missing and reaches offset 2, level with the leader. kafka-metadata-quorum describe --replication now shows it as an Observer with Lag 0. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=5)
7. **c3 is a voter: 4 voters, majority 3** (t+3.400s): add-controller succeeds: c0 commits a VotersRecord that adds c3 (offset 3). The quorum now has 4 voters, so a majority is floor(4/2)+1 = 3. c2 is still dead, so 3 of 4 are up and every live voter is needed: losing one more would freeze the control plane. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=6)
8. **Elections still complete with 4 voters** (t+4.200s): broker-2, the leader, died at 3600. c0 still has its majority of 3 (c0, c1, c3), so the election completes and broker-1 leads orders-0. c1 and c3 replicated the VotersRecord at 4000. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=7)
9. **Remove dead c2: 3 voters, majority 2** (t+4.700s): kafka-metadata-quorum remove-controller retires c2, which is never coming back. c0 commits a VotersRecord without it (offset 4). The voters are c0, c1, c3: 3 of 3 up, majority 2 again, so one voter can fail without stopping the quorum. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=8)
10. **The new voter set elects** (t+5.900s): broker-1 died at 5300. The quorum c0, c1, c3 elects broker-3, the last in-sync replica, as leader of orders-0. The controller kept electing leaders through every step: before the replacement, with 4 voters, and after the removal. Only the majority it needed moved, 2 to 3 and back to 2. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=15.1.5&t=9)

## The takeaway

Replacing a controller is two committed changes, not a config edit and a rolling restart: add the caught-up observer as a voter, then remove the dead one. In between, the quorum had 4 voters and needed 3 of them, one more than before, which is why the dead voter should not be left in the set. The simulator commits each VotersRecord at once and does not model directory ids; real Kafka identifies a voter by node id and directory id, and remove-controller needs both.

## Further reading

- [Apache Kafka documentation](https://kafka.apache.org/44/operations/kraft/)

## Kafka proposals behind this scenario

- [KIP-853 explained: adding and removing KRaft controllers](https://monedula.dev/kafka/kips/kip-853/)
