Skip to main content

retain_recent_checkpoints

Function retain_recent_checkpoints 

Source
pub fn retain_recent_checkpoints(dir: &Path)
Expand description

Delete every .checkpoint in dir except the two newest (end_offset, epoch) ids, after the controller’s snapshot+prune or an install. Best-effort: read/remove errors are ignored.

The previous checkpoint stays because a FetchSnapshot reader is chunking a snapshot id byte range by byte range: deleting the id it started on the moment a newer one lands answers its next chunk with SNAPSHOT_NOT_FOUND and sends it back to position 0 against the newer id, which a follower slower than one snapshot interval never escapes. Kafka keeps the previous snapshot the same way, through retention alone rather than by tracking in-flight readers.