Skip to main content

checkpoint_id_retained

Function checkpoint_id_retained 

Source
pub fn checkpoint_id_retained(
    candidate_end: i64,
    candidate_epoch: i32,
    selected_end: i64,
    selected_epoch: i32,
    previous_end: i64,
    previous_epoch: i32,
) -> bool
Expand description

Retain a checkpoint whose full (end offset, epoch) id equals either of two given ids, and nothing else: no partial match of either survives.

That the two ids are the newest and the runner-up is a host fact, not part of this contract: recent_checkpoint_ids in the controller picks them with latest_checkpoint_index, applied twice.

Kafka keeps the previous checkpoint alive purely through retention (KafkaMetadataLog.cleanSnapshots never deletes the latest snapshot and expires older ones only under the metadata retention caps), which is what lets a follower whose FetchSnapshot is mid-flight finish the id it started on when the leader rolls to a newer one. There is no reference count: the host passes the runner-up id as previous, and for a directory holding a single checkpoint it passes the selected id as both.