[ https://issues.apache.org/jira/browse/KAFKA-763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13601278#comment-13601278 ]
Neha Narkhede commented on KAFKA-763: ------------------------------------- Sorry for coming late to the review. Two suggestions - 1. In handleOffsetOutOfRange(), we are using an ordinary consumer id to fetch the log end offset from the leader. That will just fetch the hw, but we should be fetching the log end offset. 2. It is a good idea to avoid using return statements to exit from scala functions, if possible. It breaks the functional programming paradigm. What you can do here is - if (leaderEndOffset < log.logEndOffset) { log.truncateTo(leaderEndOffset) leaderEndOffset } else { val leaderStartOffset = simpleConsumer.earliestOrLatestOffset(topicAndPartition, OffsetRequest.EarliestTime, brokerConfig.brokerId) log.truncateAndStartWithNewOffset(leaderStartOffset) leaderStartOffset } > Add an option to replica from the largest offset during unclean leader > election > ------------------------------------------------------------------------------- > > Key: KAFKA-763 > URL: https://issues.apache.org/jira/browse/KAFKA-763 > Project: Kafka > Issue Type: Improvement > Components: core > Affects Versions: 0.8 > Reporter: Jun Rao > Assignee: Swapnil Ghike > Priority: Blocker > Labels: kafka-0.8, p2 > Fix For: 0.8 > > Attachments: kafka-763-new-v1.patch, kafka-763-new-v2.patch, > kafka-763_v1.patch > > > If there is an unclean leader election, a follower may have an offset out of > the range of the leader. Currently, the follower will delete all its data and > refetch from the smallest offset of the leader. It would be useful to add an > option to let the follower refetch from the largest offset of the leader > since refetching from the smallest offset may take some time. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira