Scenario 20.1.6 · Cluster Mirroring: stop and fail back
Apache Kafka Cluster Mirroring (KIP-1279): stop and failback
Apache Kafka's own offset-preserving mirror (KIP-1279, accepted, not yet released): there is no planned promote, the cutover is --stop, and a transaction still open at the source is aborted on the mirror.
Run this scenario in the playgroundA cluster mirror, primary → dr. t+0.000s
A KIP-1279 cluster mirror copies orders from primary into a read-only orders on dr: same name, no prefix, and the same offsets, because each dr partition leader fetches from primary with a MirrorFetcherThread. A produce to orders on dr fails with READ_ONLY_TOPIC.
Open at this step: step 1, A cluster mirror, primary → drAn open transaction is mirrored too. t+0.900s
O1-O3 sit at offsets 0-2 on both sides. The transaction then writes T1 and T2 at offsets 3 and 4 and stays open, so primary's LSO holds at 3, yet the mirror copied them: it fetches READ_UNCOMMITTED. Both copies are at high watermark 5.
Open at this step: step 2, An open transaction is mirrored tooPaused: O4 stays on primary. t+1.100s
kafka-cluster-mirrors --pause removed the fetchers. The mirror stays read-only and copies nothing, so O4 (offset 5) is on primary only: dr is 1 record behind.
Open at this step: step 3, Paused: O4 stays on primaryStop: writable now, the open transaction aborted. t+1.250s
kafka-cluster-mirrors --stop is the only cutover KIP-1279 has: it does not wait for lag 0. orders on dr is writable, O4 never reached it (RPO 1), and the stop bumps dr's leader epoch from ε0 to ε1, the line between mirrored records and dr's own. It also appends ABORT markers for the transaction still open on primary, so offsets 3-4 are aborted on dr (the faded, struck-through cells). read_committed consumers there skip them.
Open at this step: step 4, Stop: writable now, the open transaction abortedprimary commits what dr aborted. t+1.400s
The transactional producer commits on primary: T1 and T2 are committed there, primary's LSO moves to 6, while dr keeps them aborted, so for now the two copies disagree. Exactly-once does not cross clusters. That is not a KIP-1279 design choice: any asynchronous cross-cluster replication can stop between a transaction's records and its commit.
Open at this step: step 5, primary commits what dr aborteddr takes its own write. t+1.650s
D1 is produced on dr at offset 5, the offset O4 holds on primary: the two logs have diverged past the stop point.
Open at this step: step 6, dr takes its own writeFail back: truncate and mirror back. t+2.200s
The failback is a reverse mirror, dr → primary. It truncates orders on primary to the end of the last mirrored epoch, offset 5, where dr's epoch 1 begins, which deletes O4 and the COMMIT marker primary wrote after it, makes it a read-only mirror, and copies dr's log back from there: the stop's ABORT marker, then D1. dr is not truncated: it is the source now and keeps its log as it is. The two logs converge, so offsets 3-4 are now aborted on primary too. In Kafka every marker takes an offset (the ABORT at 5, D1 at 6); the simulator's markers take none, so D1 shows at 5.
Open at this step: step 7, Fail back: truncate and mirror backWhat you start with
KIP-1279 puts cluster mirroring into Apache Kafka: the destination partition leaders fetch from the source and keep the same offsets, and the mirror keeps the source name and rejects produces with READ_ONLY_TOPIC. It was accepted in September 2026 but is not in an Apache Kafka release yet; when it ships, it sits behind the mirror.version feature flag. In this run a transaction on primary is still open when the mirror is paused and then stopped, so the stop aborts it on dr, while primary commits it afterwards. dr then takes a write of its own, D1, before the topic fails back to primary.
Step by step
- A cluster mirror, primary → dr t+0.000s A KIP-1279 cluster mirror copies orders from primary into a read-only orders on dr: same name, no prefix, and the same offsets, because each dr partition leader fetches from primary with a MirrorFetcherThread. A produce to orders on dr fails with READ_ONLY_TOPIC. Open at this step: step 1, A cluster mirror, primary → dr
- An open transaction is mirrored too t+0.900s O1-O3 sit at offsets 0-2 on both sides. The transaction then writes T1 and T2 at offsets 3 and 4 and stays open, so primary's LSO holds at 3, yet the mirror copied them: it fetches READ_UNCOMMITTED. Both copies are at high watermark 5. Open at this step: step 2, An open transaction is mirrored too
- Paused: O4 stays on primary t+1.100s kafka-cluster-mirrors --pause removed the fetchers. The mirror stays read-only and copies nothing, so O4 (offset 5) is on primary only: dr is 1 record behind. Open at this step: step 3, Paused: O4 stays on primary
- Stop: writable now, the open transaction aborted t+1.250s kafka-cluster-mirrors --stop is the only cutover KIP-1279 has: it does not wait for lag 0. orders on dr is writable, O4 never reached it (RPO 1), and the stop bumps dr's leader epoch from ε0 to ε1, the line between mirrored records and dr's own. It also appends ABORT markers for the transaction still open on primary, so offsets 3-4 are aborted on dr (the faded, struck-through cells). read_committed consumers there skip them. Open at this step: step 4, Stop: writable now, the open transaction aborted
- primary commits what dr aborted t+1.400s The transactional producer commits on primary: T1 and T2 are committed there, primary's LSO moves to 6, while dr keeps them aborted, so for now the two copies disagree. Exactly-once does not cross clusters. That is not a KIP-1279 design choice: any asynchronous cross-cluster replication can stop between a transaction's records and its commit. Open at this step: step 5, primary commits what dr aborted
- dr takes its own write t+1.650s D1 is produced on dr at offset 5, the offset O4 holds on primary: the two logs have diverged past the stop point. Open at this step: step 6, dr takes its own write
- Fail back: truncate and mirror back t+2.200s The failback is a reverse mirror, dr → primary. It truncates orders on primary to the end of the last mirrored epoch, offset 5, where dr's epoch 1 begins, which deletes O4 and the COMMIT marker primary wrote after it, makes it a read-only mirror, and copies dr's log back from there: the stop's ABORT marker, then D1. dr is not truncated: it is the source now and keeps its log as it is. The two logs converge, so offsets 3-4 are now aborted on primary too. In Kafka every marker takes an offset (the ABORT at 5, D1 at 6); the simulator's markers take none, so D1 shows at 5. Open at this step: step 7, Fail back: truncate and mirror back
The takeaway
Stop is the only cutover in KIP-1279: it never waits for lag 0, so O4 is lost on dr, and it appends ABORT markers for the transactions still open at the source, so T1 and T2 are aborted on dr even though primary commits them later. It also bumps dr's leader epoch, which marks where dr's own writes begin. Exactly-once does not cross clusters, and no asynchronous cross-cluster replication can make it: a stop can always fall between a transaction's records and its commit. Failing back is a reverse mirror: it truncates primary to the end of the last mirrored epoch, the stop point, which drops O4 and primary's COMMIT marker, and copies dr's log back at the same offsets, ABORT marker included, so both copies end with T1 and T2 aborted.
Embed this scenario
Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.
<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=20.1.6" title="Kafka Simulator: Cluster Mirroring: stop and fail back" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/cluster-mirroring-stop-failback/">Apache Kafka Cluster Mirroring (KIP-1279): stop and failback</a></p> Further reading
KIP-1279 on the Apache Kafka wiki
Kafka proposals behind this scenario
More in Cluster mirroring
- Confluent Cluster Linking: offset-preserving Kafka mirroring
- Kafka mirror topics (Confluent): read-only until promoted
- Cluster Linking vs MirrorMaker 2 for Kafka replication
- Kafka consumer offset sync: Cluster Linking vs MirrorMaker 2
- Kafka failover and failback with Confluent Cluster Linking
- kaf-mirror failover: Kafka consumers re-read from earliest
- kaf-mirror failover: latest skips unread Kafka records
- kaf-mirror vs MirrorMaker 2: Kafka failover resume points