Skip to main content

Module producer_snapshot

Module producer_snapshot 

Source
Expand description

Producer-snapshot selection, validation, replay, and deletion decisions.

The rules are Kafka’s, from three places:

  • LogLoader.load picks the log start the reload runs against, and first calls ProducerStateManager.removeStraySnapshots with the base offset of every local segment.
  • ProducerStateManager.truncateAndReload(logStartOffset, logEndOffset, _) deletes every snapshot outside (logStartOffset, logEndOffset], then loadFromSnapshot loads the newest snapshot that is left.
  • UnifiedLog.rebuildProducerState replays each local segment from max(segment.baseOffset, mapEndOffset, logStartOffset).

Structs§

ProducerReloadRange
The offsets one producer-state reload runs against.
ProducerSnapshotEntryFacts
One decoded producer-state snapshot entry, field for field as Kafka’s ProducerStateManager snapshot schema (version 1) lays it out, minus the timestamp, which no validity rule reads.

Functions§

producer_snapshot_entry_valid
Validate one decoded producer entry against its snapshot’s exclusive offset boundary: the result is snapshot_entry_valid_model.
producer_snapshot_latest_index
Return the index of the newest snapshot a reload keeps, as Kafka’s loadFromSnapshot loads latestSnapshotFile() after truncateAndReload deleted every snapshot outside (log_start, log_end].
producer_snapshot_reload_keeps
Keep a snapshot through a reload exactly when Kafka’s truncateAndReload keeps it: when it lies in (log_start, log_end].
producer_snapshot_reload_log_start
Pick the log start a producer-state reload runs against, as Kafka’s LogLoader.load does.
producer_snapshot_replay_start
Select the replay cursor after a reload loaded snapshot, or none.
producer_snapshot_stray
Delete the snapshot at snapshots[index] exactly when Kafka’s removeStraySnapshots deletes it, given every local segment’s base offset. The snapshot offsets must be distinct; their order is irrelevant.
producer_snapshot_strays
Classify all producer snapshots using their on-disk offset order.