DeleteRecords
This page encodes the smallest legal instance of the request and the response: numeric fields are zero, strings and byte arrays are empty, every array carries exactly one sample element, and any records field holds one empty 61-byte RecordBatch v2. Version 2 is a flexible version, so every struct is terminated by a uvarint tagged-field count and strings and arrays carry compact length-plus-one prefixes. Sizes below include the leading int32 size prefix.
- API key
- 21
- Encoded at
- v2
- Flexible versions
- 2+
- Headers
- req v2, resp v1
- Request versions
- 0-2
- Response versions
- 0-2
- Request size
- 37 bytes
- Response size
- 33 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields
Request
DeleteRecordsRequest v2, request header v2, 37 bytes on the wire
byte layout (37 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
object tree
DeleteRecordsRequest message v2 [0x0000, 37B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 33 [0x0000, 4B] number of bytes that follow, patched after encoding +-- RequestHeader v2 [0x0004, 11B] common request header | +-- request_api_key int16 = 21 (DeleteRecords) [0x0004, 2B] numeric id of the API being invoked | +-- request_api_version int16 = 2 [0x0006, 2B] version of the API being invoked | +-- correlation_id int32 = 0 [0x0008, 4B] echoed back by the broker in the response | +-- client_id nullable_string = "" (int16 len=0) [0x000c, 2B] always a non-flexible int16-prefixed string | +-- tagged_fields uvarint = 0 [0x000e, 1B] number of tagged fields in the header +-- DeleteRecordsRequest struct [0x000f, 22B] message body, version 2 +-- Topics []DeleteRecordsTopic = 1 element [0x000f, 17B] Each topic that we want to delete records from. | +-- length uvarint = 2 (compact, n+1) [0x000f, 1B] one sample element follows | +-- DeleteRecordsTopic[0] DeleteRecordsTopic = struct [0x0010, 16B] | +-- Name string = "" (compact, len+1=1) [0x0010, 1B] The topic name. | +-- Partitions []DeleteRecordsPartition = 1 element [0x0011, 14B] Each partition that we want to delete records from. | | +-- length uvarint = 2 (compact, n+1) [0x0011, 1B] one sample element follows | | +-- DeleteRecordsPartition[0] DeleteRecordsPartition = struct [0x0012, 13B] | | +-- PartitionIndex int32 = 0 [0x0012, 4B] The partition index. | | +-- Offset int64 = 0 [0x0016, 8B] The deletion offset. | | +-- tagged_fields uvarint = 0 [0x001e, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x001f, 1B] number of tagged fields in this struct +-- TimeoutMs int32 = 0 [0x0020, 4B] How long to wait for the deletion to complete, in milliseconds. +-- tagged_fields uvarint = 0 [0x0024, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 21, "type": "request", "listeners": ["broker"], "name": "DeleteRecordsRequest", // Version 1 is the same as version 0. // Version 2 is the first flexible version. "validVersions": "0-2", "flexibleVersions": "2+", "fields": [ { "name": "Topics", "type": "[]DeleteRecordsTopic", "versions": "0+", "about": "Each topic that we want to delete records from.", "fields": [ { "name": "Name", "type": "string", "versions": "0+", "entityType": "topicName", "about": "The topic name." }, { "name": "Partitions", "type": "[]DeleteRecordsPartition", "versions": "0+", "about": "Each partition that we want to delete records from.", "fields": [ { "name": "PartitionIndex", "type": "int32", "versions": "0+", "about": "The partition index." }, { "name": "Offset", "type": "int64", "versions": "0+", "about": "The deletion offset." } ]} ]}, { "name": "TimeoutMs", "type": "int32", "versions": "0+", "about": "How long to wait for the deletion to complete, in milliseconds." } ] }
Response
DeleteRecordsResponse v2, response header v1, 33 bytes on the wire
byte layout (33 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
object tree
DeleteRecordsResponse message v2 [0x0000, 33B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 29 [0x0000, 4B] number of bytes that follow, patched after encoding +-- ResponseHeader v1 [0x0004, 5B] common response header | +-- correlation_id int32 = 0 [0x0004, 4B] matches the correlation_id of the request | +-- tagged_fields uvarint = 0 [0x0008, 1B] number of tagged fields in the header +-- DeleteRecordsResponse struct [0x0009, 24B] message body, version 2 +-- ThrottleTimeMs int32 = 0 [0x0009, 4B] The duration in milliseconds for which the request was throttled due to a q... +-- Topics []DeleteRecordsTopicResult = 1 element [0x000d, 19B] Each topic that we wanted to delete records from. | +-- length uvarint = 2 (compact, n+1) [0x000d, 1B] one sample element follows | +-- DeleteRecordsTopicResult[0] DeleteRecordsTopicResult = struct [0x000e, 18B] | +-- Name string = "" (compact, len+1=1) [0x000e, 1B] The topic name. | +-- Partitions []DeleteRecordsPartitionResult = 1 element [0x000f, 16B] Each partition that we wanted to delete records from. | | +-- length uvarint = 2 (compact, n+1) [0x000f, 1B] one sample element follows | | +-- DeleteRecordsPartitionResult[0] DeleteRecordsPartitionResult = struct [0x0010, 15B] | | +-- PartitionIndex int32 = 0 [0x0010, 4B] The partition index. | | +-- LowWatermark int64 = 0 [0x0014, 8B] The partition low water mark. | | +-- ErrorCode int16 = 0 [0x001c, 2B] The deletion error code, or 0 if the deletion succeeded. | | +-- tagged_fields uvarint = 0 [0x001e, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x001f, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x0020, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 21, "type": "response", "name": "DeleteRecordsResponse", // Starting in version 1, on quota violation, brokers send out responses before throttling. // Version 2 is the first flexible version. "validVersions": "0-2", "flexibleVersions": "2+", "fields": [ { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+", "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, { "name": "Topics", "type": "[]DeleteRecordsTopicResult", "versions": "0+", "about": "Each topic that we wanted to delete records from.", "fields": [ { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, "entityType": "topicName", "about": "The topic name." }, { "name": "Partitions", "type": "[]DeleteRecordsPartitionResult", "versions": "0+", "about": "Each partition that we wanted to delete records from.", "fields": [ { "name": "PartitionIndex", "type": "int32", "versions": "0+", "mapKey": true, "about": "The partition index." }, { "name": "LowWatermark", "type": "int64", "versions": "0+", "about": "The partition low water mark." }, { "name": "ErrorCode", "type": "int16", "versions": "0+", "about": "The deletion error code, or 0 if the deletion succeeded." } ]} ]} ] }