---
title: "kaf-mirror: Kafka mirroring without offset translation"
description: "kaf-mirror copies Kafka topics under the same name but no consumer offsets. Where a group resumes after failover, what it reads twice and what it skips."
url: https://monedula.dev/kafka/multi-dc/mirroring-without-offset-translation/
---

# Mirroring without offset translation: kaf-mirror

Checked against its sources on 27 November 2026.

kaf-mirror copies a Kafka topic to another cluster under the same name, but it keeps no offsets and syncs no consumer group positions. After a failover a group on the copy starts at its `auto.offset.reset`: `earliest` starts at the copy’s first record and reads again everything the group had already processed, and `latest` starts at the end and skips what the group had not read yet. The skipped records stay in the copy’s log.

## What kaf-mirror copies and what it does not

kaf-mirror is an Apache 2.0 service from Scalytics, written in Go on the franz-go client. Each replication job consumes the source with a consumer group of its own, `kaf-mirror-job-` followed by the job ID, and produces every record to the target. By default the target topic keeps the source’s name; an exact or regex mapping renames it. Before a job starts, it creates a missing target topic with the source’s partition count, and it does not start while a source topic and its target have different partition counts. Each record is written to the partition it came from: source partition N goes to target partition N. If the source gains partitions while a job runs, records from a partition the target does not have are placed by key hash until the target gets the same count.

It copies each record’s key, value, headers and timestamp. The copy keeps the source time as long as the target topic uses `message.timestamp.type=CreateTime`, the Kafka default; with `LogAppendTime` the target broker stamps its own. Topic configs, ACLs and consumer groups are not copied. At job start kaf-mirror compares `compression.type` and warns about a compressed source with an uncompressed target.

Offsets are not kept. The target assigns its own, as it does for any producer, and kaf-mirror writes no checkpoints, no offset syncs and no consumer group offsets on the target.

This page describes v2.0.0, released on 27 November 2026. Against v1.3.1 it changes three points: the copy keeps the source timestamp and the source partition, where v1.3.1 stamped the time of copying and let the producer’s default partitioner choose, and a write that keeps failing stops the job instead of being passed over. A job also follows a source topic that is deleted and created again, by its Kafka topic ID. Offsets stay untranslated.

## Where a consumer group resumes after failover

A group that moves to the copy has no committed offset there, so the consumer’s `auto.offset.reset` decides where it starts. `earliest` starts at the copy’s log start: the group reads every record the copy holds, so everything it had already processed on the primary is read a second time. `latest`, the Kafka default, starts at the copy’s end: the group reads only the records written after it joins, and skips the ones copied before the outage that it had not read yet.

The skipped records stay in the copy’s log. A group that starts at `earliest`, or a reset of the group to an earlier offset, reads them. What does not carry over is the group’s offset: the copy numbers its records itself. Since v2.0.0 the copy keeps the source timestamps, so a reset by time, `kafka-consumer-groups.sh --reset-offsets --to-datetime`, lands near the same place on the copy as on the primary. It is approximate: with `CreateTime` the producers set the timestamps, which need not grow with the offset, so pick a time a little before the group’s last processed record and expect to read a few records again.

`none` makes the consumer fail with an error when it has no committed offset, so the application decides where to start before it reads anything. The simulator has no such error and treats `none` like `earliest`.

Records the job had not copied when the primary failed never reach the copy, whatever the reset. That part is the same with every asynchronous mirror.

- Simulator: [kaf-mirror failover: earliest reads everything again](https://monedula.dev/kafka-simulator/scenarios/kaf-mirror-failover-earliest/): A group that had processed all 8 records fails over with `earliest` and reads all 8 a second time on the copy.
- Simulator: [kaf-mirror failover: latest skips unread records](https://monedula.dev/kafka-simulator/scenarios/kaf-mirror-failover-latest/): A group 4 records behind fails over with `latest` and never reads those 4, while a new group with `earliest` shows they are still in the copy’s log.

## At-least-once, and where duplicates come from

The job sends all records of a fetch, waits for the target to acknowledge them and then commits the highest acknowledged offset of each partition, so a source offset is committed only after the target has the record. A job that stops and restarts resumes at its last commit and writes the records after it again, so the copy holds them twice. The producer is idempotent by default, which drops the duplicates of a retry within one producer session, but not the second write of a restarted job. kaf-mirror uses no transactions, so the copy is not exactly-once across the two clusters.

A record the target keeps rejecting is not skipped. kaf-mirror tries it 5 times, waiting 1, 2, 4 and 8 seconds between the tries, and each try sends the records after it in the same partition again, so the target can get those twice. If the fifth try fails, the job stops with the status `failed` and its source offset stays at that record. v1.3.1 logged such a record and moved on, and the commit of the next record passed over it.

`disable_idempotent_writes` on a cluster, or the `KAFMIRROR_DISABLE_IDEMPOTENT_WRITES` environment variable, turns idempotence off, and a retried write can then be stored twice. It is needed only for KafScale before v2.1.0: kaf-mirror v2.0.0 is verified against KafScale v2.1.0 and later with idempotent writes on.

The source consumer sets no isolation level, so it reads `read_uncommitted`. Records of an open transaction are copied before the transaction ends, and the records of an aborted transaction reach the copy as ordinary data, where a `read_committed` consumer reads them too.

## Same names: no active-active and no failback

Because the copy keeps the source’s topic name, a second job in the other direction would copy every record back into the topic it came from, and the kaf-mirror docs describe no loop prevention. It fits a standby that stays passive, not the same topic mirrored both ways.

There is no failback step either. After a failover, a job from the new primary back to the old one would append what the standby took on top of what the old primary already holds, with nothing truncated or deduplicated.

In the simulator the copy is read-only until failover, as with MirrorMaker 2, although kaf-mirror itself does not block writes to it. The simulator refuses an active-active pair over kaf-mirror and has no failback for it, and says why in each case.

## Against a mirror that translates offsets

MirrorMaker 2 checkpoints each group’s committed offset in the target’s numbering. With `sync.group.offsets.enabled=true`, off by default, or with a client that translates the offsets itself, a group resumes at its last checkpoint and reads only the commits since then a second time: at-least-once. kaf-mirror leaves the outcome to the reset: a reread of everything the group had processed with `earliest`, or the unread records skipped with `latest`, which is at-most-once for them.

Before choosing it, measure each group’s lag behind the copy at the moment of a failover, which is what `latest` skips. Decide the reset per group, check that the consumers of the copy tolerate duplicates, and treat a reset by time on the copy as approximate.

- Simulator: [kaf-mirror vs MirrorMaker 2: where a failover resumes](https://monedula.dev/kafka-simulator/scenarios/kaf-mirror-vs-mirrormaker-2/): The same outage over kaf-mirror and MirrorMaker 2: MirrorMaker 2 resumes at its checkpoint and reads 3 records again, kaf-mirror starts at the end and skips 3 unread ones.
- Simulator: [Offset translation across clusters](https://monedula.dev/kafka-simulator/scenarios/offset-translation-checkpoint/): MirrorMaker 2 on its own: it checkpoints the committed offset, and after failover the group rereads only the commits since the last checkpoint.

## A copy is not a backup

A copy that follows the source also follows its deletes, its bad writes and anything written with stolen producer credentials. kaf-mirror’s docs say so themselves and, for a backup, point to a target your producers cannot write to, on credentials of its own: KafScale, a Kafka-compatible broker that keeps immutable segments in S3, or any other Kafka-compatible cluster set up the same way. With KafScale, create every target topic beforehand with the source’s partition count.

Replication halt, a tech preview in v2.0.0, off by default and for admins only, stops new copying when the source is compromised. It does not roll the copy back. kaf-mirror has no point-in-time restore of a topic, and its `admin-cli backup` and `restore` cover its own database and config, not topic data.

If the source deletes a topic and creates it again, the job notices the new Kafka topic ID and copies the new topic from its earliest offsets into the same target topic. A topic that is deleted and not created again leaves the job active, with the topic listed in `missing_source_topics`. Topic IDs need Kafka 2.8 or later; on an older broker the job follows the topic by name and switches nothing.

## Sources

- [kaf-mirror v2.0.0 README](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/README.md)
- [kaf-mirror v2.0.0 docs, What a copied record keeps](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/docs/record-fidelity.md)
- [kaf-mirror v2.0.0 docs, Resilience and buffering](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/docs/resilience.md)
- [kaf-mirror v2.0.0 source, internal/kafka/kaf-mirror.go](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/internal/kafka/kaf-mirror.go)
- [kaf-mirror v2.0.0 source, internal/kafka/consumer.go](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/internal/kafka/consumer.go)
- [kaf-mirror v2.0.0 source, internal/kafka/producer.go](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/internal/kafka/producer.go)
- [kaf-mirror v2.0.0 docs, Back up to S3 with KafScale](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/docs/kafscale-backup.md)
- [kaf-mirror v2.0.0 docs, Replication halt (experimental)](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/docs/protection.md)
- [kaf-mirror CHANGELOG, 2.0.0](https://github.com/scalytics/kaf-mirror/blob/v2.0.0/CHANGELOG.md)
- [Apache Kafka 4.3 docs, consumer config auto.offset.reset](https://kafka.apache.org/43/configuration/consumer-configs/#consumerconfigs_auto.offset.reset)
- [Apache Kafka 4.3 docs, consumer config isolation.level](https://kafka.apache.org/43/configuration/consumer-configs/#consumerconfigs_isolation.level)
- [KIP-382: MirrorMaker 2.0](https://cwiki.apache.org/confluence/display/KAFKA/KIP-382%3A+MirrorMaker+2.0)
- [Apache Kafka 4.3 docs, MirrorMaker configs](https://kafka.apache.org/43/configuration/mirrormaker-configs/#mirror_checkpoint_emit.checkpoints.interval.seconds)

## Changes to this page

- 27 November 2026: Updated to kaf-mirror v2.0.0: the copy keeps the source partition and timestamp, so a reset by time on the copy lands near the primary’s position; a record the target keeps rejecting stops the job instead of being skipped; and a new section on why a copy is not a backup.
- 24 November 2026: First published: what kaf-mirror copies, where a consumer group resumes after failover without offset translation, and where duplicates come from.
