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

yiguolei 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 c0eb139ed60 [fix](catalog recycle bin) table partition meta is error 
if recover partition in some case (#31125)
c0eb139ed60 is described below

commit c0eb139ed60bed6933a3b876266f3886cbf1216e
Author: meiyi <myime...@gmail.com>
AuthorDate: Tue Feb 20 16:28:52 2024 +0800

    [fix](catalog recycle bin) table partition meta is error if recover 
partition in some case (#31125)
---
 .../Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md    |  2 +
 .../Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md    |  2 +
 .../apache/doris/catalog/CatalogRecycleBin.java    | 11 ++--
 .../suites/catalog_recycle_bin_p0/recover.groovy   | 60 ++++++++++++++++++++++
 4 files changed, 69 insertions(+), 6 deletions(-)

diff --git 
a/docs/en/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
 
b/docs/en/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
index c0a7522791d..558443fd05c 100644
--- 
a/docs/en/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
+++ 
b/docs/en/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
@@ -50,6 +50,8 @@ The meaning of each column is as follows:
         TableId:             id of table
         PartitionId:         id of partition
         DropTime:            drop time of meta information
+        DataSize:            the amount of data. If the type is database, this 
value includes the data size of the recycled tables and partitions in the 
database
+        RemoteDataSize:      the amount of data on remote storage(hdfs or 
object storage). If the type is database, this value includes the remote data 
size of the recycled tables and partitions in the database
 ```
 
 ### Example
diff --git 
a/docs/zh-CN/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
 
b/docs/zh-CN/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
index 589da1ec6f1..6b54f4477ac 100644
--- 
a/docs/zh-CN/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
+++ 
b/docs/zh-CN/docs/sql-manual/sql-reference/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md
@@ -54,6 +54,8 @@ SHOW CATALOG RECYCLE BIN [ WHERE NAME [ = "name" | LIKE 
"name_matcher"] ]
         TableId:             table对应的id
         PartitionId:         partition对应的id
         DropTime:            元数据放入回收站的时间
+        DataSize:            数据量. 如果元数据类型是database, 
该值包含了database下在回收站中的所有table和partition的数据量
+        RemoteDataSize:      remote storage(hdfs或对象存储)的数据量. 如果元数据类型是database, 
该值包含了database下在回收站中的所有table和partition的remote storage数据量
 ```
 
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
index d803cde648a..177d4641fc0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
@@ -799,10 +799,9 @@ public class CatalogRecycleBin extends MasterDaemon 
implements Writable {
         }
 
         PartitionInfo partitionInfo = table.getPartitionInfo();
-        Range<PartitionKey> recoverRange = recoverPartitionInfo.getRange();
         PartitionItem recoverItem = null;
         if (partitionInfo.getType() == PartitionType.RANGE) {
-            recoverItem = new RangePartitionItem(recoverRange);
+            recoverItem = new 
RangePartitionItem(recoverPartitionInfo.getRange());
         } else if (partitionInfo.getType() == PartitionType.LIST) {
             recoverItem = recoverPartitionInfo.getListPartitionItem();
         }
@@ -811,18 +810,18 @@ public class CatalogRecycleBin extends MasterDaemon 
implements Writable {
             throw new DdlException("Can not recover partition[" + 
partitionName + "]. Partition item conflict.");
         }
 
-        // recover partition
+        // check if partition name exists
         Partition recoverPartition = recoverPartitionInfo.getPartition();
         
Preconditions.checkState(recoverPartition.getName().equalsIgnoreCase(partitionName));
         if (!Strings.isNullOrEmpty(newPartitionName)) {
             if (table.checkPartitionNameExist(newPartitionName)) {
                 throw new DdlException("Partition name[" + newPartitionName + 
"] is already used");
             }
+            recoverPartition.setName(newPartitionName);
         }
+
+        // recover partition
         table.addPartition(recoverPartition);
-        if (!Strings.isNullOrEmpty(newPartitionName)) {
-            table.renamePartition(partitionName, newPartitionName);
-        }
 
         // recover partition info
         long partitionId = recoverPartition.getId();
diff --git a/regression-test/suites/catalog_recycle_bin_p0/recover.groovy 
b/regression-test/suites/catalog_recycle_bin_p0/recover.groovy
new file mode 100644
index 00000000000..884f12d03bc
--- /dev/null
+++ b/regression-test/suites/catalog_recycle_bin_p0/recover.groovy
@@ -0,0 +1,60 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("recover") {
+    def table = "test_recover"
+
+    // create table and insert data
+    sql """ drop table if exists ${table} """
+    sql """
+    create table ${table} (
+        `id` int(11),
+        `name` varchar(128),
+        `da` date
+    )
+    engine=olap
+    duplicate key(id)
+    partition by range(da)(
+        PARTITION p3 VALUES LESS THAN ('2023-01-01'),
+        PARTITION p4 VALUES LESS THAN ('2024-01-01'),
+        PARTITION p5 VALUES LESS THAN ('2025-01-01')
+    )
+    distributed by hash(id) buckets 2
+    properties(
+        "replication_num"="1",
+        "light_schema_change"="true"
+    );
+    """
+
+    sql """ insert into ${table} values(1, 'a', '2022-01-02'); """
+    sql """ insert into ${table} values(2, 'a', '2023-01-02'); """
+    sql """ insert into ${table} values(3, 'a', '2024-01-02'); """
+
+    // drop partition
+    sql """ ALTER TABLE ${table} DROP PARTITION p3; """
+
+    // add partition with the same name as the dropped partition
+    sql """ alter table ${table} add PARTITION p3 VALUES LESS 
THAN("2026-01-01"); """
+    sql """ insert into ${table} values(4, 'a', '2025-01-02'); """
+    sql """ insert into ${table} PARTITION(p3) values (5, 'a', '2025-01-02'); 
"""
+
+    // recover partition use new name
+    sql """ recover partition p3 as p6 from 
regression_test_catalog_recycle_bin_p0.${table}; """
+
+    // insert into partition p3
+    sql """ insert into ${table} PARTITION(p3) values (6, 'a', '2025-01-02'); 
"""
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to