-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Added Public API for Preferred/Unclean Leader Election on Topic Partitions #4845
Conversation
Please use plural form of elect leader i.e. elect leaders instead of elect leader. Its all over the changes. Fix those. For example |
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.
First pass of implementation excluding tests and examples.
tests/0080-admin_ut.c
Outdated
rd_kafka_t *rk, | ||
rd_kafka_queue_t *useq, | ||
int with_options, | ||
int etype) { |
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.
Take rd_kafka_ElectionType_t
input directly.
🎉 All Contributor License Agreements have been signed. Ready to merge. |
ea378a6
to
f55f3ec
Compare
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.
Another round of review. Example and Test remaining.
Please add following documentations.
|
Please also ensure there are no memory leaks. |
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.
Another round of review.
src/rdkafka_admin.c
Outdated
result->err = err; | ||
rd_list_init_copy(&result->partitions, partitions); | ||
rd_list_copy_to(&result->partitions, partitions, NULL, NULL); | ||
return result; |
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.
Why are we not using rd_list_copy
directly here?
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.
Almost there with the code and documentation part.
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.
Comments for example.
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 the test
783aaa9
to
71884f5
Compare
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.
Few minor changes.
71884f5
to
004ff33
Compare
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.
LGTM!
Great Work Pratyush!.
3557490
to
b49e0db
Compare
src/rdkafka_admin.c
Outdated
/* Non empty topic_partition_list should be present */ | ||
if (elect_leaders->partitions->cnt == 0) { | ||
rd_kafka_admin_result_fail(rko, RD_KAFKA_RESP_ERR__INVALID_ARG, | ||
"No partitions specified"); | ||
rd_kafka_admin_common_worker_destroy(rk, rko, | ||
rd_true /*destroy*/); | ||
return; | ||
} |
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.
I was going through the Java implementation and figured out that null list is also allowed which will trigger leader election for all the topic partitions. We need to change the code to support this. There maybe multiple places we need to do this change.
Topic Partition is nullable - https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/ElectLeadersRequest.json#L29
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.
Thanks Pratyush, left these comments
bbae851
to
d8f9d83
Compare
d8f9d83
to
50f6d1e
Compare
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.
LGTM, thanks Pratyush!
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.
Great Work Pratyush!
LGTM!.
This PR introduces the public API rd_kafka_ElectLeaders, enabling the execution of Preferred or Unclean leader election for specific topic partitions. Additionally, unit tests are also included.