hachikuji commented on code in PR #14141:
URL: https://github.com/apache/kafka/pull/14141#discussion_r1287800658


##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -984,11 +991,16 @@ private CompletableFuture<FetchResponseData> 
handleFetchRequest(
                 Throwable cause = exception instanceof ExecutionException ?
                     exception.getCause() : exception;
 
-                // If the fetch timed out in purgatory, it means no new data 
is available,
-                // and we will complete the fetch successfully. Otherwise, if 
there was
-                // any other error, we need to return it.
                 Errors error = Errors.forException(cause);
-                if (error != Errors.REQUEST_TIMED_OUT) {
+                if (error == Errors.REQUEST_TIMED_OUT) {
+                    // Note that for this case the calling thread is the 
expiration service thread and not the
+                    // polling thread.
+                    //
+                    // If the fetch request timed out in purgatory, it means 
no new data is available,
+                    // just return the original fetch response.
+                    return response;

Review Comment:
   This is probably the simplest fix for now. An alternative might be to use 
the callback to put an event on the queue that could be handled in the event 
loop. 



##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -1039,6 +1054,14 @@ private FetchResponseData tryCompleteFetchRequest(
         }
     }
 
+    private static boolean 
isPartitionTruncated(FetchResponseData.PartitionData partitionResponseData) {
+        FetchResponseData.EpochEndOffset divergingEpoch = 
partitionResponseData.divergingEpoch();
+        FetchResponseData.SnapshotId snapshotId = 
partitionResponseData.snapshotId();
+
+        return divergingEpoch.epoch() != -1 || divergingEpoch.endOffset() != 
-1 ||

Review Comment:
   nit: maybe it's just me, but it seems more intuitive to separate the 
diverging epoch and snapshot id checks.



-- 
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-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to