You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by li...@apache.org on 2026/04/08 05:30:55 UTC
(doris) 01/01: [fix](fe) Fix SHOW BACKENDS field order mismatch
This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch fix-backends-field-order
in repository https://gitbox.apache.org/repos/asf/doris.git
commit d21be2b04364fc2a9f23f6e92a6d91e235e547d1
Author: happenlee <ha...@selectdb.com>
AuthorDate: Wed Apr 8 12:27:43 2026 +0800
[fix](fe) Fix SHOW BACKENDS field order mismatch
The output fields of SHOW BACKENDS command were not in the same order as
the BackendsTableValuedFunction.SCHEMA definition, causing field values
to be displayed in wrong columns.
Issue:
- CpuCores showed NodeRole value (mix)
- Memory showed CpuCores value
- NodeRole showed Memory value
Fix:
- Reorder fields in BackendsProcDir.getBackendInfos() to match SCHEMA:
CpuCores -> Memory -> LiveSince -> RunningTasks -> NodeRole
- Synchronize the same fix in MetadataGenerator.backendsMetadataResult()
- Add unit test to verify field order
Test: Unit test added
---
.../apache/doris/common/proc/BackendsProcDir.java | 6 ++--
.../doris/common/proc/BackendsProcDirTest.java | 39 ++++++++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java b/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
index a7c59ec8c37..3f98145793a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
@@ -152,9 +152,6 @@ public class BackendsProcDir implements ProcDirInterface {
// heartbeat failure counter
backendInfo.add(backend.getHeartbeatFailureCounter());
- // node role, show the value only when backend is alive.
- backendInfo.add(backend.isAlive() ? backend.getNodeRoleTag().value : "");
-
// cpu cores
backendInfo.add(String.valueOf(backend.getCputCores()));
@@ -167,6 +164,9 @@ public class BackendsProcDir implements ProcDirInterface {
// runningFragments
backendInfo.add(String.valueOf(backend.getRunningTasks()));
+ // node role, show the value only when backend is alive.
+ backendInfo.add(backend.isAlive() ? backend.getNodeRoleTag().value : "");
+
comparableBackendInfos.add(backendInfo);
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/common/proc/BackendsProcDirTest.java b/fe/fe-core/src/test/java/org/apache/doris/common/proc/BackendsProcDirTest.java
index 7c9f5fdcc6a..dad553ede60 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/proc/BackendsProcDirTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/proc/BackendsProcDirTest.java
@@ -24,6 +24,7 @@ import org.apache.doris.persist.EditLog;
import org.apache.doris.system.Backend;
import org.apache.doris.system.SystemInfoService;
+import com.google.common.collect.Lists;
import mockit.Expectations;
import mockit.Mocked;
import org.junit.After;
@@ -31,6 +32,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import java.util.List;
+
public class BackendsProcDirTest {
private Backend b1;
private Backend b2;
@@ -183,4 +186,40 @@ public class BackendsProcDirTest {
Assert.assertNotNull(result);
Assert.assertTrue(result instanceof BaseProcResult);
}
+
+ @Test
+ public void testBackendInfoFieldOrder() throws AnalysisException {
+ b1.setCpuCores(192);
+ b1.setLastUpdateMs(System.currentTimeMillis());
+ b1.setRunningTasks(10L);
+
+ new Expectations() {
+ {
+ systemInfoService.getAllBackendIds(false);
+ minTimes = 0;
+ result = Lists.newArrayList(1000L);
+
+ systemInfoService.getTabletNumByBackendId(1000L);
+ minTimes = 0;
+ result = 10;
+ }
+ };
+
+ BackendsProcDir dir = new BackendsProcDir(systemInfoService);
+ ProcResult result = dir.fetchResult();
+
+ List<String> columnNames = result.getColumnNames();
+ List<List<String>> rows = result.getRows();
+
+ int cpuCoresIdx = columnNames.indexOf("CpuCores");
+ int memoryIdx = columnNames.indexOf("Memory");
+ int liveSinceIdx = columnNames.indexOf("LiveSince");
+ int runningTasksIdx = columnNames.indexOf("RunningTasks");
+ int nodeRoleIdx = columnNames.indexOf("NodeRole");
+
+ Assert.assertTrue("CpuCores should be before Memory", cpuCoresIdx < memoryIdx);
+ Assert.assertTrue("Memory should be before LiveSince", memoryIdx < liveSinceIdx);
+ Assert.assertTrue("LiveSince should be before RunningTasks", liveSinceIdx < runningTasksIdx);
+ Assert.assertTrue("RunningTasks should be before NodeRole", runningTasksIdx < nodeRoleIdx);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org