-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Kafka 7382 - Guarantee atleast one replica of partition be alive during create topic. Kafka 7465 - Fix to add rack unaware partitions using --disable-rack-aware. #5665
base: trunk
Are you sure you want to change the base?
Conversation
val allBrokers = adminZkClient.getBrokerMetadatas() | ||
adminZkClient.validateReplicaAssignment(assignment, assignmentPartition0.size, allBrokers.map(_.id).toSet) | ||
} | ||
validateReplicaAssigment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, we need to handle this in AdminManager also
https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/server/AdminManager.scala#L95
maybe we can push this validation to createOrUpdateTopicPartitionAssignmentPathInZK method, which will be used both AdminManager, TopicCommand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this piece of code inside createOrUpdateTopicPartitionAssignmentPathInZK is leading to ~30 test fails. Fixing them. Hope that should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omkreddy Handling the code in createOrUpdateTopicPartitionAssignmentPathInZK is little tricky and will lead to serious issues:
- Topic Creation - Works fine.
- Add Partitions - Fails. Let's say a topic is created with 1 partition(replicas being 0,1) and let's say broker 0 goes down after creation. Now if I have to add partitions, alterTopic() internally calls createOrUpdateTopicPartitionAssignmentPathInZK and since the existing partition 0 doesn't have all the brokers up, it fails the add partitions functionality. So it's better we handle it outside the createOrUpdateTopicPartitionAssignmentPathInZK.
- Topic Deletion - Works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sumannewton may be we can call validateReplicaAssigment, only if update flag is false here: https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/zk/AdminZkClient.scala#L96
We should try to avoid code duplication between AdminManager, TopicCommand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed @omkreddy . Even I had the same solution.
@omkreddy Also replacing
with
makes sense. |
2. Atleast one replica should be available for topic creation 3. PreferredReplicaElectionCommandTest.testBasicPreferredReplicaElection: Reassign the partition before preferred replica election 4. ReassignPartitionsCommandTest.testResumePartitionReassignmentThatWasCompleted: Start brokers before topic creation 5. TopicCommandTest: Fixed and added more tests. 6. ControllerIntegrationTest.testControlledShutdown: replica assignment should always start from partition 0.
@omkreddy @cmccabe @rajinisivaram @vvcephei @mjsax Addressed review comments. |
Any update on this? |
@sumannewton currently replica assignment validation is different for topic creation and partition addition. With current patch, we are trying to unify both code paths. This will change the addPartitons behavior also. I am fine with the change, but we need to get committer approval for the approach. Let us wait for others comments. |
retest this please |
@sumannewton #5812 PR did some cleanups to AdminZkClient. Can you rebase the PR? Also can you raise separate PRs for Kafka-7382 and KAFKA-7465. |
@omkreddy #5812 PR isn't merged yet. Once that is done, then I can rebase PR. KAFKA-7465 needs fixes of KAFKA-7382 for tests to run. If not, they will require another PR to merge the conflicts and make the tests run pass. |
Fixed KAFKA-7382
Validate that the replica assignment provided during topic creation doesn't include brokers(broker ids) that are not registered to the kafka cluster
Reuse the method AdminZkClient.validateReplicaAssignment() by making it public. (Hope changing the modifier shouldn't be a problem)
Fixed KAFKA-7465
Fix to add rack unaware partitions using --disable-rack-aware in kafka-topics.sh command.
Maintain consistency in AdminZkClient createTopic/addPartitions methods. Accept rackAwareMode in both-the methods unlike accepting brokers in addPartitions and accepting rackAwareMode in createTopic.
@rajinisivaram @cmccabe @mjsax @vvcephei @hachikuji Review and merge.
Committer Checklist (excluded from commit message)