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


##########
server/src/main/java/org/apache/kafka/server/share/context/ShareSessionContext.java:
##########
@@ -215,6 +212,42 @@ public ShareFetchResponse 
updateAndGenerateResponseData(String groupId, String m
         }
     }
 
+    /**
+     * Re-orders the partitions of the session as per the records returned in 
the response. The subsequent
+     * fetch reads the partitions in the order of the session, hence the 
partitions which returned records
+     * are moved to the end so the partitions which did not return records are 
read first. Among the partitions
+     * which returned records, the partition read first takes the largest 
share of the records, hence they are
+     * appended in the order decided by the {@link PartitionRotateStrategy} so 
the first position rotates.
+     * <p>
+     * The updates are expected in the fetch order of the partitions.
+     *
+     * @param updates The response data for the partitions, in fetch order.
+     */
+    private void updatePartitionOrder(LinkedHashMap<TopicIdPartition, 
ShareFetchResponseData.PartitionData> updates) {

Review Comment:
   `updatePartitionOrder` keeps unserved partitions at the front and rotates 
only the served block left by one, so in the bands where exactly one partition 
goes unserved (or n is odd and two are served) the session locks into a fixed 
cycle in which the middle partitions keep their slots and one partition only 
ever receives the leftover record budget.



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