Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Fix #18 duplicate reassignment #106

Merged
merged 7 commits into from
Mar 16, 2019

Conversation

kabochya
Copy link
Contributor

@kabochya kabochya commented Mar 14, 2019

Addressing #18
Duplicate reassignment will happen when multiple outOfSyncReplicas exist and target broker is still least used broker.
Creating the broker queue each time so we don't need to deal with recovering the brokerQueue for next outOfSyncReplica

@kabochya kabochya requested a review from yuyang08 March 14, 2019 23:54
@yuyang08
Copy link
Contributor

could we start with adding a unit test that can reproduce the issue?

@@ -599,9 +599,10 @@ public UnderReplicatedReason getUnderReplicatedReason(String brokerHost,
List<OutOfSyncReplica> outOfSyncReplicas) {
Map<TopicPartition, Integer[]> replicasMap = new HashMap<>();
boolean success = true;

PriorityQueue<KafkaBroker> brokerQueue = kafkaCluster.getBrokerQueue();
Copy link
Contributor

Choose a reason for hiding this comment

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

brokerQueue is used in KafkaCluster.getAlternativeBrokers, and the priority queue ordering invariant is maintained in that method.

for (OutOfSyncReplica oosReplica : outOfSyncReplicas) {
// rebuild broker queue each time to get up-to-date results
brokerQueue = kafkaCluster.getBrokerQueue();
Copy link
Contributor

Choose a reason for hiding this comment

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

kafkaCluster.getBrokerQueue() is an expensive operation. As long as we maintain the priority queue ordering invariant, we do not need to recompute the priority queue for each out of sync replica.

@kabochya
Copy link
Contributor Author

Test added to reproduce issue, updated fix to avoid costly operations.

@yuyang08
Copy link
Contributor

@kabochya Thanks for making the fix!

@yuyang08 yuyang08 merged commit 88b29a8 into pinterest:master Mar 16, 2019
@kabochya kabochya deleted the fix-duplicate-reassignment branch March 17, 2019 07:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants