If Apache Iggy is useful to you, give it a star on GitHubStar apache/iggy
Skip to Content
Apache Iggy
Binary Protocol
These docs describe the upcoming release. They follow the master branches of apache/iggy and apache/iggy-connectors. For the last release, read the 0.10 release docs, or select a version at the top of the sidebar.

Server-to-server

Replica links, consensus commands, history fences and the header layouts used by Apache Iggy, including the replica wire revision 5 handshake.

Replicas use dedicated TCP listeners and 256-byte headers. Client listeners reject replica control commands. Replicas on different server versions link only when the release compatibility table lists them, and it lists none yet. Run the same server build and replica_connections_per_peer on every node.

Transport

The roster supplies each node's tcp_replica port and literal IP address. Lower replica IDs dial higher IDs. Each pair can use several links, which distribute traffic across shards. The default frame limit is 64 MiB through message_bus.max_message_size.

Each connection starts with an eight-byte placement preamble before TLS and the replica handshake:

[magic: IGRL, 4 bytes][version: u8][dialer_replica: u8][link_index: u16]

Version 1 opens a replica link. Version 2 opens a join link, with the dialer and link bytes zero, and a build without join links refuses it. The preamble selects a shard and is not authentication. ReplicaHello repeats the peer and link identity and supplies the link count. The acceptor rejects a mismatch. With authentication enabled, placement fields participate in the handshake MAC. Shard counts can differ between nodes.

Handshake

ReplicaHello, ReplicaChallenge and ReplicaFinish establish the connection. [cluster.auth] enables the shared-key BLAKE3 MAC. [cluster.tls] encrypts traffic with TLS 1.3 and ALPN iggy-replica. TLS requires replica authentication. See Cluster security for configuration and key rotation.

Build identity and release compatibility

ReplicaHello, an accepted ReplicaChallenge and ReplicaFinish carry a 32-byte build identity at zero-based header bytes 193 to 224 inclusive. It is a BLAKE3 hash of the client protocol version, the replica wire revision, the server release and the storage format marker. A node also computes the identity of every release that its row of the release compatibility table lists, with its own protocol version, wire revision and storage marker.

A ReplicaHello carries the identity of the dialer in its header. Before replica wire revision 5, the dialer sends a header-only ReplicaHello. Starting with revision 5, the body carries one 32-byte identity for each release the dialer lists, up to 128 identities. The acceptor closes an oversized frame before reading its body and rejects a partial identity with IncompatibleBuild.

The acceptor selects the identity of the link. It selects the identity of the dialer when that is its own or one it lists. It selects its own when the hello body contains it. Otherwise it answers with a ReplicaChallenge of status IncompatibleBuild (6).

An accepted ReplicaChallenge and ReplicaFinish carry the selected identity and have no body. When authentication is enabled, both MACs cover that identity and the BLAKE3 hash of the complete ReplicaHello frame. The dialer closes the link when the challenge carries an identity that is neither its own nor one it lists.

A node can admit a later release that explicitly lists it. The table is compiled into the server and ships empty. See Release compatibility.

A node admitted outside the static roster binds its disk to its admission over a join link to a seed. Shard 0 of the seed serves the link itself, answers one bind request and closes it, so it never becomes a replica link. A seed serves at most four join links at a time and drops the others. With [cluster.tls] the link runs inside TLS after the preamble, and the joiner checks that the seed's certificate names the seed's IP address. Integers are little-endian.

The joiner's ReplicaHello carries replica byte 255 and, as on a replica link, its nonce, build identity and heartbeat timings. Its body starts with a 32-byte JoinHello block, followed by the build identities the joiner lists:

[operation_id: u64][storage_incarnation: u128][reserved: 8 bytes, zero]

The seed answers a body shorter than the block, or one with a nonzero reserved byte, with status IncompatibleBuild (6). A seed without replica authentication answers with status JoinRequiresAuth (10), and a hello without a nonce is closed without an answer. Both handshake MACs bind the link placement as zero, the dialer id 255 and, after the channel binding, a mode byte 1 followed by operation_id and storage_incarnation.

On subsequent replica links involving an admitted node, each MAC includes mode byte 2 followed by the dialer and acceptor storage incarnations, in that order, as little-endian 128-bit integers. A static endpoint contributes zero. The acceptor replies with JoinRequiresAuth (10) if replica authentication is disabled.

The joiner sends its admission secret only after the seed's MAC verified, and the seed reads it only after the joiner's ReplicaFinish verified. Then the joiner sends one bind request and the seed one answer, each in a frame:

[length: u32][body: length bytes][mac: 32 bytes]

The frame MAC is a keyed BLAKE3 hash under the replica authentication key of the tag apache-iggy replica-join frame v1, the handshake transcript, a direction byte (1 from the joiner, 2 from the seed), the body length as a u64 and the body. The bind request body has 52 bytes:

[secret: 32 bytes][slot: u8][endpoint: 19 bytes]

An endpoint is [family: u8][address: 16 bytes][port: u16] with family 4 or 6, and an IPv4 address fills the first four address bytes and leaves the rest zero. slot is the joiner's --replica-id. The operation and the storage incarnation come from the JoinHello block.

