What is ElectLeaders?
Forces preferred leader elections or triggers unclean elections via kafka-leader-election.sh. Preferred election safely moves leadership back to the first replica; unclean election (type=1) risks data loss by electing an out-of-sync replica when no in-sync replica is available.
Wire Diagram
Request Header · flexible
message_size
int32 · 4B
api_key
int16 · 2B
api_version
int16 · 2B
correlation_id
int32 · 4B
client_id
string (compact)
tagged
var
ElectLeadersRequest v2
ElectionType
int8 · 1B
TimeoutMs
int32 · 4B
tagged
var
Topic
string (compact)
Partitions
[]int32
tagged
var
Schema & Example
Schema { "ElectionType": int8, "TopicPartitions": [{ "Topic": string, "Partitions": [int32] }]?, "TimeoutMs": int32 }
Example { "ElectionType": 1, "TopicPartitions": [{ "Topic": "orders", "Partitions": [1, 2, 3] }]?, "TimeoutMs": 30000 }