Copilot commented on code in PR #18747:
URL: https://github.com/apache/iotdb/pull/18747#discussion_r4130739495


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/LocalSourceHandle.java:
##########
@@ -306,8 +306,13 @@ public SharedTsBlockQueue getSharedTsBlockQueue() {
 
   @Override
   public void setMaxBytesCanReserve(long maxBytesCanReserve) {
-    // do nothing, the maxBytesCanReserve of SharedTsBlockQueue should be set 
by corresponding
-    // LocalSinkChannel
+    // The source-side Collect quota can be narrower than the upstream 
LocalSinkChannel quota.
+    queue.setMaxBytesCanReserve(maxBytesCanReserve);
+  }
+
+  @Override
+  public void setMemoryReservationGroupId(String reservationPlanNodeId) {
+    queue.setMemoryReservationGroupId(reservationPlanNodeId);

Review Comment:
   Setting only the plan-node key cannot share a quota across local Exchange 
siblings from different fragment instances. `MemoryPool` limits reservations by 
`(queryId, fragmentInstanceId, planNodeId)`, while each `SharedTsBlockQueue` 
retains its upstream fragment ID; therefore identical Collect group IDs still 
create independent limits and can buffer up to the group cap per upstream FI. 
The group API/accounting key needs a common reservation fragment identity for 
all local inputs.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java:
##########
@@ -1181,7 +1181,13 @@ public Operator visitCollect(CollectNode node, 
LocalExecutionPlanContext context
                 context.getNextOperatorId(),
                 node.getPlanNodeId(),
                 CollectOperator.class.getSimpleName());
-    return new CollectOperator(operatorContext, 
dealWithConsumeChildrenOneByOneNode(node, context));
+    CollectQuotaGroup quotaGroup = 
context.enterCollectQuotaGroup(node.getPlanNodeId().getId());
+    try {
+      return new CollectOperator(
+          operatorContext, dealWithConsumeChildrenOneByOneNode(node, context));

Review Comment:
   The quota scope does not capture synthetic local exchanges created by 
`dealWithConsumeChildrenOneByOneNode`. For a non-`ExchangeNode` child at DOP > 
1, that helper creates a `PipelineSourceHandle` and only calls 
`addExchangeOperator` (lines 3568-3583), so `registerExchangeSourceHandle` is 
never invoked and the child keeps the legacy per-handle quota instead of 
joining this Collect group. Register the synthetic source handle while this 
scope is active.



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