Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 120 additions & 4 deletions docs/implementation/message-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,131 @@ Compaction may also modify the baseTimestamp if the record batch contains record

### Control Batches

A control batch contains a single record called the control record. Control records should not be passed on to applications. Instead, they are used by consumers to filter out aborted transactional messages.
A control batch contains a single record called the control record. Control records should not be returned to applications. Instead, they are used by consumers to filter out aborted transactional messages, and by the KRaft implementation for its protocol metadata.

The key of a control record conforms to the following schema:

The key of a control record conforms to the following schema:

version: int16 (current version is 0)
type: int16 (0 indicates an abort marker, 1 indicates a commit)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be clearer saying that the control record types are in the table below. The table contradicts this line because it mentions the 7 control record types, not just 2.


The schema for the value of a control record is dependent on the type. The value is opaque to clients.
The following control record types are currently defined:

<table>
<tr>
<th>

Type
</th>
<th>

Name
</th>
<th>

Description
</th>
</tr>
<tr>
<td>

0
</td>
<td>

ABORT
</td>
<td>

Marks a transaction as aborted.
</td>
</tr>
<tr>
<td>

1
</td>
<td>

COMMIT
</td>
<td>

Marks a transaction as committed.
</td>
</tr>
<tr>
<td>

2
</td>
<td>

LEADER_CHANGE
</td>
<td>

Records a KRaft leader change.
</td>
</tr>
<tr>
<td>

3
</td>
<td>

SNAPSHOT_HEADER
</td>
<td>

Marks the beginning of a KRaft snapshot.
</td>
</tr>
<tr>
<td>

4
</td>
<td>

SNAPSHOT_FOOTER
</td>
<td>

Marks the end of a KRaft snapshot.
</td>
</tr>
<tr>
<td>

5
</td>
<td>

KRAFT_VERSION
</td>
<td>

Records the finalized kraft.version supported by all replicas.
</td>
</tr>
<tr>
<td>

6
</td>
<td>

KRAFT_VOTERS
</td>
<td>

Records the set of voters at a specific offset.
</td>
</tr>
</table>

Types 0 and 1 are used as end-of-transaction markers for the transactional messaging protocol. Types 2 through 6 are used internally by the KRaft consensus protocol. The schema of the value in the control record is dependent on the type. The value is opaque to clients.

## Record

Expand Down
Loading