Repository navigation
fix(inkless:switch): skip partitions in phase 1 in the consolidated log pruner [KC-878] - #908
Merged
Merged
Conversation
giuseppelillo
force-pushed
the
giuseppelillo/pruner-skip-phase-one
branch
from
November 27, 2026 10:49
7ce3aec to
e6b5ccc
Compare
giuseppelillo
changed the base branch from
main
to
giuseppelillo/reject-delete-records-during-switch
November 27, 2026 10:49
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change that defers remote retention until phase 2.
No open issues 🎉
What changed in this PR
This PR prevents remote retention from advancing the leader’s log start while followers still serve the local classic prefix during phase 1 of a classic-to-diskless switch.
Changes:
- Skip WAL pruning for partitions in phase 1, while preserving phase 2 pruning.
- Add a regression test for phase 1 when the uploaded classic prefix ends at
seal - 1. - Document why remote retention must wait until phase 2.
| File | Description |
|---|---|
docs/inkless/DISKLESS_CONSOLIDATION.md |
Explain the phase 1 pruning exclusion and retention timing. |
docs/inkless/CLASSIC_TO_DISKLESS_SWITCH.md |
Clarify how pruning gates remote retention during the switch. |
core/src/test/scala/io/aiven/inkless/consolidation/ConsolidatedDisklessLogPrunerTest.scala |
Verify that the pruner skips an uploaded classic prefix in phase 1. |
core/src/main/scala/io/aiven/inkless/consolidation/ConsolidatedDisklessLogPruner.scala |
Exclude partitions whose classic prefix remains local-only according to switch metadata. |
Review effort: Balanced
Base automatically changed from
giuseppelillo/reject-delete-records-during-switch
to
main
November 27, 2026 12:44
…og pruner [KC-878] In phase 1 of the classic-to-diskless switch, remote retention can move the log start of the leader after the leader uploads the classic prefix, if the controller hasn't committed phase 2 yet. The followers keep their log start. With this change `ConsolidatedDisklessLogPruner` skips a partition in phase 1, so remote retention waits for phase 2. ## Problem For a consolidating partition, `RemoteLogManager` doesn't expire remote segments until the control plane stores the remote log start of the partition. The first prune of `ConsolidatedDisklessLogPruner` stores that value. For a switched partition, the pruner sends this prune as soon as remote storage ends at `seal - 1`, and it skips only a partition whose switch is pending. A partition in phase 1 qualifies once the leader uploads the classic prefix. The leader then asks the controller to start phase 2. Until the controller commits that record, the partition stays in phase 1: the followers stopped fetching at the seal and serve the classic prefix from their local logs. If the pruner runs in that window, remote retention deletes the prefix on the leader and moves its log start, and the followers keep theirs. ### Example before this change On a 3-broker cluster, a topic with replicas on brokers 1 and 2 holds 20 records and is sealed at offset 20. `retention.ms` is 1 second and the pruner runs every 2 seconds. The controller is stopped before the leader can upload the prefix, so phase 2 can't commit: 1. 1.5 seconds after remote storage becomes available, the leader has `highestOffsetInRemoteStorage=19`. 2. 6 seconds after, the leader has `logStartOffset=20` and the follower has `logStartOffset=0`. `classicPrefixInRemoteStorage` is false on both brokers. 3. 60 seconds after, the state is the same. ## Fix The pruner skips a partition while `isClassicPrefixOnlyOnLocalDisks` is true, which covers the pending switch and phase 1. Nothing consolidates in phase 1, so the prune that the pruner now skips deletes no diskless batches. The first pruner run in phase 2 stores the remote log start, and remote retention runs from then on. With the change, the same scenario keeps `logStartOffset=0` on both replicas for the 60 seconds of the check. ## Test plan - `ConsolidatedDisklessLogPrunerTest.testRunOmitsSwitchedPartitionInPhaseOneWhenRemotePrefixEndsBeforeSeal` covers a partition in phase 1 whose remote storage ends at `seal - 1`. It fails without the change, because the pruner sends the prune. - `testRunBootstrapsSwitchedPartitionWhenRemotePrefixEndsBeforeSeal` still passes: in phase 2 the same state sends the prune. - On a 3-broker cluster with the controller running, the leader's log start moves from 0 to 20 about 4 seconds after `classicPrefixInRemoteStorage` becomes true, so remote retention still runs in phase 2. - The cluster scenarios ran as temporary tests that stop the controller and watch the replicas for 60 seconds. They aren't part of this change. - `./gradlew :core:checkstyleMain :core:checkstyleTest :core:spotbugsMain :core:test --tests "io.aiven.inkless.consolidation.*" --tests "kafka.server.InklessTopicTypeSwitcherClusterTest"` passes: 166 tests, 0 failures. Assisted-by: Claude Fable 5.2
giuseppelillo
force-pushed
the
giuseppelillo/pruner-skip-phase-one
branch
from
November 27, 2026 12:51
e6b5ccc to
64fc336
Compare
jeqo
approved these changes
Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied
3162
while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In phase 1 of the classic-to-diskless switch, remote retention can move the log start of the leader after the leader uploads the classic prefix, if the controller hasn't committed phase 2 yet. The followers keep their log start. With this change
ConsolidatedDisklessLogPrunerskips a partition in phase 1, so remote retention waits for phase 2.Problem
For a consolidating partition,
RemoteLogManagerdoesn't expire remote segments until the control plane stores the remote log start of the partition. The first prune ofConsolidatedDisklessLogPrunerstores that value. For a switched partition, the pruner sends this prune as soon as remote storage ends atseal - 1, and it skips only a partition whose switch is pending. A partition in phase 1 qualifies once the leader uploads the classic prefix.The leader then asks the controller to start phase 2. Until the controller commits that record, the partition stays in phase 1: the followers stopped fetching at the seal and serve the classic prefix from their local logs. If the pruner runs in that window, remote retention deletes the prefix on the leader and moves its log start, and the followers keep theirs.
Example before this change
On a 3-broker cluster, a topic with replicas on brokers 1 and 2 holds 20 records and is sealed at offset 20.
retention.msis 1 second and the pruner runs every 2 seconds. The controller is stopped before the leader can upload the prefix, so phase 2 can't commit:highestOffsetInRemoteStorage=19.logStartOffset=20and the follower haslogStartOffset=0.classicPrefixInRemoteStorageis false on both brokers.Fix
The pruner skips a partition while
isClassicPrefixOnlyOnLocalDisksis true, which covers the pending switch and phase 1. Nothing consolidates in phase 1, so the prune that the pruner now skips deletes no diskless batches. The first pruner run in phase 2 stores the remote log start, and remote retention runs from then on.With the change, the same scenario keeps
logStartOffset=0on both replicas for the 60 seconds of the check.Test plan
ConsolidatedDisklessLogPrunerTest.testRunOmitsSwitchedPartitionInPhaseOneWhenRemotePrefixEndsBeforeSealcovers a partition in phase 1 whose remote storage ends atseal - 1. It fails without the change, because the pruner sends the prune.testRunBootstrapsSwitchedPartitionWhenRemotePrefixEndsBeforeSealstill passes: in phase 2 the same state sends the prune.classicPrefixInRemoteStoragebecomes true, so remote retention still runs in phase 2../gradlew :core:checkstyleMain :core:checkstyleTest :core:spotbugsMain :core:test --tests "io.aiven.inkless.consolidation.*" --tests "kafka.server.InklessTopicTypeSwitcherClusterTest"passes: 166 tests, 0 failures.🤖 Generated with Claude Code