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


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorShard.java:
##########
@@ -1037,6 +1038,23 @@ public CoordinatorResult<Void, CoordinatorRecord> 
clearStoredDescriptionTopology
         return 
groupMetadataManager.clearStoredDescriptionTopologyEpoch(groupId, 
expectedStoredEpoch);
     }
 
+    /**
+     * Batched form of {@link #clearStoredDescriptionTopologyEpoch}: emits one 
conditional clear
+     * record per entry in {@code expectedStoredEpochByGroupId} in a single
+     * {@link CoordinatorResult}, so the cycle issues one {@code 
scheduleWriteOperation} per
+     * shard instead of one per group. Groups whose stored epoch no longer 
matches yield no
+     * record (the GMM-level method returns an empty list for those), matching 
the single-group
+     * variant's silent skip.
+     */
+    public CoordinatorResult<Void, CoordinatorRecord> 
clearStoredDescriptionTopologyEpochBatch(
+        Map<String, Integer> expectedStoredEpochByGroupId
+    ) {
+        List<CoordinatorRecord> records = new 
ArrayList<>(expectedStoredEpochByGroupId.size());
+        expectedStoredEpochByGroupId.forEach((groupId, expectedStoredEpoch) ->
+            
records.addAll(groupMetadataManager.clearStoredDescriptionTopologyEpoch(groupId,
 expectedStoredEpoch).records()));
+        return new CoordinatorResult<>(records);

Review Comment:
   `clearStoredDescriptionTopologyEpochBatch` returns `new 
CoordinatorResult<>(records)` which defaults to `isAtomic=true`. Because this 
batched write can include many independent per-group records, keeping it atomic 
increases the risk of `RecordBatchTooLargeException` (atomic writes cannot be 
split across batches) and is inconsistent with other bulk-maintenance writes in 
this shard that explicitly use `isAtomic=false` (e.g. `cleanupGroupMetadata` at 
GroupCoordinatorShard.java:1148 and `onTopicsDeleted` at :1201). Consider 
returning a non-atomic result here so the runtime can split the records across 
multiple batches if needed.



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