Monedula

Scenario 20.2.3 · kaf-mirror vs MirrorMaker 2: where a failover resumes

kaf-mirror vs MirrorMaker 2: Kafka failover resume points

Cluster mirroring · Advanced · about 5 min · Apache Kafka 4.4 · Scalytics kaf-mirror v2.0.0

One outage over two links. MM2 with offset sync resumes at its last checkpoint and reads 3 records again; kaf-mirror starts at the end of the copy and skips 3 unread records.

Run this scenario in the playground

Failover: two resume points. t+1.650s

dr is promoted. g-payments resumes on primary.payments at the MM2 checkpoint, offset 5, where offset sync or a client-side translation puts it, below its commit of 8. g-orders moves to orders on dr with no committed offset there, and latest puts it at the end of the copy, offset 11: it will never read O9-O11 (they are still in the log).

Open at this step: step 5, Failover: two resume points

What you start with

This scenario runs kaf-mirror and MirrorMaker 2 side by side from primary to dr, on two topics with the same producers and consumers. MM2 checkpoints the committed offset of each group in the offset space of the target, and a group starts there only with sync.group.offsets.enabled=true (off by default) or when the application translates its offsets itself; the simulator applies the checkpoint at failover. kaf-mirror copies no offsets, so its group starts at its auto.offset.reset.

Step by step

  1. Two links, two ways to resume t+0.000s orders is copied by kaf-mirror into orders on dr (same name, no offsets copied); g-orders keeps auto.offset.reset=latest, the Kafka default. payments is copied by MirrorMaker 2 into primary.payments, and MM2 checkpoints the committed offset of g-payments every 1000 ms here (emit.checkpoints.interval.seconds defaults to 60 s). A group starts at that checkpoint only with sync.group.offsets.enabled=true (off by default) or a client-side translation (RemoteClusterUtils); the simulator applies it at failover. Open at this step: step 1, Two links, two ways to resume
  2. MM2 checkpoints committed 5 t+1.100s Both groups have read O1-O8 and P1-P8. At 1000 MM2 checkpointed the committed offset of g-payments, 5, translated to dr. kaf-mirror has nothing to checkpoint: it keeps no offset map. Open at this step: step 2, MM2 checkpoints committed 5
  3. Both commit 8; a burst is copied, not read t+1.350s Both groups have committed 8. O9-O11 and P9-P11 arrived after the last poll: both links copied them to dr (both copies hold 11, RPO 0), but neither group has read them. The MM2 checkpoint is still 5. The link inspectors forecast the failover: payments reads 3 records again, orders skips 3. Open at this step: step 3, Both commit 8; a burst is copied, not read
  4. primary is lost t+1.450s The primary DC goes down: both brokers and its three controllers. Every record either group committed is on dr, and so are the 3 records of each topic they had not read. Open at this step: step 4, primary is lost
  5. Failover: two resume points t+1.650s dr is promoted. g-payments resumes on primary.payments at the MM2 checkpoint, offset 5, where offset sync or a client-side translation puts it, below its commit of 8. g-orders moves to orders on dr with no committed offset there, and latest puts it at the end of the copy, offset 11: it will never read O9-O11 (they are still in the log). Open at this step: step 5, Failover: two resume points
  6. MM2 reads 3 again, kaf-mirror skips 3 t+2.500s c2 polled 6 records: P6-P8 a second time, then P9-P11, and g-payments has committed 11. c1 polled nothing: O9-O11 sit on dr below the offset of g-orders. kaf-mirror has no failback, so going back to primary would take a new job in the other direction. Open at this step: step 6, MM2 reads 3 again, kaf-mirror skips 3

The takeaway

A checkpoint is never newer than the commit, so MM2 reads the records committed since the last checkpoint again: at-least-once (18.2.4 shows the checkpoint on its own). Without offset sync (the MM2 default) its group would also start at its auto.offset.reset. kaf-mirror with latest starts after them all and skips what the group had not read: at-most-once for those records. With earliest it would read everything again (20.2.1). kaf-mirror has no failback.

Configs in this scenario

  • auto.offset.reset 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 works

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.3" title="Kafka Simulator: kaf-mirror vs MirrorMaker 2: where a failover resumes" 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-vs-mirrormaker-2/">kaf-mirror vs MirrorMaker 2: Kafka failover resume points</a></p>

Further reading

kaf-mirror v2.0.0 source on GitHub

More in Cluster mirroring

All scenarios