Scenario 20.2.2 · kaf-mirror failover: latest skips unread records
kaf-mirror failover: latest skips unread Kafka records
g1 is 4 records behind when primary is lost. kaf-mirror carries no offsets, so latest starts g1 at the end of the copy on dr and it never reads O5-O8.
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=latest, the Kafka default. 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 drg1 is 4 records behind. t+1.300s
c1 stalled on a slow record after committing offset 4 (O1-O4). kaf-mirror kept copying: O1-O8 are at offsets 0-7 on primary and on dr, so the RPO is 0. g1's commit lives on primary only.
Open at this step: step 2, g1 is 4 records behindprimary is lost. t+1.450s
The primary DC goes down: both brokers and its three controllers. g1 had read O1-O4. dr holds all 8 records.
Open at this step: step 3, primary is lostFailover: g1 starts at the end of dr. t+1.650s
dr is promoted and orders there becomes writable. g1 moves to dr with no committed offset there, because nothing translated or copied its offset 4. auto.offset.reset=latest puts it at the end of the copy, offset 8: g1 will skip O5-O8 (offsets 4-7), which it never read.
Open at this step: step 4, Failover: g1 starts at the end of drg1 reads only new records. t+2.500s
c1 is back, and p1 writes D1 to dr at offset 8. g1 reads D1 (committed offset 9) but never O5-O8. The skip is silent: no error, no lag on g1.
Open at this step: step 5, g1 reads only new recordsThe skipped records are still on dr. t+3.000s
g-audit, a new group at auto.offset.reset=earliest on dr, reads all 9 records, O5-O8 among them. They were never lost, only skipped by g1. To read them, g1 has to be reset on dr by hand. dr numbers its own offsets, so g1's offset from primary does not carry over. kaf-mirror v2.0.0 keeps the source timestamp, so a reset by time (--to-datetime) a little before g1's last processed record lands near the same place and reads a few records again. kaf-mirror has no failback.
Open at this step: step 6, The skipped records are still on drWhat you start with
kaf-mirror copies a topic under the same name but does not translate or copy consumer offsets. After a failover each group starts on the copy at its auto.offset.reset. Here g1 keeps the Kafka default, latest, and is behind when primary is lost.
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=latest, the Kafka default. 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
- g1 is 4 records behind t+1.300s c1 stalled on a slow record after committing offset 4 (O1-O4). kaf-mirror kept copying: O1-O8 are at offsets 0-7 on primary and on dr, so the RPO is 0. g1's commit lives on primary only. Open at this step: step 2, g1 is 4 records behind
- primary is lost t+1.450s The primary DC goes down: both brokers and its three controllers. g1 had read O1-O4. dr holds all 8 records. Open at this step: step 3, primary is lost
- Failover: g1 starts at the end of dr t+1.650s dr is promoted and orders there becomes writable. g1 moves to dr with no committed offset there, because nothing translated or copied its offset 4. auto.offset.reset=latest puts it at the end of the copy, offset 8: g1 will skip O5-O8 (offsets 4-7), which it never read. Open at this step: step 4, Failover: g1 starts at the end of dr
- g1 reads only new records t+2.500s c1 is back, and p1 writes D1 to dr at offset 8. g1 reads D1 (committed offset 9) but never O5-O8. The skip is silent: no error, no lag on g1. Open at this step: step 5, g1 reads only new records
- The skipped records are still on dr t+3.000s g-audit, a new group at auto.offset.reset=earliest on dr, reads all 9 records, O5-O8 among them. They were never lost, only skipped by g1. To read them, g1 has to be reset on dr by hand. dr numbers its own offsets, so g1's offset from primary does not carry over. kaf-mirror v2.0.0 keeps the source timestamp, so a reset by time (--to-datetime) a little before g1's last processed record lands near the same place and reads a few records again. kaf-mirror has no failback. Open at this step: step 6, The skipped records are still on dr
The takeaway
With latest, a failed-over group starts at the end of the copy and skips every record it had not read yet. The records are still in the log on dr, so a reset to an earlier offset or time, or a group at earliest, can read them; nothing in kaf-mirror does it for you. 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.2" title="Kafka Simulator: kaf-mirror failover: latest skips unread records" 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-latest/">kaf-mirror failover: latest skips unread Kafka records</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: Kafka consumers re-read from earliest
- kaf-mirror vs MirrorMaker 2: Kafka failover resume points