Monedula

Markdown

Part III · Architecture

Kafka guide · Multi-DC and DR

Consumer offsets in failover and failback

Checked against its sources on 24 November 2026

MirrorMaker 2, Replicator and Lenses K2K write the standby’s log themselves, so its offsets are its own and a consumer group resumes at its last translated position, rereading what it committed after it. Cluster Linking and Apache Kafka’s Cluster Mirroring (KIP-1279) keep offsets identical, so a group resumes where it was as of the last offset sync, with no mapping error, but no tool brings back records the mirror had not copied. On failback, the records the old primary held but never mirrored are truncated or left orphaned, depending on the tool.

Why the standby’s offsets are not the primary’s

An offset is a position in one partition’s log on one cluster. MirrorMaker 2, Confluent Replicator and Lenses K2K consume from the primary and produce to the standby, so the standby numbers the records itself. The K2K docs say it outright: where an application stopped on the source means nothing on the target.

MirrorMaker 2 records offset syncs, each a source offset and its equivalent on the target, and emits checkpoints with every group’s latest committed offset translated to the target, every 60 seconds by default in the Apache Kafka 4.3 configs (emit.checkpoints.interval.seconds; KIP-382 proposed 5). With sync.group.offsets.enabled=true, off by default, it also writes them to the target’s __consumer_offsets, every 60 seconds by default (sync.group.offsets.interval.seconds). Not every offset is captured in the checkpoint stream, so a translated position is one a consumer can seek to, not always the exact one.

Replicator translates by timestamp. A consumer interceptor, ConsumerTimestampsInterceptor, writes each group’s committed offsets and timestamps to __consumer_timestamps on the primary, and Replicator writes the matching offsets to the standby’s __consumer_offsets while no consumer of that group is connected there. The interceptor works for Java clients only and does not support transactions.

K2K records source-to-target offset mappings in __k2k_offset_mappings as it replicates. A separate app, the offset mapper, checks for consumer group changes every 5 seconds by default (groups.pollInterval) and commits translated positions on the target. Offset mapping needs a license; the free tier does not include it.

Cluster Linking mirror topics are byte-for-byte, offset-preserving copies, and the link can sync consumer group offsets (consumer.offset.sync.enable, off by default; Confluent’s example sets consumer.offset.sync.ms=5000). KIP-1279 copies batches byte for byte, keeping offsets and topic IDs, and syncs group offsets too. With either, a committed offset names the same record on both clusters.

In the simulator

Where the group resumes after failover

Take one partition of orders on the primary with records up to offset 1249. When the primary fails, the mirror has copied everything below 1244, and the consumer group has committed 1247: it has processed everything below that.

The primary’s log holds offsets 1236 to 1249. The standby holds everything below 1244. The consumer group has committed up to 1247. The primary goes down.
Where the consumer group resumes on the standby, by tool.
ToolStandby topicGroup resumes atRereadsLost
MirrorMaker 2 primary.orders 1240 (offset 240 on the standby) 4 records 6 records
Confluent Replicator orders 1241 (offset 241 on the standby) 3 records 6 records
Lenses K2K orders 1242 (offset 242 on the standby) 2 records 6 records
kaf-mirror orders 1000 (offset 0 on the standby, from the log start) 244 records 6 records
Cluster Linking orders (mirror) 1244 0 records 6 records
Cluster Mirroring (KIP-1279) orders (mirror) 1244 0 records 6 records
MirrorMaker 2
Offsets on the standby are its own numbers. A checkpoint translated the group to 1240 before the outage, so it resumes there.
Confluent Replicator
Offsets are translated too (by timestamp), so the group resumes near, not at, where it stopped.
Lenses K2K
Offsets on the standby are its own numbers. The offset mapper had last committed the group at 1242, the position its last poll translated, so it resumes close to, not at, where it stopped.
kaf-mirror
No offsets are translated. With auto.offset.reset=earliest the group starts at the standby’s first record and reads everything again; with latest it starts at the end and skips what it had not read.
Cluster Linking
The mirror topic keeps the same offsets. On failover the synced offset is clamped to the mirror’s end, so the group resumes at the first record written on the standby after failover.
Cluster Mirroring (KIP-1279)
Stopping the mirror makes the same-name topic writable with the same offsets. The synced offset is clamped to the mirror’s end, so the group resumes at the first record written on the standby after failover.

The 6 records from 1244 to 1249 never reached the standby. That loss is the same with every tool, because every tool here copies asynchronously, and the group had already processed 3 of them on the primary. The tools differ only in where the group starts on the standby.

MirrorMaker 2 resumes the group at 1240 (offset 240 in primary.orders on the standby), the position its last checkpoint before the outage translated, and reads 4 records a second time. That holds only if sync.group.offsets.enabled=true wrote the checkpoint into the standby’s __consumer_offsets, or the application seeks to the translated offsets itself (RemoteClusterUtils.translateOffsets); otherwise the group has no committed offset on the standby at all. Replicator resumes it at 1241, the offset its timestamp translation found, and reads 3 records a second time. K2K resumes it at 1242, the position the offset mapper’s last poll translated, and reads 2 records a second time.

