This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 7bd04b43d930c222b40d8ca00300d087184b14e3
Author: yujun <yu.jun.re...@gmail.com>
AuthorDate: Wed May 8 14:24:05 2024 +0800

    [fix](tablet schedule) disable schedule need clear running tasks (#34461)
---
 .../org/apache/doris/clone/TabletScheduler.java    | 26 +++++++++++++++-------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/clone/TabletScheduler.java 
b/fe/fe-core/src/main/java/org/apache/doris/clone/TabletScheduler.java
index eebc8cec0fb..094beca0425 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/clone/TabletScheduler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/clone/TabletScheduler.java
@@ -1572,7 +1572,7 @@ public class TabletScheduler extends MasterDaemon {
         releaseTabletCtx(tabletCtx, state, status == Status.UNRECOVERABLE);
 
         // if check immediately, then no need to wait TabletChecker's 20s
-        if (state == TabletSchedCtx.State.FINISHED) {
+        if (state == TabletSchedCtx.State.FINISHED && 
!Config.disable_tablet_scheduler) {
             tryAddAfterFinished(tabletCtx);
         }
     }
@@ -1868,19 +1868,29 @@ public class TabletScheduler extends MasterDaemon {
      */
     public void handleRunningTablets() {
         // 1. remove the tablet ctx if timeout
-        List<TabletSchedCtx> timeoutTablets = Lists.newArrayList();
+        List<TabletSchedCtx> cancelTablets = Lists.newArrayList();
         synchronized (this) {
-            
runningTablets.values().stream().filter(TabletSchedCtx::isTimeout).forEach(timeoutTablets::add);
+            for (TabletSchedCtx tabletCtx : runningTablets.values()) {
+                if (Config.disable_tablet_scheduler) {
+                    tabletCtx.setErrMsg("tablet scheduler is disabled");
+                    cancelTablets.add(tabletCtx);
+                } else if (Config.disable_balance && tabletCtx.getType() == 
Type.BALANCE) {
+                    tabletCtx.setErrMsg("balance is disabled");
+                    cancelTablets.add(tabletCtx);
+                } else if (tabletCtx.isTimeout()) {
+                    tabletCtx.setErrMsg("timeout");
+                    cancelTablets.add(tabletCtx);
+                    stat.counterCloneTaskTimeout.incrementAndGet();
+                }
+            }
         }
 
         // 2. release ctx
-        timeoutTablets.forEach(t -> {
+        cancelTablets.forEach(t -> {
             // Set "resetReplicaState" to true because
-            // the timeout task should also be considered as UNRECOVERABLE,
+            // task should also be considered as UNRECOVERABLE,
             // so need to reset replica state.
-            t.setErrMsg("timeout");
-            finalizeTabletCtx(t, TabletSchedCtx.State.CANCELLED, 
Status.UNRECOVERABLE, "timeout");
-            stat.counterCloneTaskTimeout.incrementAndGet();
+            finalizeTabletCtx(t, TabletSchedCtx.State.CANCELLED, 
Status.UNRECOVERABLE, t.getErrMsg());
         });
     }
 


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

Reply via email to