morningman commented on a change in pull request #2958: Auto Resume 
RoutineLoadJob
URL: https://github.com/apache/incubator-doris/pull/2958#discussion_r382059620
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/load/routineload/ScheduleRule.java
 ##########
 @@ -0,0 +1,78 @@
+// 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.doris.load.routineload;
+
+import org.apache.doris.catalog.Catalog;
+import org.apache.doris.common.InternalErrorCode;
+import org.apache.doris.system.SystemInfoService;
+
+public class ScheduleRule {
+
+    private static int aliveBeCount(String clusterName) {
+        SystemInfoService systemInfoService = Catalog.getCurrentSystemInfo();
+        return systemInfoService.getClusterBackendIds(clusterName, 
true).size();
+    }
+    /**
+     * 是否开启自动调度
+     * 只针对状态是PAUSED JOB 才需要进行判断 其他都返回false
+     * @param jobRoutine
+     * @return
+     */
+    public static boolean isNeedAutoSchedule(RoutineLoadJob jobRoutine) {
+        if (jobRoutine.state != RoutineLoadJob.JobState.PAUSED) {
+            return false;
+        }
+        if (jobRoutine.autoResumeLock) {//表示只能手动恢复
+            return false;
+        }
+        /**
+         * 这种错误是 BE挂掉才会出现的场景
+         * 增加计数器、恢复锁定功能主要是为了避免无限制的恢复
+         */
+        if (jobRoutine.pauseReason.getCode() == 
InternalErrorCode.REPLICA_FEW_ERR) {
+            int alive =  aliveBeCount(jobRoutine.clusterName);
+            if (alive < jobRoutine.replicationNum) {// be存活个数小于最小副本数
 
 Review comment:
   only `replicationNum` of BE alive is not enough. Consider we have 100 BEs in 
a cluster, only 3 alive is not enough. 
   And the `replicationNum` will because 0 once FE restart or Master changing, 
cause you don't persist it.
   
   I didn't think about how many BE alive would be more suitable. Consider we 
have 100 BEs in a cluster,97 is alive, but the job may still fail because all 
replicas of a table may be on that 3 dead BE.
   
   Maybe we can add a config like `min_alive_be_num_for_auto_resume` ?
   default is 0. And here we judge like: 
   `max(quorum of BE, min_alive_be_num_for_auto_resume)` ?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to