You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "klsince (via GitHub)" <gi...@apache.org> on 2023/11/29 23:28:48 UTC

Re: [PR] Extend strictReplicaGroup policy to pick a replica group even if there are unavaliable segments for more availablity [pinot]

klsince commented on code in PR #11847:
URL: https://github.com/apache/pinot/pull/11847#discussion_r1367558654


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/FallbackReplicaGroupInstanceSelector.java:
##########
@@ -0,0 +1,428 @@
+/**
+ * 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 java.time.Clock;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.tuple.Pair;
+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.metrics.BrokerMetrics;
+import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.utils.HashUtil;
+import org.apache.pinot.common.utils.config.QueryOptionsUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This extends the default strictReplicaGroup policy to allow fallback. When using default strictReplicaGroup policy,
+ * if none of replica groups have all segments available in it, all segments are marked as unavailable, which is very
+ * strict and makes queries less available. In this new policy, we allow to fall back to a replica group in that
+ * case, even though the selected replica group might have some segments unavailable. As strictReplicaGroup, all the
+ * remaining available segments are processed in the same replica group.
+ */
+public class FallbackReplicaGroupInstanceSelector extends BaseInstanceSelector {
+  private static final Logger LOGGER = LoggerFactory.getLogger(FallbackReplicaGroupInstanceSelector.class);
+  private final Map<Set<String>, InstanceGroup> _instanceGroups = new HashMap<>();

Review Comment:
   InstanceGroup is a key concept here. It is a set of the replica instances hosting a group of segments, e.g. segment[0-10] are kept on instance[0-2] (i.e. 3 replicas for those segments), then the InstanceGroup is (instance0/1/2) with each instance hosting all segment[0-10].
   
   The major change is to keep available/unavailable segments for every instance in a InstanceGroup, to allow us to dynamically select an instance from the InstanceGroup for its available segments, and report the unavailable segments from the selected instance.



-- 
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-unsubscribe@pinot.apache.org

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


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