The answer body starts with a kind byte. Kind 0 means the binding is not committed yet, has no further bytes, and the joiner asks again later. Kind 2 is a refusal followed by a reason byte: 1 unknown operation, 2 secret mismatch, 3 operation bound to another disk, 4 expired, 5 cancelled, 6 the seed cannot decide admissions now, 7 endpoint mismatch, and 8 slot mismatch followed by the slot the operation reserved. Kind 1 accepts the binding:

[slot: u8][endpoint: 19 bytes][directory_revision: u64][member_count: u8][members]

Each member is [slot: u8][storage_incarnation: u128][endpoint: 19 bytes]. An answer lists at most 32 members, each slot once and below 32, so it is at most 1182 bytes.

Command discriminants

The command byte is at offset 60. This is the complete registry, including client commands:

ValueCommand
0Reserved
1Ping
2Pong
3PingClient
4PongClient
5Request
6Prepare
7PrepareOk
8Reply
9Commit
10StartViewChange
11DoViewChange
12StartView
13Eviction
14ReplicaHello
15ReplicaChallenge
16ReplicaFinish
17RequestStartView
18RequestPrepares
19RepairPrepare
20RepairDone
21RangeEvicted
22RequestStateTransfer
23StateTransferTarget
24RequestStateChunk
25StateChunk
26ForwardRegister
27ForwardRegisterResult
28ForwardLogout
29ForwardLogoutResult
30ConsumerSessionHeartbeat
31SessionRetirementProgress
32ForwardCompletion
33PrimaryRebalance
34SegmentDelete
35CommitReply
36PrepareProgress

Reserved and unused ping/pong forms do not establish a session. Reply and Eviction are client-bound and rejected on replica ingress. A replica Request uses the internal routed-request header, including its group and metadata watermark.

Consensus and history

The metadata group orders resources, users and sessions. Every partition has its own group for messages and offsets. The group field identifies the target. The metadata group uses 1 << 63, while partition groups use packed stream, topic and partition IDs.

Prepare carries an operation and its body. PrepareOk acknowledges the required replication and persistence work. Commit broadcasts the commit point and a liveness token. CommitReply proves that peers still respond. A primary that cannot reach a quorum relinquishes leadership.

StartViewChange, DoViewChange and StartView establish a new view. The DoViewChange flags byte defines four bits, and a receiver drops a vote with any other bit set.

Bit 0 marks a log that may lack writes its sender acknowledged before a restart, so a replica without proven history cannot vote as an authoritative empty log. Such a vote adds the bodies it can serve to the merge and never counts as a nack. Bit 1 marks a vote built from the sender's own journal. A replica barred from electing answers with a vote that carries no log and leaves bit 1 clear. For persisted partitions, the merge limits how many placeholders can hide an acknowledged operation.

Bit 2 marks a copy with no initialization record on a disk known to predate the partition. Bit 3 marks a missing copy whose disk may have replaced an earlier one. A sender sets at most one of these bits.

Each unmarked placeholder can hide an acknowledger. Among marked placeholders the merge counts all bit 3 senders, or one bit 2 sender if no bit 3 sender reported. The total must stay below the replication quorum when the merge needs every voter.

incarnation carries the sender's per-boot incarnation, and a receiver counts a vote only from the incarnation it registered for the sender. RequestStartView probes for the current view after recovery.

Partition incarnation fields fence an old partition history. Consumer ownership generations separately fence old group members. PrimaryRebalance moves a partition primary under metadata coordination. PrepareProgress lets a slow replica report received, held and committed progress while it catches up.

Frame integrity

Replica control frames use an XxHash3-64 frame seal widened to u128. Prepare and RepairPrepare use a prepare identity hash, and a parent identity links the history. Metadata prepare bodies have their own seal. Message batches carry their batch checksums. These unkeyed hashes detect corruption, not a malicious peer. Authentication and TLS provide separate protection.

Header layouts

Every header begins with the common 128-byte frame prefix shown in Framing. The tables below list the remaining fields in wire order. Multi-byte integers are little-endian. Reserved fields are not extension space for clients. RepairPrepare uses the PrepareHeader layout with its repair command value.

PrepareHeader

OffsetBytesField
12816client
14416parent
16016request_checksum
1768op
1848commit
1928timestamp
2008request
2081operation
2097operation_padding
2168group
2244user_id
2284retry_capacity
2328partition_incarnation
2408reserved
2488session

PrepareOkHeader

OffsetBytesField
12816parent
14416prepare_checksum
1608op
1688commit
1768timestamp
1848request
1921operation
1937operation_padding
2008group
20848reserved

CommitHeader

OffsetBytesField
12816commit_checksum
1448timestamp_monotonic
1528commit
1608checkpoint_op
1688group
1768partition_incarnation
18472reserved

CommitReplyHeader

OffsetBytesField
1288timestamp_monotonic
1368group
1448partition_incarnation
152104reserved

Each batched CommitReplyEntry is 32 bytes. Offsets are relative to the start of the entry.

OffsetBytesField
08Group
88Partition incarnation
168Monotonic heartbeat timestamp
244View
281Sender's member index
291Flags
302Reserved, zero

