junrao commented on code in PR #17539:
URL: https://github.com/apache/kafka/pull/17539#discussion_r1817193502
##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -1525,6 +1537,24 @@ private Optional<Throwable> acknowledgeCompleteBatch(
return Optional.empty();
}
+ protected void updateLatestFetchOffsetMetadata(LogOffsetMetadata
fetchOffsetMetadata) {
+ lock.writeLock().lock();
+ try {
+ latestFetchOffsetMetadata = fetchOffsetMetadata;
Review Comment:
I was thinking about an alternative approach by maintaining
`latestFetchOffsetMetadata` every time we update `endOffset`. In the common
case, we move `endOffset` to `lastOffset` of an acked batch. The file position
in `latestFetchOffsetMetadata` can just be updated by adding the batch size to
the file position of the previous `latestFetchOffsetMetadata`. This way, in the
common case, we only need to call `readFromLog` once per fetch request, instead
of twice (once for getting `latestFetchOffsetMetadata` and another for getting
the data) in the current approach.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]