FrankYang0529 commented on PR #21134:
URL: https://github.com/apache/kafka/pull/21134#issuecomment-3728250102

   @mmatloka I agree with @gaurav-narula. Based on 
https://github.com/apache/kafka/pull/19590, it uses 
`LeaderRecoveryState.RECOVERING` to correct the metric. The 
`LeaderRecoveryState.RECOVERING` is used in two cases.
   1. The election result is unclean. If the leader is in `targetIsr`, the 
result cannot be unclean.
   
https://github.com/apache/kafka/blob/506ff18e8887cf9610489f56f643a081d015394e/metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java#L357-L366
   2. Elect a leader for offline. This will trigger 
`leaderAndIsr.newRecoveringLeaderAndIsr` and get 
`LeaderRecoveryState.RECOVERING`. However, for a new partition you mentioned, 
its state is changed from `NewPartition` to `OnlinePartition`, so it doesn't 
get into this path.
   
https://github.com/apache/kafka/blob/506ff18e8887cf9610489f56f643a081d015394e/core/src/main/scala/kafka/controller/Election.scala#L28-L58
   
   Could you help to cherry-pick 
https://github.com/apache/kafka/commit/3094ce2c202c96c57084e82892df44b1f124c481 
and ignore `electionFromElr`? Thanks.


-- 
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]

Reply via email to