What is Fetch?
Consumers and follower replicas both issue this continuously for log replication and consumption. When a consumer's fetch stalls with empty responses despite records existing, check isolation.level: read_committed consumers are blocked by open transactions until EndTxn.
Wire Diagram
Response Header · flexible
message_size
int32 · 4B
correlation_id
int32 · 4B
tagged
var
FetchResponse v16
ThrottleTimeMs
int32 · 4B
ErrorCode
int16 · 2B
SessionId
int32 · 4B
tagged
var
TopicId
uuid · 16B
tagged
var
PartitionIndex
int32 · 4B
ErrorCode
int16 · 2B
HighWatermark
int64 · 8B
LastStableOffset
int64 · 8B
LogStartOffset
int64 · 8B
PreferredReadReplica
int32 · 4B
Records?
records (compact)
tagged
var
Epoch
int32 · 4B
EndOffset
int64 · 8B
tagged
var
LeaderId
int32 · 4B
LeaderEpoch
int32 · 4B
tagged
var
EndOffset
int64 · 8B
Epoch
int32 · 4B
tagged
var
ProducerId
int64 · 8B
FirstOffset
int64 · 8B
tagged
var
NodeId
int32 · 4B
Host
string (compact)
Port
int32 · 4B
Rack?
string (compact)
tagged
var
Schema & Example
Schema { "ThrottleTimeMs": int32, "ErrorCode": int16, "SessionId": int32, "Responses": [{ "TopicId": uuid, "Partitions": [{ "PartitionIndex": int32, "ErrorCode": int16, "HighWatermark": int64, "LastStableOffset": int64, "LogStartOffset": int64, "DivergingEpoch": { "Epoch": int32, "EndOffset": int64 }, "CurrentLeader": { "LeaderId": int32, "LeaderEpoch": int32 }, "SnapshotId": { "EndOffset": int64, "Epoch": int32 }, "AbortedTransactions": [{ "ProducerId": int64, "FirstOffset": int64 }]?, "PreferredReadReplica": int32, "Records": records? }] }], "NodeEndpoints": [{ "NodeId": int32, "Host": string, "Port": int32, "Rack": string? }] }
Example { "ThrottleTimeMs": 0, "ErrorCode": 0, "SessionId": 1847, "Responses": [{ "TopicId": "550e8400-e29b-41d4-a716-446655440000", "Partitions": [{ "PartitionIndex": 3, "ErrorCode": 0, "HighWatermark": 284729, "LastStableOffset": 284729, "LogStartOffset": 284729, "DivergingEpoch": { "Epoch": 17, "EndOffset": 150382 }, "CurrentLeader": { "LeaderId": 1, "LeaderEpoch": 17 }, "SnapshotId": { "EndOffset": 150382, "Epoch": 17 }, "AbortedTransactions": [{ "ProducerId": 0, "FirstOffset": 150382 }]?, "PreferredReadReplica": 2, "Records": "<binary>" }] }], "NodeEndpoints": [{ "NodeId": 1, "Host": "broker-1.kafka.local", "Port": 9092, "Rack": "us-east-1a" }] }