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

TsukiokaKogane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new dbc4d4eb23b [fix](fe) Fix disk rebalance priority timeout handling 
(#69139)
dbc4d4eb23b is described below

commit dbc4d4eb23b8876d4f29bca1044a46a8a3f1ea07
Author: TsukiokaKogane <[email protected]>
AuthorDate: Wed Oct 21 10:21:56 2026 +0800

    [fix](fe) Fix disk rebalance priority timeout handling (#69139)
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    Related PR: #xxx
    
    Problem Summary:
    
    `ADMIN REBALANCE DISK` calculates priority expiration by adding a
    timeout in seconds directly to a millisecond timestamp, reducing the
    intended 24-hour duration to 86.4 seconds. The expiration check is also
    reversed, removing unexpired priority backends while retaining expired
    ones. Convert the timeout to milliseconds and remove backends only when
    their priority has expired. Add unit test coverage for timeout
    conversion and priority filtering.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [x] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [x] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 .../org/apache/doris/clone/DiskRebalancer.java     |  6 ++--
 .../java/org/apache/doris/clone/Rebalancer.java    |  2 +-
 .../java/org/apache/doris/clone/RebalanceTest.java | 33 +++++++++++++++++++++-
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/clone/DiskRebalancer.java 
b/fe/fe-core/src/main/java/org/apache/doris/clone/DiskRebalancer.java
index 6fc413a861c..ed13a9c86e4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/clone/DiskRebalancer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/clone/DiskRebalancer.java
@@ -65,9 +65,9 @@ public class DiskRebalancer extends Rebalancer {
         List<BackendLoadStatistic> stats = Lists.newArrayList();
         for (BackendLoadStatistic backend : bes) {
             long backendId = backend.getBeId();
-            Long timeoutS = prioBackends.getOrDefault(backendId, 0L);
-            if (timeoutS != 0) {
-                if (timeoutS > System.currentTimeMillis()) {
+            Long expireTimeMs = prioBackends.getOrDefault(backendId, 0L);
+            if (expireTimeMs != 0) {
+                if (expireTimeMs <= System.currentTimeMillis()) {
                     // remove backends from prio if timeout
                     prioBackends.remove(backendId);
                     continue;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/clone/Rebalancer.java 
b/fe/fe-core/src/main/java/org/apache/doris/clone/Rebalancer.java
index f04af1191e4..2227d42df27 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/clone/Rebalancer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/clone/Rebalancer.java
@@ -181,7 +181,7 @@ public abstract class Rebalancer {
     public void addPrioBackends(List<Backend> backends, long timeoutS) {
         long currentTimeMillis = System.currentTimeMillis();
         for (Backend backend : backends) {
-            prioBackends.put(backend.getId(), currentTimeMillis + timeoutS);
+            prioBackends.put(backend.getId(), currentTimeMillis + timeoutS * 
1000L);
         }
     }
 
diff --git a/fe/fe-core/src/test/java/org/apache/doris/clone/RebalanceTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/clone/RebalanceTest.java
index 949658c9d98..4300ae3c785 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/clone/RebalanceTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/clone/RebalanceTest.java
@@ -196,8 +196,16 @@ public class RebalanceTest {
             for (int i = 0; i < 3; i++) {
                 backends.add(RebalancerTestUtil.createBackend(10086 + i, 2048, 
0));
             }
-            rebalancer.addPrioBackends(backends, 1000);
+            long beforeMs = System.currentTimeMillis();
+            rebalancer.addPrioBackends(backends, 86400L);
+            long afterMs = System.currentTimeMillis();
+
             Assertions.assertTrue(rebalancer.hasPrioBackends());
+            for (Backend backend : backends) {
+                long expireTimeMs = 
rebalancer.prioBackends.get(backend.getId());
+                Assertions.assertTrue(expireTimeMs >= beforeMs + 86400000L);
+                Assertions.assertTrue(expireTimeMs <= afterMs + 86400000L);
+            }
         } // CHECKSTYLE IGNORE THIS LINE
 
         // remove
@@ -212,6 +220,29 @@ public class RebalanceTest {
         }
     }
 
+    @Test
+    public void testFilterByPrioBackends() {
+        DiskRebalancer rebalancer = new DiskRebalancer(systemInfoService, 
invertedIndex, null);
+        Backend priorityBackend = RebalancerTestUtil.createBackend(10086L, 
2048, 0);
+        Backend expiredBackend = RebalancerTestUtil.createBackend(10087L, 
2048, 0);
+        rebalancer.addPrioBackends(Lists.newArrayList(priorityBackend, 
expiredBackend), 86400L);
+
+        long priorityExpireTimeMs = 
rebalancer.prioBackends.get(priorityBackend.getId());
+        rebalancer.prioBackends.put(expiredBackend.getId(), 
System.currentTimeMillis() - 86400000L);
+
+        BackendLoadStatistic priority = new BackendLoadStatistic(
+                priorityBackend.getId(), Tag.DEFAULT_BACKEND_TAG, 
systemInfoService, invertedIndex);
+        BackendLoadStatistic expired = new BackendLoadStatistic(
+                expiredBackend.getId(), Tag.DEFAULT_BACKEND_TAG, 
systemInfoService, invertedIndex);
+        BackendLoadStatistic ordinary = new BackendLoadStatistic(
+                10088L, Tag.DEFAULT_BACKEND_TAG, systemInfoService, 
invertedIndex);
+
+        Assertions.assertEquals(Collections.singletonList(priority),
+                rebalancer.filterByPrioBackends(Lists.newArrayList(ordinary, 
expired, priority)));
+        
Assertions.assertEquals(Collections.singletonMap(priorityBackend.getId(), 
priorityExpireTimeMs),
+                rebalancer.prioBackends);
+    }
+
     @Test
     public void testPartitionRebalancer() {
         Configurator.setLevel("org.apache.doris.clone.PartitionRebalancer", 
Level.DEBUG);


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

Reply via email to