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


##########
core/src/main/java/kafka/server/share/DelayedShareFetch.java:
##########
@@ -1041,6 +1050,35 @@ private void processRemoteFetchOrException(
         pendingRemoteFetchesOpt = Optional.of(new 
PendingRemoteFetches(remoteFetches, fetchOffsetMetadataMap));
     }
 
+    /**
+     * Returns a copy of the remote storage fetch info with its byte caps 
raised to newFetchMaxBytes.
+     * The remote read is capped by the minimum of fetchMaxBytes and the 
partition-level maxBytes,
+     * hence both are replaced. The caps are never lowered so that a 
re-distribution can only grant
+     * the remote read more budget than the local read that surfaced it.
+     */
+    private static RemoteStorageFetchInfo maybeResizeRemoteStorageFetchInfo(
+        RemoteStorageFetchInfo remoteStorageFetchInfo,
+        int newFetchMaxBytes
+    ) {
+        if (newFetchMaxBytes <= remoteStorageFetchInfo.fetchMaxBytes()) {
+            return remoteStorageFetchInfo;

Review Comment:
   With three remote partitions and a 1 MiB budget, `UNIFORM` can change its 
random remainder allocation from `[349526,349525,349525]` to 
`[349525,349526,349525]`; this raise-only guard retains caps totaling 1,048,577 
bytes. Remote completion does not trim the combined results, so the response 
can exceed the request budget without an oversized batch. Redistribute only the 
unused budget on top of existing remote caps, and add a multi-remote test where 
the remainder recipient changes.



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