8000 fix(inkless:switch): skip partitions in phase 1 in the consolidated log pruner [KC-878] by giuseppelillo · Pull Request #908 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content

fix(inkless:switch): skip partitions in phase 1 in the consolidated log pruner [KC-878] - #908

Merged
jeqo merged 1 commit into
mainfrom
giuseppelillo/pruner-skip-phase-one
Nov 30, 2026
Merged

jeqo merged 1 commit into
mainfrom
giuseppelillo/pruner-skip-phase-one

Conversation

@giuseppelillo
@giuseppelillo giuseppelillo commented Nov 27, 2026 •
Copy link
Copy Markdown
Contributor

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.

🤖 Generated with Claude Code

@giuseppelillo
giuseppelillo force-pushed the giuseppelillo/pruner-skip-phase-one branch from 7ce3aec to e6b5ccc Compare November 27, 2026 10:49
@giuseppelillo
giuseppelillo changed the base branch from main to giuseppelillo/reject-delete-records-during-switch November 27, 2026 10:49
@giuseppelillo
giuseppelillo requested a balanced review from Copilot November 27, 2026 12:23
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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
giuseppelillo force-pushed the giuseppelillo/pruner-skip-phase-one branch from e6b5ccc to 64fc336 Compare November 27, 2026 12:51
@jeqo
jeqo merged commit ac46047 into main Nov 30, 2026
6 checks passed
@jeqo
jeqo deleted the giuseppelillo/pruner-skip-phase-one branch November 30, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0