Skip to content

KAFKA-20932: Track replaced remote log segments as unreferenced - #23148

Open
Gimini-3 wants to merge 1 commit into
apache:trunkfrom
Gimini-3:KAFKA-20932-track-replaced-remote-segments
Open

KAFKA-20932: Track replaced remote log segments as unreferenced#23148
Gimini-3 wants to merge 1 commit into
apache:trunkfrom
Gimini-3:KAFKA-20932-track-replaced-remote-segments

Conversation

@Gimini-3

Copy link
Copy Markdown
Contributor

RemoteLogLeaderEpochState could drop an existing segment from both the referenced offset map and the unreferenced set when a later overlapping segment reused its start offset while a higher tail segment remained.

The global highestLogOffset check prevents the overlap-removal loop from running in this case, and the previous value returned by offsetToId.put was ignored. This left the replaced segment in the partition metadata map but absent from leader-epoch listings used by remote retention cleanup.

This change records a distinct replaced segment as unreferenced and adds a regression test covering:

  • S0 = [0, 100]
  • S1 = [101, 200]
  • S2 = [0, 150]
  • replay of the S2 completion update

Jira: https://issues.apache.org/jira/browse/KAFKA-20932

Testing:

  • ./gradlew :storage:test --tests org.apache.kafka.server.log.remote.metadata.storage.RemoteLogLeaderEpochStateTest
  • ./gradlew :storage:spotlessCheck

The contribution is my original work and I license it to the project under the project's open source license.

@github-actions github-actions Bot added triage PRs from the community storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature small Small PRs labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

small Small PRs storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant