Skip to content

fix(inkless:switch): print partitions whose ListOffsets fails in topic switch state [KC-840] - #881

Merged
gqmelo merged 2 commits into
mainfrom
claude/bug-kc-840-ba5432
Nov 19, 2026
Merged

gqmelo merged 2 commits into
mainfrom
claude/bug-kc-840-ba5432

Conversation

@giuseppelillo

Copy link
Copy Markdown
Contributor

Why

kafka-topic-switch.sh state read the offsets of every partition with ListOffsetsResult.all(), which fails if any partition fails. After the controller commits the seal and until the leader initializes the control plane, ListOffsets for the latest offset fails with the retriable UNKNOWN_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 runs state for, and the command printed nothing for the topic.

Change

stateCommand reads each partition's ListOffsets result separately. If a partition's request fails, its offset prints as unavailable and the other partitions print as before:

logStartOffset=10 logEndOffset=unavailable

A partition with no entry in the result also prints unavailable. It printed -1 before.

Test plan

  • Added testStateCommandListOffsetsFailsForOnePartition to TopicSwitchCommandTest. The latest-offset request of partition 1 fails with UnknownTopicOrPartitionException, and the test checks that both partitions print.
  • Ran ./gradlew :tools:test --tests '*TopicSwitchCommandTest' :tools:checkstyleMain :tools:checkstyleTest: passes.
  • make vale reports no changed Inkless-owned prose.

🤖 Generated with Claude Code

…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

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

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 unavailable for 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

@giuseppelillo
giuseppelillo requested a review from gqmelo November 19, 2026 10:43
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