Kafka log recovery

A Kafka partition is an ordered sequence of log segments whose offsets, indexes, replicas, and high-watermarks must agree.

Kafka stores partition data in segment files with offset and time indexes and transaction metadata. Startup recovery can validate the newest segment and truncate at the last valid record, which may remove evidence needed for deeper recovery.

Understand the symptom

Record batches carry offsets and checksums; indexes map logical offsets to positions in immutable segments.

WHY

What is happening

An index can often be regenerated from a valid segment, but missing segment bytes cannot. Compacted topics, transactions, replication divergence, and leader epochs affect which record sequence is authoritative.

What you may see

Symptoms that change the recovery path.

01

CorruptRecordException

A batch length, checksum, or record structure is invalid.

02

Index out of range

Offset or time index no longer matches the segment.

03

Replica truncation

Follower and leader logs diverged at an epoch or offset.

04

Broker fails recovery

A partition segment or checkpoint prevents startup.

Protect the source

Actions that can make the situation worse.

01

Startup may truncate data

Clone before restarting brokers.

02

Retention deletes older segments

Freeze time- and size-based cleanup.

03

Reassignment changes replicas

Preserve the original distributed state first.

Do this now

Safe steps before evaluation.

01

Quiesce affected partitions

Stop producers, retention, compaction, and moves.

02

Copy every replica

Keep segment, index, checkpoint, and metadata files.

03

Record cluster state

Save leaders, ISR, epochs, topic IDs, offsets, and configurations.

04

Image unstable disks

Preserve sector errors before repeated broker scans.

NEPFOSYS process

How a data-first evaluation proceeds.

01

Partition timeline

NEPFOSYS correlates replicas, epochs, segments, batches, offsets, and checkpoints.

02

Segment analysis

Valid record batches and recoverable index relationships are mapped from copies.

03

Message validation

Keys, timestamps, transactions, ordering, and consumer priorities are checked.

A clear next step

Preserve the original device before another repair or recovery attempt.

Start a case with the exact symptoms, incident timeline, prior attempts, encryption details, and the files that matter most. NEPFOSYS will route the case to the appropriate DFW intake or nationwide mail-in path.

Start with a case review

Questions, answered

What customers ask before starting.

Can Kafka rebuild a corrupt index?

Often, if the underlying log segment is complete and valid.

Can another replica replace a bad segment?

Yes, when it contains the authoritative complete offset range.

Why stop broker restart loops?

Recovery may repeatedly truncate or alter the affected partition state.

DFW local · Nationwide mail-in

Protect the device. Start with the facts.

Start my recovery case