You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Hangleton (via GitHub)" <gi...@apache.org> on 2023/05/18 10:39:08 UTC

[GitHub] [kafka] Hangleton commented on a diff in pull request #13719: MINOR:Fix illogical log in fetchOffsetAndTruncate method

Hangleton commented on code in PR #13719:
URL: https://github.com/apache/kafka/pull/13719#discussion_r1197663944


##########
core/src/main/scala/kafka/server/AbstractFetcherThread.scala:
##########
@@ -680,12 +680,15 @@ abstract class AbstractFetcherThread(name: String,
        */
       val offsetAndEpoch = leader.fetchEarliestOffset(topicPartition, currentLeaderEpoch)
       val leaderStartOffset = offsetAndEpoch.offset
-      warn(s"Reset fetch offset for partition $topicPartition from $replicaEndOffset to current " +
-        s"leader's start offset $leaderStartOffset")
       val offsetToFetch = Math.max(leaderStartOffset, replicaEndOffset)
+      info(s"Reset fetch offset for partition $topicPartition from $replicaEndOffset to " +
+        s"new fetch offset $offsetToFetch")
       // Only truncate log when current leader's log start offset is greater than follower's log end offset.
-      if (leaderStartOffset > replicaEndOffset)
+      if (leaderStartOffset > replicaEndOffset) {
         truncateFullyAndStartAt(topicPartition, leaderStartOffset)
+        warn(s"Truncate fully and start at leader's start offset $leaderStartOffset for partition $topicPartition " +
+          s"because of local replica logEndOffset $replicaEndOffset smaller than leader's start offset.")

Review Comment:
   nit: maybe "because of local replica" => "because the local replica"?



##########
core/src/main/scala/kafka/server/AbstractFetcherThread.scala:
##########
@@ -680,12 +680,15 @@ abstract class AbstractFetcherThread(name: String,
        */
       val offsetAndEpoch = leader.fetchEarliestOffset(topicPartition, currentLeaderEpoch)
       val leaderStartOffset = offsetAndEpoch.offset
-      warn(s"Reset fetch offset for partition $topicPartition from $replicaEndOffset to current " +
-        s"leader's start offset $leaderStartOffset")
       val offsetToFetch = Math.max(leaderStartOffset, replicaEndOffset)
+      info(s"Reset fetch offset for partition $topicPartition from $replicaEndOffset to " +

Review Comment:
   If `leaderStartOffset <= replicaEndOffset` the fetch offset shouldn't change since it should already be set to `replicaEndOffset` no? In this case should we log it at all?



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