Repository navigation
fix(inkless:switch): print partitions whose ListOffsets fails in topic switch state [KC-840] - #881
Merged
Merged
Conversation
…c switch state [KC-840] `kafka-topic-switch.sh state` read the offsets with `ListOffsetsResult.all()`, which fails if any partition fails. Between the seal commit and the control plane initialization, `ListOffsets` fails with `UNKNOWN_TOPIC_OR_PARTITION` for such a partition, so the command printed nothing for the topic. That is the case an operator runs `state` for. The command now reads each partition's result separately and prints `unavailable` for an offset that failed. Assisted-by: Claude Sonnet 5.5
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the per-partition offset failure handling change.
No open issues 🎉
What changed in this PR
This PR keeps kafka-topic-switch.sh state useful during classic-to-diskless transitions by showing partition state even when individual offset requests fail.
Changes:
- Reads offset results per partition instead of failing the command when any partition fails.
- Prints
unavailablefor failed or missing offset results. - Adds a regression test confirming that both partitions print when one latest-offset request fails.
| File | Description |
|---|---|
tools/src/test/java/org/apache/kafka/tools/TopicSwitchCommandTest.java |
Tests partial offset failure and continued partition output. |
tools/src/main/java/org/apache/kafka/tools/TopicSwitchCommand.java |
Handles offset failures per partition and formats unavailable offsets. |
Review effort: Balanced
…-840] Assisted-by: Claude Sonnet 5.5
gqmelo
approved these changes
Nov 19, 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 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.
Why
kafka-topic-switch.sh stateread the offsets of every partition withListOffsetsResult.all(), which fails if any partition fails. After the controller commits the seal and until the leader initializes the control plane,ListOffsetsfor the latest offset fails with the retriableUNKNOWN_TOPIC_OR_PARTITION, and on a consolidating topic the earliest offset fails the same way. A partition in that window is the case an operator runsstatefor, and the command printed nothing for the topic.Change
stateCommandreads each partition'sListOffsetsresult separately. If a partition's request fails, its offset prints asunavailableand the other partitions print as before:A partition with no entry in the result also prints
unavailable. It printed-1before.Test plan
testStateCommandListOffsetsFailsForOnePartitiontoTopicSwitchCommandTest. The latest-offset request of partition 1 fails withUnknownTopicOrPartitionException, and the test checks that both partitions print../gradlew :tools:test --tests '*TopicSwitchCommandTest' :tools:checkstyleMain :tools:checkstyleTest: passes.make valereports no changed Inkless-owned prose.🤖 Generated with Claude Code