Data resilience

Why Kafka Writes Stall During a Restart

Use replica thresholds, DNS evidence and test orders to decide when Kafka can safely move to the next broker during rolling maintenance.
By MR Solutions
4 min readPublished
Three servers with amber lights in an open rack, with the middle unit pulled forward on a copper-coloured rail.

Can the order service still write?

Suppose an order service sends each accepted order to Kafka for fulfilment. During maintenance, the dashboard shows three running brokers. The question for the operations lead is whether an order can still reach fulfilment within the promised time. A broker count answers only the first part of that investigation.

Take a Kafka 4.0 topic with three replicas per partition, min.insync.replicas set to two and producer acknowledgements set to all (acks=all). Start with all three copies in sync. Restart the broker holding one copy and two remain. If another copy falls behind far enough to leave the in-sync replica set (ISR), only one remains. Kafka can no longer acknowledge that write under the agreed policy. The third broker can already be running again while its copy catches up.

Find where recovery waits

Use a single timeline for the affected partition. Mark the broker shutdown, replacement pod address, first successful replication after restart and return to full ISR. If a peer repeatedly connects to the old address after the replacement is reachable, investigate name resolution. If it reaches the new address promptly, look for time spent recovering producer state or catching up on the log before changing DNS settings.

For a Strimzi-managed deployment, check the Java version and the DNS path used by the affected process. Java 21 caches successful name lookups. Kubernetes clusters with NodeLocal DNSCache also cache answers on each node. Compare the destination the broker actually tried with the answer from its node and the replacement pod’s address at the same time. A fresh lookup from an administrator’s laptop cannot tell you which address the broker used.

Give KRaft controller restarts their own rehearsal. Compare changes in the active controller’s timed-out broker heartbeat count with the times at which partitions lost in-sync replicas. A matching timestamp gives the team a connection to investigate. Verify which endpoint the broker tried before attributing the delay to a cache.

Set the rule for the next restart

Before maintenance, choose a representative order event and agree how long it may take to reach the fulfilment consumer. During a rehearsal, send uniquely identified test events with the application’s normal acknowledgement and retry settings. Record elapsed time to acknowledgement, final delivery errors and elapsed time to consumption. Reconcile the identifiers afterwards so a late event and a missing event receive different follow-up.

Watch AtMinIsrPartitionCount as well as UnderMinIsrPartitionCount. At the minimum, the affected partition has no spare in-sync copy above its write threshold. Before replacing the next broker, check which partitions it hosts and whether they have recovered the expected replica count. Pause if the next step would take one below minimum or if test orders are already missing their deadline.

Choose a change that fits the timeline. If peers keep using an obsolete address, trial a shorter Java cache lifetime and measure DNS query volume alongside delivery times. If connection recovery is prompt but replication takes longer, allow more time between brokers and investigate the slow recovery. A longer roll costs maintenance time. Lowering the minimum ISR changes the durability commitment for acknowledged orders and merits a separate business decision.

Frequently asked questions

Can a partition accept writes at its minimum ISR?

With acks=all, a partition exactly at the configured minimum can still acknowledge writes if its in-sync replicas acknowledge them. The loss of one more in-sync copy takes it below the threshold.

Does an Under-Min-ISR alert count failed orders?

UnderMinIsrPartitionCount counts partitions below their configured threshold. To establish customer impact, match producer delivery outcomes and consumer timestamps to individual order identifiers during that interval.

Should we disable DNS caching before a roll?

First establish whether the affected process kept using an obsolete address. Java’s successful-lookup cache and Kubernetes’ optional node-local cache operate at different points. Test a change to the implicated layer and compare both delivery times and DNS traffic.

← Back to the article library

Start with a conversation

Put your ideas into practice.

Tell us about your business and what you want to improve. We’ll help you find a sensible place to start.

Discuss Your Project