conduktor.io ↗

Kafka FetchSnapshot Request Wire Format v1 — Binary Protocol Layout

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.

Related Errors

POSITION_OUT_OF_RANGE · SNAPSHOT_NOT_FOUND

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
FetchSnapshotRequest v1
ClusterId? string (compact)
ReplicaId int32 · 4B
MaxBytes int32 · 4B
Topics array
tagged var
Name string (compact)
Partitions array
tagged var
Partition int32 · 4B
CurrentLeaderEpoch int32 · 4B
SnapshotId struct
Position int64 · 8B
ReplicaDirectoryId uuid · 16B
tagged var
EndOffset int64 · 8B
Epoch int32 · 4B
tagged var

Schema & Example

Schema
{
  "ClusterId": string?,
  "ReplicaId": int32,
  "MaxBytes": int32,
  "Topics": [{
      "Name": string,
      "Partitions": [{
          "Partition": int32,
          "CurrentLeaderEpoch": int32,
          "SnapshotId": {
            "EndOffset": int64,
            "Epoch": int32
          },
          "Position": int64,
          "ReplicaDirectoryId": uuid
      }]
  }]
}
Example
{
  "ClusterId": "dQw4w9WgXcQ",
  "ReplicaId": -1,
  "MaxBytes": 65536,
  "Topics": [{
      "Name": "orders",
      "Partitions": [{
          "Partition": 0,
          "CurrentLeaderEpoch": 12,
          "SnapshotId": {
            "EndOffset": 150382,
            "Epoch": 17
          },
          "Position": 0,
          "ReplicaDirectoryId": "550e8400-e29b-41d4-a716-446655440000"
      }]
  }]
}