ankitsultana commented on code in PR #9808:
URL: https://github.com/apache/pinot/pull/9808#discussion_r1034178740


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/MultiStageStrictReplicaGroupSelector.java:
##########
@@ -0,0 +1,150 @@
+/**
+ * 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.broker.routing.instanceselector;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Nullable;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import 
org.apache.pinot.broker.routing.adaptiveserverselector.AdaptiveServerSelector;
+import org.apache.pinot.common.assignment.InstancePartitions;
+import org.apache.pinot.common.assignment.InstancePartitionsUtils;
+import org.apache.pinot.common.metrics.BrokerMetrics;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.config.table.assignment.InstancePartitionsType;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Instance selector for multi-stage queries which can ensure that Colocated 
Tables always leverage Colocated Join
+ * whenever possible. To achieve this, this instance-selector uses 
InstancePartitions (IP) to determine replica-groups,
+ * as opposed to IdealState used by other instance-selectors. Moreover, this 
also uses the requestId generated by
+ * Pinot broker to determine the replica-group picked for each table involved 
in the query, as opposed to using a
+ * member variable. There may be scenarios where an instance in the chosen 
replica-group is down. In that case, this
+ * strategy will try to pick another replica-group. For realtime tables, this 
strategy uses only CONSUMING partitions.

Review Comment:
   `requestId` is the ID created by the Broker for the entire query. We use 
that to determine which replica-group to pick for all tables. That ensures that 
the same replica-group is picked for all tables involved in the join.
   
   In context of colocated joins, we will have multiple tables with the same 
instance partitions. In the happy path, requestId will be used to select the 
replica-group and we'll select the same set of servers for each table involved.
   
   When an instance in a replica-group is down or a few segments are in a bad 
state for a table in one of the replicas, we may try to pick another 
replica-group. There are two possibilities in this case:
   
   1. We still end up picking the same replica-group for all tables involved in 
the query. This is because if an instance itself is down, it would impact all 
tables involved, so ideally the next available replica-group should be picked 
for all tables. This means the query would still use colocated joins.
   2. We pick different replica-groups for some of the tables. This would mean 
that the query won't use colocated join but it would still be able to run.
   
   I think it may also make sense to instead fail the query since technically 
we weren't able to guarantee that the same replica-group would be used for the 
full query. I was thinking of following up on this after running some tests in 
our internal clusters. Hence I marked this feature as Beta for now.



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to