clolov commented on code in PR #24034:
URL: https://github.com/apache/kafka/pull/24034#discussion_r4492023392
##########
metadata/src/main/java/org/apache/kafka/metadata/PartitionRegistration.java:
##########
@@ -249,14 +250,16 @@ public PartitionRegistration merge(PartitionChangeRecord
record) {
int[] newAddingReplicas = (record.addingReplicas() == null) ?
addingReplicas : Replicas.toArray(record.addingReplicas());
- int newLeader;
+ int newLeader = (record.leader() == NO_LEADER_CHANGE) ? leader :
record.leader();
int newLeaderEpoch;
- if (record.leader() == NO_LEADER_CHANGE) {
- newLeader = leader;
- newLeaderEpoch = leaderEpoch;
- } else {
- newLeader = record.leader();
+ if (record.leaderEpoch() != NO_LEADER_EPOCH_CHANGE) {
+ // Since version 3, the controller sets the new leader epoch in
the record.
+ newLeaderEpoch = record.leaderEpoch();
Review Comment:
Let's put the check in the controller before committing the record as a
follow-up PR? Otherwise a rejection here means that the record has already been
committed and we can't really recover from this.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]