Bit 0 (STORAGE_RECOVERING) excludes the sender from handoff. Bit 1 (ACKS_FENCED) excludes it from the write quorum. Bit 2 (LEAVING) excludes a departing sender from handoff while its heartbeat still counts toward quorum if it can acknowledge. Receivers reject unknown bits.

PrepareProgressHeader

OffsetBytesField
1288nonce
1368group
1448partition_incarnation
1528observed_op
1608received_op
1688held_op
1768commit_op
1841kind
1851ready
1861recovery_flags
1875reserved
19216incarnation
20848reserved

Kinds 0 and 1 carry a replication progress probe and reply. Kinds 2 and 3 carry a storage recovery probe and reply. For storage recovery, nonce and observed_op contain the low and high halves of the requester's fresh 128-bit challenge. A voter replies with its durable view and sets ready when its storage is trusted. The requester counts each other voter once for its own group and partition incarnation.

A mounted sender uses its nonzero boot incarnation. A refused copy answers with a stable nonzero incarnation for that copy, its verified durable view (at least the creation view) or the creation view when the record cannot be trusted, ready = 0 and only bit 1 set. It counts as a responder and may still hold history.

A recovery reply sets bit 0 of recovery_flags for a missing copy on a disk known to predate the partition, or bit 2 for a missing copy on a possible replacement disk. Bit 1 independently indicates that the sender cannot serve its history yet. The receiver rejects unknown bits.

A partition can elect with an empty history after every voter reports a missing copy and the number of possible replacement disks stays below the replication quorum. received_op, held_op and commit_op are zero in a recovery frame, and recovery_flags and incarnation are zero in kinds 0 and 1.

StartViewChangeHeader

OffsetBytesField
1288group
1368partition_incarnation
144112reserved

DoViewChangeHeader

OffsetBytesField
1288op
1368commit
1448group
1524log_view
1561flags
1573reserved
16016incarnation
17640reserved
2168partition_incarnation
22416nack_bitset
24016present_bitset

StartViewHeader

OffsetBytesField
1288op
1368commit
1448group
1528partition_incarnation
16080reserved
24016incarnation

RequestStartViewHeader

OffsetBytesField
1288group
1368partition_incarnation
14496reserved
24016incarnation

RequestPreparesHeader

OffsetBytesField
12816nonce
1448from_op
1528to_op
1608group
1688partition_incarnation
17680reserved

RepairRangeReplyHeader

OffsetBytesField
12816nonce
1448op
1528group
1608partition_incarnation
16888reserved

RequestStateTransferHeader

OffsetBytesField
12816nonce
1448group
1528partition_incarnation
16096reserved

StateTransferTargetHeader

OffsetBytesField
12816nonce
1448commit_op
1528group
1601available
1611unavailable_transient
1626reserved_alignment
1688commit_max
1768partition_incarnation
18472reserved

RequestStateChunkHeader

OffsetBytesField
12816nonce
1448offset
1528group
1604len
1644artifact
1688partition_incarnation
17680reserved

StateChunkHeader

OffsetBytesField
12816nonce
1448offset
1528group
1604artifact
16484reserved
2488partition_incarnation

ForwardRegisterHeader

OffsetBytesField
12816client
14416nonce
1604user_id
16492reserved

ForwardRegisterResultHeader

OffsetBytesField
12816nonce
14416client
1608epoch
1688watermark
17679reserved
2551outcome

ForwardLogoutHeader

OffsetBytesField
12816client
14416nonce
1608session
1688request
17680reserved

ForwardLogoutResultHeader

OffsetBytesField
12816nonce
14416client
1608commit
16887reserved
2551outcome

ForwardCompletionHeader

OffsetBytesField
1282reporter
1301operation
131125reserved

Repair and state transfer

RequestPrepares asks for a retained operation range. RepairPrepare sends the original prepares. RepairDone terminates the stream, and RangeEvicted reports history that is no longer retained. Requests are bounded by repair_chunk_max and the peer queue capacity.

State transfer handles larger gaps. RequestStateTransfer obtains a manifest, then RequestStateChunk and StateChunk transfer artifacts. The receiver checks each complete artifact against its manifest length and checksum before using it. The manifest has magic ISM1, a u32 entry count, a u8 entry length and a trailing XxHash3-64 checksum. Entries contain kind, frontier, length and checksum.

Server 0.10.0 uses replica wire revision 1, writes metadata snapshot format 15, reads formats 14 and 15, and transfers the client table as ICT5. Server 0.10.1-edge.2 builds use revisions 4, 5, 6 and 7. Server 0.10.1-edge.3 uses revision 8 and the formats below.

KindArtifactCurrent format
0Metadata snapshotMessagePack version 22, readers accept 21 and 22
1Client tableICT6
2Segment logCanonical batch records
3Consumer offsets and partition stateICO1 version 9, readers accept 8 and 9

The offset artifact also retains partition history, retry state and producer state. These internal readability windows do not provide migration from a 0.9 data directory. Use the upgrade procedure.

The header definitions and command registry define the layouts. The replica transport implements preamble admission and authentication.

On this page