You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "mannoopj (via GitHub)" <gi...@apache.org> on 2024/05/06 13:20:57 UTC
[PR] John confluent unclean recovery elect leader request [kafka]
mannoopj opened a new pull request, #15876:
URL: https://github.com/apache/kafka/pull/15876
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599223700
##########
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:
##########
@@ -1513,14 +1518,18 @@ ApiError electLeader(String topic, int partitionId, ElectionType electionType,
"No such partition as " + topic + "-" + partitionId);
}
if ((electionType == ElectionType.PREFERRED && partition.hasPreferredLeader())
- || (electionType == ElectionType.UNCLEAN && partition.hasLeader())) {
+ || (electionType == ElectionType.UNCLEAN && partition.hasLeader())
+ || (electionType == ElectionType.DESIGNATED && partition.getLeader() == desiredLeader)) {
return new ApiError(Errors.ELECTION_NOT_NEEDED);
}
PartitionChangeBuilder.Election election = PartitionChangeBuilder.Election.PREFERRED;
if (electionType == ElectionType.UNCLEAN) {
election = PartitionChangeBuilder.Election.UNCLEAN;
}
+ if (electionType == ElectionType.DESIGNATED) {
Review Comment:
It seems like this should be a `switch` statement that handles all the cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15876:
URL: https://github.com/apache/kafka/pull/15876#issuecomment-2780176549
This PR is being marked as stale since it has not had any activity in 90 days. If you
would like to keep this PR alive, please leave a comment asking for a review. If the PR has
merge conflicts, update it with the latest from the base branch.
<p>
If you are having difficulty finding a reviewer, please reach out on the
[mailing list](https://kafka.apache.org/contact).
<p>
If this PR is no longer valid or desired, please feel free to close it. If no activity
occurs in the next 30 days, it will be automatically closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599220577
##########
core/src/main/scala/kafka/controller/KafkaController.scala:
##########
@@ -920,6 +920,7 @@ class KafkaController(val config: KafkaConfig,
* triggered by the admin client
*/
OfflinePartitionLeaderElectionStrategy(allowUnclean = electionTrigger == AdminClientTriggered)
+ case ElectionType.DESIGNATED => throw new RuntimeException("Designated election not supported by KafkaController")
Review Comment:
Something like "in ZK mode" would be more helpful. Also, what is the error passed back to the user?
Why is this not UnsupportedVersionException rather than a generic runtime error?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15876:
URL: https://github.com/apache/kafka/pull/15876#issuecomment-2323747266
This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has merge conflicts, please update it with the latest from trunk (or appropriate release branch) <p> If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599217166
##########
clients/src/main/java/org/apache/kafka/common/TopicPartition.java:
##########
@@ -28,12 +28,19 @@ public final class TopicPartition implements Serializable {
private int hash = 0;
private final int partition;
private final String topic;
+ private int designatedLeader = -1;
Review Comment:
I don't think this change should be in as fundamental a class as TopicPartition. This is used all over the place in Kafka and a change here will impact efficiency (and readability)
Instead, we should create a subclass of this, that AdminClient can use. Then we have to test if the TopicPartition we're passed is one of those (yes, it's messy, but it preserves compatibility).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15876:
URL: https://github.com/apache/kafka/pull/15876#issuecomment-2849835065
This PR has been closed since it has not had any activity in 120 days. If you feel like this
was a mistake, or you would like to continue working on it, please feel free to re-open the
PR and ask for a review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599218840
##########
clients/src/main/resources/common/message/ElectLeadersRequest.json:
##########
@@ -32,7 +32,9 @@
{ "name": "Topic", "type": "string", "versions": "0+", "entityType": "topicName", "mapKey": true,
"about": "The name of a topic." },
{ "name": "Partitions", "type": "[]int32", "versions": "0+",
- "about": "The partitions of this topic whose leader should be elected." }
+ "about": "The partitions of this topic whose leader should be elected." },
+ { "name": "DesiredLeaders", "type": "[]int32", "versions": "3+", "nullableVersions": "3+",
+ "about": "The desired leaders. The entry should match with the entry in Partitions by the index." }
Review Comment:
In the `about`, please specify that this is only for DESIGNATED elections.
Also, please change the name of the field to `designatedLeaders`. We shouldn't mix terminiology -- pick one term, like "designated", and stick with it, rather than having designated / desired / specified all over the place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599223381
##########
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:
##########
@@ -1475,8 +1475,13 @@ ControllerResult<ElectLeadersResponseData> electLeaders(ElectLeadersRequestData
ReplicaElectionResult topicResults =
new ReplicaElectionResult().setTopic(topic.topic());
response.replicaElectionResults().add(topicResults);
- for (int partitionId : topic.partitions()) {
- ApiError error = electLeader(topic.topic(), partitionId, electionType, records);
+ for (int i = 0; i < topic.partitions().size(); i++) {
+ int partitionId = topic.partitions().get(i);
+ int desiredLeader = -1;
+ if(!topic.desiredLeaders().isEmpty()) {
+ desiredLeader = topic.desiredLeaders().get(i);
Review Comment:
We need to handle the case where the array is the wrong size, or has negative numbers in it, or whatever.
Just having an UnknownServerException happen in these cases is not good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599221011
##########
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:
##########
@@ -77,7 +77,11 @@ public enum Election {
/**
* Prefer replicas in the ISR but keep the partition online even if it requires picking a leader that is not in the ISR.
*/
- UNCLEAN
+ UNCLEAN,
+ /**
+ * Perform leader election for designated leader
+ */
+ DESIGNTATED
Review Comment:
fix spelling
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #15876: KIP-966 unclean recovery elect leader request
URL: https://github.com/apache/kafka/pull/15876
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599218098
##########
clients/src/main/java/org/apache/kafka/common/requests/ElectLeadersRequest.java:
##########
@@ -75,6 +76,13 @@ private ElectLeadersRequestData toRequestData(short version) {
data.topicPartitions().add(tps);
}
tps.partitions().add(tp.partition());
+ if (version >= 3) {
Review Comment:
Honestly I find it annoying that this class does this kind of "manual serialization" rather than simply using the generated KRPC classes. Anyway, if we start using a subclass of TopicPartition, then this will change.
##########
clients/src/main/java/org/apache/kafka/common/requests/ElectLeadersRequest.java:
##########
@@ -75,6 +76,13 @@ private ElectLeadersRequestData toRequestData(short version) {
data.topicPartitions().add(tps);
}
tps.partitions().add(tp.partition());
+ if (version >= 3) {
Review Comment:
Honestly I find it annoying that this class does this kind of "manual serialization" rather than simply using the generated KRPC classes. Anyway, if we start using a subclass of TopicPartition, then this will change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599220921
##########
core/src/test/scala/unit/kafka/utils/TestUtils.scala:
##########
@@ -1786,6 +1786,105 @@ object TestUtils extends Logging {
KafkaYammerMetrics.defaultRegistry.removeMetric(metricName)
}
+ def clearYammerMetricsExcept(names: Set[String]): Unit = {
Review Comment:
This seems like a pretty heavy hammer that might cause problems, given that so many tests modify global metrics state. Why do we need this now, when we didn't before?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] John confluent unclean recovery elect leader request [kafka]
Posted by "mannoopj (via GitHub)" <gi...@apache.org>.
mannoopj commented on PR #15876:
URL: https://github.com/apache/kafka/pull/15876#issuecomment-2096185204
WIP
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] John confluent unclean recovery elect leader request [kafka]
Posted by "mannoopj (via GitHub)" <gi...@apache.org>.
mannoopj commented on PR #15876:
URL: https://github.com/apache/kafka/pull/15876#issuecomment-2096008537
WIP
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599222750
##########
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:
##########
@@ -235,10 +245,16 @@ ElectionResult electLeader() {
/**
* Assumes that the election type is Election.PREFERRED
*/
- private ElectionResult electPreferredLeader() {
- int preferredReplica = targetReplicas.get(0);
- if (isValidNewLeader(preferredReplica)) {
- return new ElectionResult(preferredReplica, false);
+ private ElectionResult electPreferredOrDesignatedLeader() {
+ if (election == Election.PREFERRED) {
+ int preferredReplica = targetReplicas.get(0);
+ if (isValidNewLeader(preferredReplica)) {
+ return new ElectionResult(preferredReplica, false);
+ }
+ } else if (election == Election.DESIGNTATED) {
+ if (isValidNewLeader(desiredLeader)) {
+ return new ElectionResult(desiredLeader, false);
+ }
Review Comment:
If the designated leader isn't valid, shouldn't we return an error code rather than falling through? I don't think we want to just elect "whatever" in the case where we couldn't do what the user asked us to do.
On a related note, I don't see the point of having a single function for both elect preferred and elect designated. It seems like we should have separate functions for each?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599218840
##########
clients/src/main/resources/common/message/ElectLeadersRequest.json:
##########
@@ -32,7 +32,9 @@
{ "name": "Topic", "type": "string", "versions": "0+", "entityType": "topicName", "mapKey": true,
"about": "The name of a topic." },
{ "name": "Partitions", "type": "[]int32", "versions": "0+",
- "about": "The partitions of this topic whose leader should be elected." }
+ "about": "The partitions of this topic whose leader should be elected." },
+ { "name": "DesiredLeaders", "type": "[]int32", "versions": "3+", "nullableVersions": "3+",
+ "about": "The desired leaders. The entry should match with the entry in Partitions by the index." }
Review Comment:
Please specify that this is only for DESIGNATED elections. Also, please change the name to `designatedLeaders` (we shouldn't mix terminiology -- pick one term, like "designated", and stick with it, rather than having designated / desired / specified all over the place.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KIP-966 unclean recovery elect leader request [kafka]
Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599220070
##########
clients/src/main/resources/common/message/ElectLeadersRequest.json:
##########
@@ -21,7 +21,7 @@
// Version 1 implements multiple leader election types, as described by KIP-460.
//
// Version 2 is the first flexible version.
Review Comment:
Please add a comment about version 3.
##########
clients/src/main/resources/common/message/ElectLeadersResponse.json:
##########
@@ -20,7 +20,7 @@
// Version 1 adds a top-level error code.
//
// Version 2 is the first flexible version.
Review Comment:
Please add a comment about version 3.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org