junrao commented on code in PR #17739:
URL: https://github.com/apache/kafka/pull/17739#discussion_r1842631506


##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -1602,8 +1602,6 @@ protected void 
updateFetchOffsetMetadata(Optional<LogOffsetMetadata> fetchOffset
     protected Optional<LogOffsetMetadata> fetchOffsetMetadata() {
         lock.readLock().lock();
         try {
-            if (findNextFetchOffset.get())

Review Comment:
   I was thinking of the following. Each tryComplete always calls 
sharePartition.nextFetchOffset() first. When we get the nextFetchOffset, we 
call fetchOffsetMetadata(nextFetchOffset) to see if the offsetMetadata for 
nextFetchOffset is available. If not, we call readFromLog to get offsetMetadata 
and then call updateFetchOffsetMetadata(fetchOffsetMetadata, nextFetchOffset). 
Inside this method, we cache both inputs. In 
fetchOffsetMetadata(nextFetchOffset), we compare the input with the cached 
nextFetchOffset to determine if the offsetMetadata is available. This covers 
the corner case where the fetch offset is not on the batch boundary too.



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