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

morningman 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 3334e3f393 [fix](restore) do not set default replication_allocation 
when restore with property reserve_replica = true (#15562)
3334e3f393 is described below

commit 3334e3f393806442228ee1b3d34b1ae58ac5aab2
Author: xueweizhang <[email protected]>
AuthorDate: Mon Feb 6 22:38:03 2023 +0800

    [fix](restore) do not set default replication_allocation when restore with 
property reserve_replica = true (#15562)
    
    Signed-off-by: nextdreamblue <[email protected]>
---
 fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java    | 3 ++-
 fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java    | 5 +++--
 .../src/main/java/org/apache/doris/catalog/TableProperty.java       | 6 ++++--
 .../src/test/java/org/apache/doris/catalog/OlapTableTest.java       | 4 ++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java 
b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
index 9905b5e677..c01aa2b685 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
@@ -672,7 +672,8 @@ public class RestoreJob extends AbstractJob {
                     }
 
                     // Reset properties to correct values.
-                    
remoteOlapTbl.resetPropertiesForRestore(reserveDynamicPartitionEnable, 
replicaAlloc);
+                    
remoteOlapTbl.resetPropertiesForRestore(reserveDynamicPartitionEnable, 
reserveReplica,
+                                                            replicaAlloc);
 
                     // DO NOT set remote table's new name here, cause we will 
still need the origin name later
                     // 
remoteOlapTbl.setName(jobInfo.getAliasByOriginNameIfSet(tblInfo.name));
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 b2333e019a..13c7ae4218 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
@@ -438,9 +438,10 @@ public class OlapTable extends Table {
     /**
      * Reset properties to correct values.
      */
-    public void resetPropertiesForRestore(boolean 
reserveDynamicPartitionEnable, ReplicaAllocation replicaAlloc) {
+    public void resetPropertiesForRestore(boolean 
reserveDynamicPartitionEnable, boolean reserveReplica,
+                                          ReplicaAllocation replicaAlloc) {
         if (tableProperty != null) {
-            
tableProperty.resetPropertiesForRestore(reserveDynamicPartitionEnable, 
replicaAlloc);
+            
tableProperty.resetPropertiesForRestore(reserveDynamicPartitionEnable, 
reserveReplica, replicaAlloc);
         }
         // remove colocate property.
         setColocateGroup(null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
index 6615e65982..a122e004ff 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
@@ -117,7 +117,7 @@ public class TableProperty implements Writable {
      *
      * @return this for chained
      */
-    public TableProperty resetPropertiesForRestore(boolean 
reserveDynamicPartitionEnable,
+    public TableProperty resetPropertiesForRestore(boolean 
reserveDynamicPartitionEnable, boolean reserveReplica,
             ReplicaAllocation replicaAlloc) {
         // disable dynamic partition
         if (properties.containsKey(DynamicPartitionProperty.ENABLE)) {
@@ -126,7 +126,9 @@ public class TableProperty implements Writable {
             }
             executeBuildDynamicProperty();
         }
-        setReplicaAlloc(replicaAlloc);
+        if (!reserveReplica) {
+            setReplicaAlloc(replicaAlloc);
+        }
         return this;
     }
 
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/catalog/OlapTableTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/catalog/OlapTableTest.java
index f547189ff1..340161495d 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/OlapTableTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/OlapTableTest.java
@@ -92,7 +92,7 @@ public class OlapTableTest {
         Assert.assertTrue(olapTable.getDefaultReplicaAllocation() == 
ReplicaAllocation.DEFAULT_ALLOCATION);
 
         ReplicaAllocation replicaAlloc = new ReplicaAllocation((short) 4);
-        olapTable.resetPropertiesForRestore(false, replicaAlloc);
+        olapTable.resetPropertiesForRestore(false, false, replicaAlloc);
         Assert.assertEquals(tableProperty.getProperties(), 
olapTable.getTableProperty().getProperties());
         
Assert.assertFalse(tableProperty.getDynamicPartitionProperty().isExist());
         Assert.assertFalse(olapTable.isColocateTable());
@@ -112,7 +112,7 @@ public class OlapTableTest {
 
         tableProperty = new TableProperty(properties);
         olapTable.setTableProperty(tableProperty);
-        olapTable.resetPropertiesForRestore(false, 
ReplicaAllocation.DEFAULT_ALLOCATION);
+        olapTable.resetPropertiesForRestore(false, false, 
ReplicaAllocation.DEFAULT_ALLOCATION);
 
         Map<String, String> expectedProperties = Maps.newHashMap(properties);
         expectedProperties.put(DynamicPartitionProperty.ENABLE, "false");


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

Reply via email to