Scenario 20.2.1 · kaf-mirror failover: earliest reads everything again
kaf-mirror failover: Kafka consumers re-read from earliest
kaf-mirror copies orders under the same name but not the consumer offsets. After the failover g1 starts at the log start on dr and reads all 8 records twice.
Run this scenario in the playgroundkaf-mirror copies orders to dr. t+0.000s
kaf-mirror consumes orders on primary and produces each record into orders on dr, partition 0 to partition 0, under the same name. It keeps no offset map and copies no consumer offsets. g1 reads orders on primary with auto.offset.reset=earliest. Until a failover the copy on dr is read-only (the simulator's choice: kaf-mirror itself does not block writes to it).
Open at this step: step 1, kaf-mirror copies orders to drCaught up on both sides. t+1.300s
O1-O8 are at offsets 0-7 on primary and on dr, so the RPO is 0. g1 has read and committed all 8 on primary (committed offset 8). That commit lives on primary only: kaf-mirror does not copy it to dr.
Open at this step: step 2, Caught up on both sidesprimary is lost. t+1.450s
The primary DC goes down: both brokers and its three controllers. kaf-mirror can no longer read from it. dr still holds all 8 records.
Open at this step: step 3, primary is lostFailover: g1 starts at offset 0 on dr. t+1.650s
dr is promoted and orders there becomes writable. g1 moves to dr, where it has no committed offset, because nothing translated or copied its offset 8. auto.offset.reset=earliest puts it at the start of the copy: offset 0.
Open at this step: step 4, Failover: g1 starts at offset 0 on drAll 8 records read a second time. t+1.850s
c1 polls O1-O8 again from dr and commits offset 8 there. Every record g1 had already processed on primary is processed twice: nothing is missed, but the application must tolerate the duplicates.
Open at this step: step 5, All 8 records read a second timeNew writes on dr are read once. t+2.500s
p1 writes D1 to dr at offset 8 and g1 reads it once (committed offset 9). kaf-mirror has no failback: going back to primary would take a new job in the other direction, which the simulator does not model.
Open at this step: step 6, New writes on dr are read onceWhat you start with
kaf-mirror copies a topic into another cluster under the same name, partition for partition, but it does not translate or copy consumer offsets. After a failover each group starts on the copy wherever its auto.offset.reset puts it. Here g1 uses earliest.
Step by step
- kaf-mirror copies orders to dr t+0.000s kaf-mirror consumes orders on primary and produces each record into orders on dr, partition 0 to partition 0, under the same name. It keeps no offset map and copies no consumer offsets. g1 reads orders on primary with auto.offset.reset=earliest. Until a failover the copy on dr is read-only (the simulator's choice: kaf-mirror itself does not block writes to it). Open at this step: step 1, kaf-mirror copies orders to dr
- Caught up on both sides t+1.300s O1-O8 are at offsets 0-7 on primary and on dr, so the RPO is 0. g1 has read and committed all 8 on primary (committed offset 8). That commit lives on primary only: kaf-mirror does not copy it to dr. Open at this step: step 2, Caught up on both sides
- primary is lost t+1.450s The primary DC goes down: both brokers and its three controllers. kaf-mirror can no longer read from it. dr still holds all 8 records. Open at this step: step 3, primary is lost
- Failover: g1 starts at offset 0 on dr t+1.650s dr is promoted and orders there becomes writable. g1 moves to dr, where it has no committed offset, because nothing translated or copied its offset 8. auto.offset.reset=earliest puts it at the start of the copy: offset 0. Open at this step: step 4, Failover: g1 starts at offset 0 on dr
- All 8 records read a second time t+1.850s c1 polls O1-O8 again from dr and commits offset 8 there. Every record g1 had already processed on primary is processed twice: nothing is missed, but the application must tolerate the duplicates. Open at this step: step 5, All 8 records read a second time
- New writes on dr are read once t+2.500s p1 writes D1 to dr at offset 8 and g1 reads it once (committed offset 9). kaf-mirror has no failback: going back to primary would take a new job in the other direction, which the simulator does not model. Open at this step: step 6, New writes on dr are read once
The takeaway
Without offset translation, auto.offset.reset decides where a failed-over group starts. earliest skips nothing that reached the copy (records not yet copied are gone whatever the reset), but reads the whole copy again, so the application must handle every record twice (idempotent processing). kaf-mirror has no failback: going back to primary means a new job in the other direction.
Configs in this scenario
-
auto.Where a consumer starts when its group has no committed offset or the offset no longer exists: latest (the default), earliest, by_duration (a time back from now, such as by_duration:PT1H), or none to throw an exception instead. How auto.offset.reset worksoffset. reset
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.2.1" title="Kafka Simulator: kaf-mirror failover: earliest reads everything again" 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/kaf-mirror-failover-earliest/">kaf-mirror failover: Kafka consumers re-read from earliest</a></p> Further reading
kaf-mirror v2.0.0 source on GitHub
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
- Apache Kafka Cluster Mirroring (KIP-1279): stop and failback
- kaf-mirror failover: latest skips unread Kafka records
- kaf-mirror vs MirrorMaker 2: Kafka failover resume points