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


##########
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:
   Thanks, agreed. With the full `requestMaxBytes`, a remote partition with a 
backlog could keep crowding out the released local partitions.
   
   I've changed the approach in bc69857. The remote reads no longer get 
`requestMaxBytes` re-split across them. They keep the caps from the log read 
and are only topped up with the part of the budget that is neither already 
allocated to them nor reserved for the released local partitions:
   - A local partition read in this request reserves the bytes it returned.
   - A local partition not read in this request (its fetch offset metadata was 
already cached) reserves its strategy share, since we don't know how much data 
it has.
   
   The top-up never hands out the reserved bytes, so the compensating read in 
`completeRemoteStorageShareFetchRequest` still has room for the local 
partitions. Local partitions that had no data still pass their share to the 
remote reads, which was the point of this PR.
   
   On the question in your review summary: this doesn't prioritize remote over 
local. Local partitions keep their part of the budget, and the remote reads 
only get what's left over. It also fixes the overshoot since the remote caps 
can no longer add up to more than `requestMaxBytes`.



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