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

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


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 53323fb65b9 branch-4.0: [fix](cloud) modify some partition 
getVisibleVersion to getCachedVisibleVersion #60072 (#60199)
53323fb65b9 is described below

commit 53323fb65b942dc75edb8fbacc955b5772bd1ddc
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Jan 24 13:04:43 2026 +0800

    branch-4.0: [fix](cloud) modify some partition getVisibleVersion to 
getCachedVisibleVersion #60072 (#60199)
    
    Cherry-picked from #60072
    
    Co-authored-by: meiyi <[email protected]>
---
 .../org/apache/doris/catalog/MetadataViewer.java   |  8 +++-
 .../java/org/apache/doris/catalog/OlapTable.java   |  4 +-
 .../apache/doris/cloud/catalog/CloudReplica.java   | 11 ------
 .../apache/doris/httpv2/rest/RowCountAction.java   |  4 +-
 .../org/apache/doris/qe/cache/PartitionRange.java  | 12 ------
 .../org/apache/doris/qe/cache/RowBatchBuilder.java | 44 ----------------------
 .../apache/doris/statistics/OlapAnalysisTask.java  |  5 ++-
 .../java/org/apache/doris/system/Diagnoser.java    |  4 +-
 8 files changed, 19 insertions(+), 73 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/MetadataViewer.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MetadataViewer.java
