You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "showuon (via GitHub)" <gi...@apache.org> on 2023/09/07 03:51:32 UTC
[GitHub] [kafka] showuon commented on a diff in pull request #14340: KAFKA-15351: Update log-start-offset after leader election for topics enabled with remote storage
showuon commented on code in PR #14340:
URL: https://github.com/apache/kafka/pull/14340#discussion_r1318052940
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -585,15 +587,25 @@ public void convertToLeader(int leaderEpochVal) {
if (this.leaderEpoch != leaderEpochVal) {
leaderEpoch = leaderEpochVal;
}
- // Reset readOffset, so that it is set in next run of RLMTask
+ // Reset copied and log-start offset, so that it is set in next run of RLMTask
copiedOffsetOption = OptionalLong.empty();
+ logStartOffsetOption = OptionalLong.empty();
}
public void convertToFollower() {
leaderEpoch = -1;
}
- private void maybeUpdateReadOffset(UnifiedLog log) throws RemoteStorageException {
+ private void maybeUpdateLogStartOffset(UnifiedLog log) throws RemoteStorageException {
+ if (!logStartOffsetOption.isPresent()) {
+ logStartOffsetOption = OptionalLong.of(findLogStartOffset(topicIdPartition, log));
+ logStartOffsetOption.ifPresent(offset -> updateRemoteLogStartOffset.accept(topicIdPartition.topicPartition(), offset));
+ logger.info("Found the log start offset: {} for partition: {} after becoming leader, leaderEpoch: {}",
+ logStartOffsetOption, topicIdPartition, leaderEpoch);
Review Comment:
The log is not completely correct. Since the RLMTask will be run periodically, the log start offset update might happen not because of leadership change (ex: record deletion).
--
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