# When a Kafka OK means your message is saved

> With acks=1 a leader crash can lose messages Kafka confirmed; acks=all plus min.insync.replicas=2 stops that.

Source: https://fullbytedeveloper.com/blog/when-kafka-ok-means-saved
Published here: 2026-11-17
Tested: 2026-11-16, Apache Kafka 4.1.0 (1 KRaft controller + 3 brokers) in Docker 29.4.0 on macOS 27.2

Kafka can lose a message it already said OK to. It happens with the producer setting `acks=1` when the leader dies before its followers copy the message [1]. This page is part 2 of [what happens when you send a message to Kafka](/blog/what-happens-when-you-send-a-kafka-message), and it uses the numbers from the run shown in the video: Apache Kafka 4.1.0 in Docker, three brokers and one KRaft controller on one machine, recorded on 2026-11-16.

## Kill the leader and watch who takes over

In part 1, the order sat at offset 1447 in partition 1, on broker 2 (the leader), with copies on brokers 3 and 1. In the run, broker 2 was killed with no clean shutdown.

A controller tracks every broker through heartbeats. A broker's lease lasts `broker.session.timeout.ms` without heartbeats, 9 seconds by default [2]. The new leader can only come from the in-sync replicas [3], and `unclean.leader.election.enable` is `false` by default [2]. In the run, broker 3 led partition 1 after 9.7 seconds, with in-sync replicas 3 and 1.

The order was still at offset 1447. The next order from the same user went in at 1448, on the new leader.

## Know what in-sync means

A follower leaves the in-sync set if it has not fetched, or not caught up to the leader's log end, for `replica.lag.time.max.ms`, 30 seconds by default [2]. So a follower a few seconds behind still counts as in sync, and it can be missing the newest messages.

## Set acks on the producer

`acks` decides when the producer hears OK. With `acks=1`, the leader writes the record to its own log and answers without waiting for the followers. Per the docs, if the leader fails right after that answer and before the followers have the record, the record is lost [1]. With `acks=all`, the leader waits for the full set of in-sync replicas [1]. The default is `all` [1].

```properties title="producer.properties"
acks=all
```

## Compare the two settings under the same crash

The run tested both settings on a one-partition topic with three replicas. Both followers were frozen, the producer kept sending, and then the leader was killed.

With `acks=1`, five messages got an OK. A follower took over without them, because it was still in sync, and new messages were written into the same offsets. Those five were gone from the log.

With `acks=all` and `min.insync.replicas=2`, the five messages in flight got an error instead of an OK. Zero confirmed messages were lost. A default Java producer retries such errors: `retries` defaults to 2147483647, bounded by `delivery.timeout.ms`, 120000 ms by default [1]. The test tool in the run reported the errors and did not retry.

## Set min.insync.replicas to 2 on the topic

`min.insync.replicas` is the minimum number of in-sync replicas, the leader included, that must have a write for it to succeed. Its default is 1 [2]. If both followers drop out of the in-sync set, `acks=all` with the default would wait for the leader alone. With 2, Kafka refuses the write. The topic config command follows the operations docs [4].

```bash
bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name orders --alter --add-config min.insync.replicas=2
```

```bash
bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name orders --describe
```

You should see `min.insync.replicas=2` in the topic's config list.

## Accept the throughput cost

Waiting for copies costs speed. On the run's one machine (200-byte messages, three partitions, replication factor 3, `min.insync.replicas=2`), `acks=all` sent 229,043 messages a second and `acks=1` sent 564,334. All brokers shared that one machine, so treat these as a ratio for that setup only.

An OK means saved when the topic has three replicas, the producer uses `acks=all`, and `min.insync.replicas` is 2.

Send this to the teammate whose Kafka producer still uses acks=1 for orders.

## Sources

1. [Apache Kafka 4.1 docs: Producer configs (acks, retries, delivery.timeout.ms)](https://kafka.apache.org/41/configuration/producer-configs/)
2. [Apache Kafka 4.1 docs: Broker configs (min.insync.replicas, replica.lag.time.max.ms, broker.session.timeout.ms)](https://kafka.apache.org/41/configuration/broker-configs/)
3. [Apache Kafka 4.1 docs: Design (Replication)](https://kafka.apache.org/41/design/design/)
4. [Apache Kafka 4.1 docs: Basic Kafka operations (topic configs)](https://kafka.apache.org/41/operations/basic-kafka-operations/)
