liveBook · Manning

Data loss

As explained in Apache Kafka in Action

Data loss is the unintended destruction or unavailability of stored data.

Data loss is the unintended destruction or unavailability of stored data. In Kafka, it can result from weak acknowledgment settings, insufficient in-sync replicas, or storage failures. section 5.1.2 section 16.1.3

Reduce data-loss risk by combining replication controls with storage safeguards:

  • Set a reasonable min.insync.replicas value; with replication factor 3, a recommended starting point is 2. section 5.1.2
  • Do not assume acks=all prevents loss when only one replica remains in sync; in that case, it behaves like acks=1. section 5.1.2
  • Monitor disk capacity and stop Kafka before volumes become full, especially when the stored data is important. section 16.1.3
  • Replace failed disks and allow the broker to replicate their data from the respective leaders until it rejoins the in-sync replicas. section 16.1.3

Testing insufficient replicas

Create a topic with replication factor 3 and min.insync.replicas=2, stop two brokers, and inspect the topic. Only one ISR remains; producing with acks=all then fails with NOT_ENOUGH_REPLICAS instead of accepting the message. section 5.1.2

$ kafka-topics.sh \
    --create \
    --topic products.prices.changelog.min-isr-2 \
    --replication-factor 3 \
    --partitions 3 \
    --config min.insync.replicas=2 \
    --bootstrap-server localhost:9092

Use the topic-creation command to configure three replicas and require two in-sync replicas before accepting writes. section 5.1.2

How Apache Kafka in Action covers it

How deep it goes
Explains failure mechanisms and operational mitigations, while deferring detailed producer-send behavior.
Examples
Uses stopped brokers, topic descriptions, cola messages, full volumes, failed disks, and NOT_ENOUGH_REPLICAS errors.
What it assumes
Assumes basic Kafka broker and topic familiarity while illustrating acknowledgments, replicas, and storage risks concretely.
What you can do after
Operate/configure Kafka with replication and storage practices that reduce accepted writes and data loss during failures.
How it connects
Connects data loss with acknowledgments, in-sync replicas, replication factor, storage failures, page cache, and disk monitoring.

Also explained in

Compare how 4 books explain data loss →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.