Restore Internals: The Checkpoint File
Linked from Fault Recovery via Changelog
Where Restore Starts: The Checkpoint File
Step 2 glosses over the obvious question — how does the instance know where to start reading? Not from a committed offset in Kafka. From a plain text file sitting next to the state directory it describes:
state.dir/<application.id>/<task_id>/.checkpoint
counts-changelog 7 184203
└── topic │ └─ state is restored up to this offset
└─ partitionOn initialization the task reads that file and seeks the restore consumer straight to 184203. No file, or an unreadable one, means seek to the beginning and replay everything. That is the entire mechanism — no coordinator, no __consumer_offsets entry.
Why a local file and not a Kafka offset. This looks like a wart until you see the constraint. The restore position means "my local RocksDB contains everything up to here" — a statement that is only true on one specific disk. Store it in Kafka, let the task move to a different machine, and the new instance would read "restored to 184203," seek there, and skip 184,203 records it does not have — silently starting with a state missing most of its keys.
Co-locating the offset with the data it describes makes the two impossible to separate. Lose the disk, lose the checkpoint, do a full replay — exactly the right behavior. Two independent offset systems are in play, and conflating them is the usual confusion:
Input topic (impressions) | Changelog topic | |
|---|---|---|
| Read by | Main consumer, in the consumer group | Restore consumer — no group, manual assign() |
| Position stored in | __consumer_offsets, in Kafka | .checkpoint, on local disk |
| Committed to a broker? | Yes | Never |
| Read when? | Continuously, during processing | Only while restoring |
The restore consumer is a genuinely separate KafkaConsumer, tunable via restore.consumer.*. Because it never joins a group, it never rebalances and never commits.
When restore actually runs. Not only at process startup — on every task (re)initialization:
- Cold start on a new machine → full replay
- Warm restart with a valid checkpoint → replay only the tail
- Any rebalance that moves the task here → restore before processing resumes
- A task closed dirty and reinitialized → restore
- Standby replicas restore continuously — that is their whole job; they never stop
But for a running active task the intuition holds: it only writes to the changelog. Every read comes from RocksDB. The changelog is write-only on the hot path.
The checkpoint also advances during a long restore, roughly every 10,000 records of progress — so a crash 40 GB into a 50 GB rebuild resumes near 40 GB instead of starting over. During normal processing it is refreshed at each commit (step 4 of the commit cycle), which is what makes a clean restart cheap.