Cluster Linking keeps the same offsets, so the synced position needs no mapping, but it is still only as fresh as the last sync. If that sync carried 1247, that is past the mirror’s end, and the link clamps synced offsets to the mirror topic’s log end offset at failover, so the group resumes at 1244 and rereads nothing. Without the clamp it would start at 1247 and skip the first 3 records written on the standby after failover.

KIP-1279 keeps the same offsets too, and clamps each synced group offset between the mirror’s log start and log end, so a synced 1247 becomes 1244 and the group rereads nothing. Its stop also appends ABORT markers for transactions still open, so a transaction the primary commits later is aborted on the standby.

The rereads above assume the last translation or sync ran just before the outage. With a tool that translates or syncs offsets, a group resumes at its last translated or synced position, so the window grows with the interval: a minute or more of commits with MirrorMaker 2’s 60-second defaults, a few seconds with K2K, whose offset mapper polls for group changes every 5 seconds. Consumers that cannot take a reread of that size need idempotent processing downstream.

Cluster Linking also separates a planned move from a disaster. promote checks that there is no mirroring, config or consumer offset lag and needs the source online; failover runs whatever the lag or the source’s state.

In the simulator

Failback: the records only the old primary has

While the standby serves traffic it takes new writes. With an offset-preserving mirror it numbers them from 1244, and by the time the old primary is back it has reached 1255: 12 records the old primary has never seen. The old primary still holds 6 records, 1244 to 1249, that the standby never got. The two logs agree below 1244 and differ from there on.

When the old primary returns, it holds 6 records (offsets 1244 to 1249) that the standby never received, and the standby holds 12 records (offsets 1244 to 1255) written since the failover. This is the case with an offset-preserving mirror, where the standby’s writes continue the primary’s numbering.
Only on the old primary
6 records, which diverge from the standby’s log. Cluster Linking and KIP-1279 delete them on failback; under MirrorMaker 2 and Replicator they stay on the old primary, orphaned.
Only on the standby
12 records. Cluster Linking and KIP-1279 copy them to the old primary at the same offsets; under MirrorMaker 2 they belong in a topic of the standby’s own, which arrives on the primary under another prefixed name.

Cluster Linking and KIP-1279 truncate. With Cluster Linking, truncate-and-restore on the old primary’s topic deletes the divergent records produced there after the failover point and turns it into a mirror of the standby; reverse-and-start then restores the original direction. It needs a bidirectional link and KRaft. Under KIP-1279 the returning cluster truncates each partition to the last offset of the mirror epoch and copies only the delta. Either way the 6 records are deleted, and offsets 1244 to 1255 then hold the standby’s records on both clusters.

MirrorMaker 2 and Replicator have no such step, so the tail is orphaned instead. MirrorMaker 2 names the standby’s copy after the source cluster, primary.orders, and a flow back to the primary skips that topic as a cycle; writes taken on the standby belong in a topic of its own, which arrives on the primary under another prefixed name. The primary’s orders keeps the 6 records that nobody reading the standby saw.

Replicator’s failback instructions leave the tail to you: copy it to the secondary if order does not matter, and if order matters, Confluent says no standard answer exists. K2K offers bidirectional replication as a licensed feature, with headers that stop records looping, but the K2K docs read for this page describe no failback procedure for the old primary’s tail.

The group had committed 1247 on the old primary, so it had processed 3 of the 6 records. Truncation deletes them, but what the consumer did with them downstream stays done; Confluent warns that truncation can lose data unless clients are set up to reprocess it.

There are two ways around it. A stretched cluster has no second log to diverge: an acknowledged record is already on the in-sync replicas in the other sites, and failback is a leader moving home. Otherwise, keep a producer replay window: producers retain what they sent for longer than the worst mirror lag and resend it to the new primary after failover, and consumers deduplicate by a key the application owns.

Kafka’s idempotent producer does not cover that replay. The broker assigns each producer an ID and deduplicates by the sequence number sent with every record, and the standby’s brokers have never seen that ID.

In the simulator

  • Failback after the primary recoversFail over, take writes on the standby, fail back: the simulator re-syncs them onto the recovered primary with the mirror caught up, so nothing is orphaned, and its conclusion says why real MirrorMaker 2 has no failback action.
  • Bidirectional links and clean failbackA cluster link switched over and back: the link reverses in place each time, and both clusters end with the same records at the same offsets.
  • Cluster Mirroring: stop and fail backKIP-1279’s stop with one record not yet mirrored and a transaction open: the record is lost on the standby, the transaction is aborted there, and failback truncates the old primary to the stop point.

Sources

Changes to this page

  • The copy names no fixed number of tools, and a group resumes at its last synced or translated position only with a tool that syncs or translates offsets.
  • First published: where each tool resumes a consumer group after failover, and what failback does to the records only the old primary has.

Kafka disaster recovery across data centers