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 e495c9303d2 branch-3.1: [Fix](auto-partition) Fix false positive check 
of max_auto_partition_num #52270 (#52369)
e495c9303d2 is described below

commit e495c9303d216d8d2c129bcb8f2fc28c121f0f53
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jun 27 10:40:27 2025 +0800

    branch-3.1: [Fix](auto-partition) Fix false positive check of 
max_auto_partition_num #52270 (#52369)
    
    Cherry-picked from #52270
    
    Co-authored-by: zclllyybb <[email protected]>
---
 .../apache/doris/service/FrontendServiceImpl.java  | 28 +++++++++++-----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java 
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 4a7def9ce16..92cfe98e535 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -3640,20 +3640,6 @@ public class FrontendServiceImpl implements 
FrontendService.Iface {
             return result;
         }
 
-        // check partition's number limit.
-        int partitionNum = olapTable.getPartitionNum() + 
addPartitionClauseMap.size();
-        if (partitionNum > Config.max_auto_partition_num) {
-            String errorMessage = String.format(
-                    "create partition failed. partition numbers %d will exceed 
limit variable "
-                            + "max_auto_partition_num %d",
-                    partitionNum, Config.max_auto_partition_num);
-            LOG.warn(errorMessage);
-            errorStatus.setErrorMsgs(Lists.newArrayList(errorMessage));
-            result.setStatus(errorStatus);
-            LOG.warn("send create partition error status: {}", result);
-            return result;
-        }
-
         for (AddPartitionClause addPartitionClause : 
addPartitionClauseMap.values()) {
             try {
                 // here maybe check and limit created partitions num
@@ -3668,6 +3654,20 @@ public class FrontendServiceImpl implements 
FrontendService.Iface {
             }
         }
 
+        // check partition's number limit. because partitions in 
addPartitionClauseMap may be duplicated with existing
+        // partitions, which would lead to false positive. so we should check 
the partition number AFTER adding new
+        // partitions using its ACTUAL NUMBER, rather than the sum of existing 
and requested partitions.
+        if (olapTable.getPartitionNum() > Config.max_auto_partition_num) {
+            String errorMessage = String.format(
+                    "partition numbers %d exceeded limit of variable 
max_auto_partition_num %d",
+                    olapTable.getPartitionNum(), 
Config.max_auto_partition_num);
+            LOG.warn(errorMessage);
+            errorStatus.setErrorMsgs(Lists.newArrayList(errorMessage));
+            result.setStatus(errorStatus);
+            LOG.warn("send create partition error status: {}", result);
+            return result;
+        }
+
         // build partition & tablets
         List<TOlapTablePartition> partitions = Lists.newArrayList();
         List<TTabletLocation> tablets = Lists.newArrayList();


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

Reply via email to