Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

KAFKA-20023 Fix kafka-reassign-partitions.sh to handle dead brokers #21222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
m1a2st wants to merge 3 commits into apache:trunk
base: trunk
Choose a base branch
Loading
from m1a2st:KAFKA-20023

Conversation

@m1a2st
Copy link
Collaborator

@m1a2st m1a2st commented Dec 30, 2025
edited by github-actions bot
Loading

We can catch the TimeoutException to avoid cases where the broker
cannot retrieve log directory information.

Test Result:
Broker 4 is alive

./bin/kafka-reassign-partitions.sh --bootstrap-server localhost:19092
--topics-to-move-json-file tmp.json --broker-list "2,3,4" --generate
Current partition replica assignment
{"version":1,"partitions":[{"topic":"test1","partition":0,"replicas":[3,4],"log_dirs":["/tmp/kraft-broker-logs-1","/tmp/kraft-broker-logs-2"]},{"topic":"test1","partition":1,"replicas":[4,2],"log_dirs":["/tmp/kraft-broker-logs-2","/tmp/kraft-broker-logs"]}]}

Broker 4 shutdown

./bin/kafka-reassign-partitions.sh --bootstrap-server localhost:19092
--topics-to-move-json-file tmp.json --broker-list "2,3,4" --generate
Failed to get log dir for test1-0-4:
org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a
node assignment. Call: describeReplicaLogDirs
Failed to get log dir for test1-1-4:
org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a
node assignment. Call: describeReplicaLogDirs
Current partition replica assignment
{"version":1,"partitions":[{"topic":"test1","partition":0,"replicas":[3,4],"log_dirs":["/tmp/kraft-broker-logs-1","any"]},{"topic":"test1","partition":1,"replicas":[4,2],"log_dirs":["any","/tmp/kraft-broker-logs"]}]}
Proposed partition reassignment configuration
{"version":1,"partitions":[{"topic":"test1","partition":0,"replicas":[3,2],"log_dirs":["any","any"]},{"topic":"test1","partition":1,"replicas":[2,3],"log_dirs":["any","any"]}]}

@github-actions github-actions bot added triage PRs from the community tools small Small PRs labels Dec 30, 2025
Copy link
Collaborator Author

m1a2st commented Dec 30, 2025

Gentle ping @chia7712

@m1a2st m1a2st changed the title (削除) KAFKA-20023 Fix kafka-reassign-partitions.sh to handle dead brokers [WIP] (削除ここまで) (追記) KAFKA-20023 Fix kafka-reassign-partitions.sh to handle dead brokers (追記ここまで) Dec 30, 2025
try {
var logDir = entry.getValue().get().getCurrentReplicaLogDir();
return logDir != null ? logDir : "any";
} catch (ExecutionException e) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of this solution because it leads to timeouts, which we want to avoid. Perhaps getReplicaAssignmentForPartitions could return Node instead of Integer? Then we can reuse the Node#isEmpty check to skip fetching directories from offline nodes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chia7712 chia7712 chia7712 left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

small Small PRs tools triage PRs from the community

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /