What is FetchSnapshot?
KRaft follower controllers or newly joining brokers download a point-in-time metadata snapshot when they've fallen too far behind to catch up via the log. After a long outage or when joining a mature cluster, a broker fetches the snapshot first, then applies incremental log entries.
Wire Diagram
Response Header v1 · flexible
message_size
int32 · 4B
correlation_id
int32 · 4B
tagged
var
FetchSnapshotResponse v1
ThrottleTimeMs
int32 · 4B
ErrorCode
int16 · 2B
tagged
var
Name
string (compact)
tagged
var
Index
int32 · 4B
ErrorCode
int16 · 2B
Size
int64 · 8B
Position
int64 · 8B
UnalignedRecords
records (compact)
tagged
var
EndOffset
int64 · 8B
Epoch
int32 · 4B
tagged
var
Known optional payloads inside tagged buffer
tag 0: CurrentLeader
LeaderIdAndEpoch
Known optional payloads inside tagged buffer
tag 0: NodeEndpoints
[]NodeEndpoint
Schema & Example
Schema { "ThrottleTimeMs": int32, "ErrorCode": int16, "Topics": [{ "Name": string, "Partitions": [{ "Index": int32, "ErrorCode": int16, "SnapshotId": { "EndOffset": int64, "Epoch": int32 }, "CurrentLeader": { "LeaderId": int32, "LeaderEpoch": int32 }, "Size": int64, "Position": int64, "UnalignedRecords": records }] }], "NodeEndpoints": [{ "NodeId": int32, "Host": string, "Port": uint16 }] }
Illustrative values (not encoded bytes) { "ThrottleTimeMs": 0, "ErrorCode": 0, "Topics": [{ "Name": "orders", "Partitions": [{ "Index": 3, "ErrorCode": 0, "SnapshotId": { "EndOffset": 150382, "Epoch": 17 }, "CurrentLeader": { "LeaderId": 1, "LeaderEpoch": 17 }, "Size": 1048576, "Position": 0, "UnalignedRecords": "<binary>" }] }], "NodeEndpoints": [{ "NodeId": 1, "Host": "broker-1.kafka.local", "Port": 9092 }] }