apoorvmittal10 commented on code in PR #22740:
URL: https://github.com/apache/kafka/pull/22740#discussion_r4642250003


##########
core/src/test/java/kafka/server/share/DelayedShareFetchTest.java:
##########
@@ -1780,6 +1784,79 @@ public void 
testTryCompleteWithPendingRemoteFetchInFlight() {
         }
     }
 
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testRemoteStorageFetchMaxBytesResizedToRemoteFetchPartitions() 
{

Review Comment:
   The test covers one remote partition out of three. Could we add:
   1. A case with 2 or more remote partitions, asserting the caps are split and 
sum to at most `requestMaxBytes`.
   2. A case where the recomputed value is not larger than the existing cap 
(e.g. small `requestMaxBytes`, or the strategy's case 3), asserting the 
original `RemoteStorageFetchInfo` is returned unchanged. This covers the "never 
lowered" behaviour described in the PR.



##########
core/src/main/java/kafka/server/share/DelayedShareFetch.java:
##########
@@ -1013,11 +1014,19 @@ private void processRemoteFetchOrException(
             topicIdPartition,
             logReadResult.info().fetchOffsetMetadata
         ));
+        // The byte caps in the remote storage fetch info were computed by 
dividing the request budget
+        // across all acquired partitions, but the non-remote partitions have 
since been released without
+        // consuming any of it. Re-distribute the request budget across the 
remote fetch partitions only,
+        // so the remote reads can use the share freed up by the released 
partitions.
+        LinkedHashMap<TopicIdPartition, Integer> resizedMaxBytesMap = 
partitionMaxBytesStrategy.maxBytes(
+            shareFetch.fetchParams().maxBytes, 
remoteStorageFetchInfoMap.keySet(), remoteStorageFetchInfoMap.size());

Review Comment:
   Previously a remote read was capped at `requestMaxBytes / N`, which left 
budget for the local partitions in the compensating read in 
`completeRemoteStorageShareFetchRequest`. With this change a single remote 
partition can now be granted the full `requestMaxBytes`. If it returns that 
much, `readableBytes < maxBytes` is false and the local read is skipped 
entirely, so a single remote partition could keep serving while the released 
local partitions be skipped in every mixed request.
   
   What do you think?



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

Reply via email to