index 92ed8841962..f504bbf498c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MetadataViewer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MetadataViewer.java
@@ -75,7 +75,9 @@ public class MetadataViewer {
 
             for (String partName : partitions) {
                 Partition partition = olapTable.getPartition(partName);
-                long visibleVersion = partition.getVisibleVersion();
+                // for local mode, getCachedVisibleVersion return 
visibleVersion.
+                // for cloud mode, the replica version is not updated.
+                long visibleVersion = partition.getCachedVisibleVersion();
                 short replicationNum = olapTable.getPartitionInfo()
                         
.getReplicaAllocation(partition.getId()).getTotalReplicaNum();
 
@@ -180,7 +182,9 @@ public class MetadataViewer {
 
             for (String partName : partitions) {
                 Partition partition = olapTable.getPartition(partName);
-                long visibleVersion = partition.getVisibleVersion();
+                // for local mode, getCachedVisibleVersion return 
visibleVersion.
+                // for cloud mode, the replica version is not updated.
+                long visibleVersion = partition.getCachedVisibleVersion();
                 short replicationNum = olapTable.getPartitionInfo()
                         
.getReplicaAllocation(partition.getId()).getTotalReplicaNum();
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
index 4aac2062ee3..1da1ab08b8d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
@@ -2250,7 +2250,9 @@ public class OlapTable extends Table implements 
MTMVRelatedTableIf, GsonPostProc
     public long proximateRowCount() {
         long totalCount = 0;
         for (Partition partition : getPartitions()) {
-            long version = partition.getVisibleVersion();
+            // for local mode, getCachedVisibleVersion return visibleVersion.
+            // for cloud mode, the replica.checkVersionCatchUp always returns 
true.
+            long version = partition.getCachedVisibleVersion();
             for (MaterializedIndex index : 
partition.getMaterializedIndices(IndexExtState.VISIBLE)) {
                 for (Tablet tablet : index.getTablets()) {
                     long tabletRowCount = 0L;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java
index 68ebfc5bd3a..ea656647c8b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java
@@ -20,7 +20,6 @@ package org.apache.doris.cloud.catalog;
 import org.apache.doris.analysis.UserIdentity;
 import org.apache.doris.catalog.ColocateTableIndex.GroupId;
 import org.apache.doris.catalog.Env;
-import org.apache.doris.catalog.Partition;
 import org.apache.doris.catalog.Replica;
 import org.apache.doris.cloud.proto.Cloud;
 import org.apache.doris.cloud.qe.ComputeGroupException;
@@ -544,16 +543,6 @@ public class CloudReplica extends Replica implements 
GsonPostProcessable {
         // ATTN: expectedVersion is not used here, and 
OlapScanNode.addScanRangeLocations
         // depends this feature to implement snapshot partition version. See 
comments in
         // OlapScanNode.addScanRangeLocations for details.
-        if (ignoreAlter && getState() == ReplicaState.ALTER
-                && getVersion() == Partition.PARTITION_INIT_VERSION) {
-            return true;
-        }
-
-        if (expectedVersion == Partition.PARTITION_INIT_VERSION) {
-            // no data is loaded into this replica, just return true
-            return true;
-        }
-
         return true;
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java
index 4e6179b3af9..6ae3576f6b5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java
@@ -75,7 +75,9 @@ public class RowCountAction extends RestBaseController {
         olapTable.readLock();
         try {
             for (Partition partition : olapTable.getAllPartitions()) {
-                long version = partition.getVisibleVersion();
+                // for local mode, getCachedVisibleVersion return 
visibleVersion.
+                // for cloud mode, the replica.checkVersionCatchUp always 
returns true.
+                long version = partition.getCachedVisibleVersion();
                 for (MaterializedIndex index : 
partition.getMaterializedIndices(IndexExtState.VISIBLE)) {
                     long indexRowCount = 0L;
                     for (Tablet tablet : index.getTablets()) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java
index c3d55e35bd3..7387ce2e67b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/PartitionRange.java
@@ -120,18 +120,6 @@ public class PartitionRange {
             this.fromCache = false;
             this.tooNew = false;
         }
-
-        public void debug() {
-            if (partition != null) {
-                LOG.info("partition id {}, cacheKey {}, version {}, time {}, 
fromCache {}, tooNew {} ",
-                        partitionId, cacheKey.realValue(),
-                        partition.getVisibleVersion(), 
partition.getVisibleVersionTime(),
-                        fromCache, tooNew);
-            } else {
-                LOG.info("partition id {}, cacheKey {}, fromCache {}, tooNew 
{} ", partitionId,
-                        cacheKey.realValue(), fromCache, tooNew);
-            }
-        }
     }
 
     public enum KeyType {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/RowBatchBuilder.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/RowBatchBuilder.java
index 20d9f93efb4..7576c10a5a6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/RowBatchBuilder.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/RowBatchBuilder.java
@@ -154,48 +154,4 @@ public class RowBatchBuilder {
         }
         return key;
     }
-
-    /**
-     * Rowbatch split to Row
-     */
-    public InternalService.PUpdateCacheRequest 
buildPartitionUpdateRequest(String sql) {
-        if (updateRequest == null) {
-            updateRequest = InternalService.PUpdateCacheRequest.newBuilder()
-                    .setSqlKey(CacheProxy.getMd5(sql))
-                    
.setCacheType(InternalService.CacheType.PARTITION_CACHE).build();
-        }
-        HashMap<Long, List<byte[]>> partRowMap = new HashMap<>();
-        List<byte[]> partitionRowList;
-        PartitionRange.PartitionKeyType cacheKey;
-        for (byte[] row : rowList) {
-            cacheKey = getKeyFromRow(row, keyIndex, keyType);
-            if (!cachePartMap.containsKey(cacheKey.realValue())) {
-                LOG.info("cant find partition key {}", cacheKey.realValue());
-                continue;
-            }
-            if (!partRowMap.containsKey(cacheKey.realValue())) {
-                partitionRowList = Lists.newArrayList();
-                partitionRowList.add(row);
-                partRowMap.put(cacheKey.realValue(), partitionRowList);
-            } else {
-                partRowMap.get(cacheKey.realValue()).add(row);
-            }
-        }
-
-        for (HashMap.Entry<Long, List<byte[]>> entry : partRowMap.entrySet()) {
-            Long key = entry.getKey();
-            PartitionRange.PartitionSingle partition = cachePartMap.get(key);
-            partitionRowList = entry.getValue();
-            updateRequest = updateRequest.toBuilder()
-                    .addValues(InternalService.PCacheValue.newBuilder()
-                            .setParam(InternalService.PCacheParam.newBuilder()
-                                    .setPartitionKey(key)
-                                    
.setLastVersion(partition.getPartition().getVisibleVersion())
-                                    
.setLastVersionTime(partition.getPartition().getVisibleVersionTime())
-                                    .build()).setDataSize(dataSize).addAllRows(
-                                    
partitionRowList.stream().map(ByteString::copyFrom)
-                                            
.collect(Collectors.toList()))).build();
-        }
-        return updateRequest;
-    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java
index 2f73ae87382..187eff6d40a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java
@@ -193,7 +193,10 @@ public class OlapAnalysisTask extends BaseAnalysisTask {
             for (int i = 0; i < tabletCounts; i++) {
                 int seekTid = (int) ((i + seek) % ids.size());
                 long tabletId = ids.get(seekTid);
-                long tabletRows = 
materializedIndex.getTablet(tabletId).getMinReplicaRowCount(p.getVisibleVersion());
+                // for local mode, getCachedVisibleVersion return 
visibleVersion.
+                // for cloud mode, the replica.checkVersionCatchUp always 
returns true.
+                long tabletRows = materializedIndex.getTablet(tabletId)
+                        .getMinReplicaRowCount(p.getCachedVisibleVersion());
                 if (tabletRows > MAXIMUM_SAMPLE_ROWS) {
                     LOG.debug("Found one large tablet id {} in table {}, rows 
{}",
                             largeTabletId, tbl.getName(), largeTabletRows);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/Diagnoser.java 
b/fe/fe-core/src/main/java/org/apache/doris/system/Diagnoser.java
index d6f68c6aa0d..46c6abbd18a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/system/Diagnoser.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/system/Diagnoser.java
@@ -114,7 +114,9 @@ public class Diagnoser {
         StringBuilder versionErr = new StringBuilder();
         StringBuilder statusErr = new StringBuilder();
         StringBuilder compactionErr = new StringBuilder();
-        long visibleVersion = partition.getVisibleVersion();
+        // for local mode, getCachedVisibleVersion return visibleVersion.
+        // for cloud mode, the replica version is not updated.
+        long visibleVersion = partition.getCachedVisibleVersion();
         for (Replica replica : replicas) {
             // backend
             do {


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

Reply via email to