xiangfu0 commented on code in PR #18791: URL: https://github.com/apache/pinot/pull/18791#discussion_r3466986781
########## pinot-query-planner/src/main/java/org/apache/pinot/query/planner/physical/FragmentType.java: ########## @@ -0,0 +1,81 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.query.planner.physical; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.calcite.rel.RelDistribution; +import org.apache.pinot.query.planner.plannode.MailboxReceiveNode; +import org.apache.pinot.query.planner.plannode.MailboxSendNode; +import org.apache.pinot.query.planner.plannode.PlanNode; + + +/** + * Classifies dispatchable physical-plan fragments that participate in mailbox-based stage execution. + * <p> + * The values describe whether a fragment is a scanning leaf, a leaf reached through singleton exchanges, + * or an intermediate stage. Fragments outside this scope are left unclassified: {@link #classify(PlanNode, + * boolean, Map)} returns {@code null} when the fragment root is not a {@link MailboxSendNode}. + */ +public enum FragmentType { + // Scans a fact table; non-SINGLETON sender + LEAF, + // Dim-table leaf via SINGLETON exchange, with a leaf upstream sender + SINGLETON_LEAF, + // Non-scanning stage (join, agg, sort); timings reflect upstream cascade delays + INTERMEDIATE; + + public static FragmentType classify(PlanNode root, boolean hasScannedTable, + Map<Integer, DispatchablePlanMetadata> metadataMap) { + if (!(root instanceof MailboxSendNode)) { + return null; + } + if (!hasScannedTable) { + return INTERMEDIATE; + } + List<Integer> singletonSenderStageIds = getSingletonReceiveSenderStageIds(root); Review Comment: This classification only looks at `SINGLETON` inputs. A stage that scans a table and also has a `HASH`/`BROADCAST` mailbox receive from a non-leaf stage still returns `LEAF` here, and a stage with both a leaf `SINGLETON` input and any non-leaf input still returns `SINGLETON_LEAF`. `AdaptiveRoutingStageClassification` then trusts/tracks those stages as if they were pure leaves, so the elapsed times from their receive operators include upstream cascade delay and can poison the adaptive-routing EMA for healthy servers. Please downgrade any fragment that has any mailbox receive from a non-leaf sender to `INTERMEDIATE` (or otherwise exclude it from trusted/tracked), and add a regression test for the mixed-input topology. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
