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

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


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 168863f9c16 branch-3.1: [fix](cloud) Skip tablet report  when 
CloudTabletRebalancer is not inited #56989 (#57393)
168863f9c16 is described below

commit 168863f9c165ff72bff216587814ce5878937033
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Oct 30 14:42:00 2025 +0800

    branch-3.1: [fix](cloud) Skip tablet report  when CloudTabletRebalancer is 
not inited #56989 (#57393)
    
    Cherry-picked from #56989
    
    Co-authored-by: Lijia Liu <[email protected]>
    Co-authored-by: liutang123 <[email protected]>
---
 .../org/apache/doris/cloud/catalog/CloudEnv.java   |  4 ++
 .../doris/cloud/catalog/CloudTabletRebalancer.java |  7 +++
 .../doris/cloud/master/CloudReportHandler.java     |  4 ++
 .../doris/cloud/master/CloudReportHandlerTest.java | 63 ++++++++++++++++++++++
 4 files changed, 78 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudEnv.java 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudEnv.java
index 411ddbe52cf..fa0e7487f02 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudEnv.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudEnv.java
@@ -90,6 +90,10 @@ public class CloudEnv extends Env {
         return this.cloudTabletRebalancer;
     }
 
+    public boolean isRebalancerInited() {
+        return this.cloudTabletRebalancer.isInited();
+    }
+
     public CloudUpgradeMgr getCloudUpgradeMgr() {
         return this.upgradeMgr;
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
index f203148a1b1..1c821558b9a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
@@ -106,6 +106,8 @@ public class CloudTabletRebalancer extends MasterDaemon {
 
     private boolean tableBalanced = true;
 
+    private volatile boolean inited = false;
+
     private LinkedBlockingQueue<Pair<Long, Long>> tabletsMigrateTasks = new 
LinkedBlockingQueue<Pair<Long, Long>>();
 
     private Map<InfightTablet, InfightTask> tabletToInfightTask = new 
HashMap<>();
@@ -264,6 +266,7 @@ public class CloudTabletRebalancer extends MasterDaemon {
         performBalancing();
 
         checkDecommissionState(clusterToBes);
+        inited = true;
         LOG.info("finished to rebalancer. cost: {} ms", 
(System.currentTimeMillis() - start));
     }
 
@@ -1324,4 +1327,8 @@ public class CloudTabletRebalancer extends MasterDaemon {
         }
         return rets;
     }
+
+    public boolean isInited() {
+        return inited;
+    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/master/CloudReportHandler.java
 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/master/CloudReportHandler.java
index 6564bd7d3a5..c25574b8113 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/master/CloudReportHandler.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/master/CloudReportHandler.java
@@ -42,6 +42,10 @@ public class CloudReportHandler extends ReportHandler {
         long start = System.currentTimeMillis();
         LOG.info("backend[{}] have {} tablet(s), {} need deal tablet(s). 
report version: {}",
                 backendId, numTablets, backendTablets.size(), 
backendReportVersion);
+        if (!((CloudEnv) Env.getCurrentEnv()).isRebalancerInited()) {
+            LOG.warn("TabletRebalancer has not been initialized, so skip do 
report for {}", backendId);
+            return;
+        }
         // current be useful
         Set<Long> tabletIdsInFe = ((CloudEnv) 
Env.getCurrentEnv()).getCloudTabletRebalancer()
                 .getSnapshotTabletsInPrimaryAndSecondaryByBeId(backendId);
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/cloud/master/CloudReportHandlerTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/cloud/master/CloudReportHandlerTest.java
new file mode 100644
index 00000000000..5af6d35c5f9
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/cloud/master/CloudReportHandlerTest.java
@@ -0,0 +1,63 @@
+// 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.cloud.master;
+
+import org.apache.doris.catalog.Env;
+import org.apache.doris.cloud.catalog.CloudEnv;
+
+import mockit.Expectations;
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.Mocked;
+import mockit.Verifications;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class CloudReportHandlerTest {
+
+    @Mocked
+    private CloudEnv mockCloudEnv;
+
+    @Test
+    public void testTabletReportWhenTabletRebalancerNotInitialized() {
+        new MockUp<Env>() {
+            @Mock
+            public Env getCurrentEnv() {
+                return mockCloudEnv;
+            }
+        };
+        new Expectations() {
+            {
+                mockCloudEnv.isRebalancerInited();
+                result = false;
+            }
+        };
+
+        CloudReportHandler handler = new CloudReportHandler();
+        handler.tabletReport(1001L, new HashMap<>(), new HashMap<>(), 1L, 10L);
+        // If the tabletRebalancer is not initialized,
+        // the tabletReport should not call mockCloudEnv.getCurrentSystemInfo
+        new Verifications() {
+            {
+                mockCloudEnv.getCurrentSystemInfo();
+                times = 0;
+            }
+        };
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to