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

deardeng 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 e75325840cb [fix](cloud) Fix SHOW TABLETS visible version (#68467)
e75325840cb is described below

commit e75325840cb928030f3212a3380dc6b8969b994f
Author: deardeng <[email protected]>
AuthorDate: Thu Oct 8 11:41:01 2026 +0800

    [fix](cloud) Fix SHOW TABLETS visible version (#68467)
    
    Problem Summary: Cloud replicas keep placeholder version fields in FE
    metadata. SHOW TABLETS constructed TabletsProcDir without the partition
    visible version, so it displayed -1 and filtered on the stale replica
    version. Batch-read partition visible versions outside the table
    metadata lock, pass each version through the existing TabletsProcDir
    constructor, and filter on the same displayed version returned to users.
    Enable the existing partitioned and non-partitioned regression case in
    cloud mode and add a focused unit test for version filtering.
    
    ### Release note
    
    Fix SHOW TABLETS to display and filter by the current partition visible
    version in cloud mode.
    
    ### Check List (For Author)
    
    - Test: Unit Test
    - ./run-fe-ut.sh --run
    org.apache.doris.common.proc.CloudProcVersionDisplayTest
    - ./run-fe-ut.sh --run
    
org.apache.doris.nereids.trees.plans.commands.TruncateTableCommandTest#testTruncateTable
    - Cloud regression case enabled but not run because this worktree has no
    running cloud cluster
    - Behavior changed: Yes, cloud SHOW TABLETS now reports and filters by
    partition visible version
    - Does this need documentation: No
---
 .../org/apache/doris/common/proc/TabletsProcDir.java  |  6 +++---
 .../plans/commands/ShowTabletsFromTableCommand.java   | 19 +++++++++++++------
 .../common/proc/CloudProcVersionDisplayTest.java      | 16 ++++++++++++++++
 .../select_tablets/select_with_tablets.groovy         |  5 -----
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/proc/TabletsProcDir.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/proc/TabletsProcDir.java
index 676942d0b1b..3ab4d7f919f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/TabletsProcDir.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/TabletsProcDir.java
@@ -174,13 +174,13 @@ public class TabletsProcDir implements ProcDirInterface {
                     }
                     for (Replica replica : tablet.getReplicas()) {
                         long beId = replica.getBackendIdWithoutException();
-                        if ((version > -1 && replica.getVersion() != version)
+                        long displayVersion = 
ProcReplicaVersionDisplay.getDisplayReplicaVersion(
+                                replica, partitionVisibleVersion);
+                        if ((version > -1 && displayVersion != version)
                                 || (backendId > -1 && beId != backendId)
                                 || (state != null && replica.getState() != 
state)) {
                             continue;
                         }
-                        long displayVersion = 
ProcReplicaVersionDisplay.getDisplayReplicaVersion(
-                                replica, partitionVisibleVersion);
                         long displayLastSuccessVersion = 
ProcReplicaVersionDisplay.getDisplayReplicaLastSuccessVersion(
                                 replica, partitionVisibleVersion);
                         List<Comparable> tabletInfo = new 
ArrayList<Comparable>();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletsFromTableCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletsFromTableCommand.java
index 33535f80300..fb3fb8e37b6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletsFromTableCommand.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletsFromTableCommand.java
@@ -58,7 +58,6 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
 import java.util.Optional;
@@ -228,10 +227,9 @@ public class ShowTabletsFromTableCommand extends 
ShowCommand {
 
         Optional<Integer> sizeLimit = computeSizeLimit(limit, offset);
 
-        List<List<Comparable>> tabletInfos = new ArrayList<>();
+        List<Partition> partitions = new ArrayList<>();
         olapTable.readLock();
         try {
-            Collection<Partition> partitions = new ArrayList<Partition>();
             if (partitionNames != null) {
                 List<String> paNames = partitionNames.getPartitionNames();
                 if (!paNames.isEmpty()) {
@@ -244,8 +242,16 @@ public class ShowTabletsFromTableCommand extends 
ShowCommand {
                     }
                 }
             } else {
-                partitions = olapTable.getPartitions();
+                partitions.addAll(olapTable.getPartitions());
             }
+        } finally {
+            olapTable.readUnlock();
+        }
+
+        List<Long> visibleVersions = limit == 0 ? new ArrayList<>() : 
Partition.getVisibleVersions(partitions);
+        List<List<Comparable>> tabletInfos = new ArrayList<>();
+        olapTable.readLock();
+        try {
             // With an explicit ORDER BY every tablet has to be collected 
before the result can be
             // truncated, otherwise the sort only sees an arbitrary prefix of 
the scan and returns
             // the wrong rows -- the bug reported in #65871. Without ORDER BY 
the scan still stops
@@ -253,12 +259,13 @@ public class ShowTabletsFromTableCommand extends 
ShowCommand {
             // An explicit LIMIT 0 cannot return any row, so nothing has to be 
fetched at all,
             // whether or not an OFFSET was given.
             boolean stop = limit == 0;
-            for (Partition partition : partitions) {
+            for (int i = 0; i < partitions.size(); i++) {
                 if (stop) {
                     break;
                 }
+                Partition partition = partitions.get(i);
                 for (MaterializedIndex index : 
partition.getMaterializedIndices(IndexExtState.ALL, true)) {
-                    TabletsProcDir procDir = new TabletsProcDir(olapTable, 
index);
+                    TabletsProcDir procDir = new TabletsProcDir(olapTable, 
index, visibleVersions.get(i));
                     tabletInfos.addAll(procDir.fetchComparableResult(
                             version, backendId, replicaState));
                     if (orderByPairs == null && sizeLimit.isPresent() && 
tabletInfos.size() >= sizeLimit.get()) {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/common/proc/CloudProcVersionDisplayTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/common/proc/CloudProcVersionDisplayTest.java
index d5e83d7ac59..e5546eb516a 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/common/proc/CloudProcVersionDisplayTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/common/proc/CloudProcVersionDisplayTest.java
@@ -53,6 +53,8 @@ import org.junit.jupiter.api.Test;
 import org.mockito.MockedStatic;
 import org.mockito.Mockito;
 
+import java.util.List;
+
 public class CloudProcVersionDisplayTest {
     private static final long DB_ID = 10001L;
     private static final long TABLE_ID = 20001L;
@@ -120,6 +122,20 @@ public class CloudProcVersionDisplayTest {
         assertVersionColumns(result, PARTITION_VISIBLE_VERSION);
     }
 
+    @Test
+    public void testTabletsProcDirFiltersByDisplayedCloudVersion() throws 
AnalysisException {
+        ProcTestContext context = createProcTestContext();
+        TabletsProcDir procDir = new TabletsProcDir(
+                context.table, context.partition.getBaseIndex(), 
PARTITION_VISIBLE_VERSION);
+
+        List<List<Comparable>> result = 
procDir.fetchComparableResult(PARTITION_VISIBLE_VERSION, -1, null);
+
+        Assertions.assertEquals(1, result.size());
+        Assertions.assertEquals(
+                PARTITION_VISIBLE_VERSION, 
result.get(0).get(TabletsProcDir.TITLE_NAMES.indexOf("Version")));
+        
Assertions.assertTrue(procDir.fetchComparableResult(STALE_REPLICA_VERSION, -1, 
null).isEmpty());
+    }
+
     @Test
     public void testReplicasProcNodeShowsPartitionCachedVersionInCloudMode() 
throws AnalysisException {
         ProcTestContext context = createProcTestContext();
diff --git 
a/regression-test/suites/query_p0/select_tablets/select_with_tablets.groovy 
b/regression-test/suites/query_p0/select_tablets/select_with_tablets.groovy
index db9c2035c3d..987a3b6be9b 100644
--- a/regression-test/suites/query_p0/select_tablets/select_with_tablets.groovy
+++ b/regression-test/suites/query_p0/select_tablets/select_with_tablets.groovy
@@ -16,11 +16,6 @@
 // under the License.
 
 suite("select_with_tablets") {
-    if (isCloudMode()) {
-        return
-    }
-
-
     def table_name1 = "test_table"
     sql """ DROP TABLE IF EXISTS ${table_name1} """
     sql """


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

Reply via email to