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 87463ee2be..dad2bf3b11 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,7 @@ public class RestoreJob extends AbstractJob { } // Reset properties to correct values. - remoteOlapTbl.resetPropertiesForRestore(reserveDynamicPartitionEnable); + remoteOlapTbl.resetPropertiesForRestore(reserveDynamicPartitionEnable, 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 faf009a1dd..79265f3451 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 @@ -425,9 +425,9 @@ public class OlapTable extends Table { /** * Reset properties to correct values. */ - public void resetPropertiesForRestore(boolean reserveDynamicPartitionEnable) { + public void resetPropertiesForRestore(boolean reserveDynamicPartitionEnable, ReplicaAllocation replicaAlloc) { if (tableProperty != null) { - tableProperty.resetPropertiesForRestore(reserveDynamicPartitionEnable); + tableProperty.resetPropertiesForRestore(reserveDynamicPartitionEnable, 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 2883cf6917..14b518910e 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 @@ -118,7 +118,8 @@ public class TableProperty implements Writable { * * @return this for chained */ - public TableProperty resetPropertiesForRestore(boolean reserveDynamicPartitionEnable) { + public TableProperty resetPropertiesForRestore(boolean reserveDynamicPartitionEnable, + ReplicaAllocation replicaAlloc) { // disable dynamic partition if (properties.containsKey(DynamicPartitionProperty.ENABLE)) { if (!reserveDynamicPartitionEnable) { @@ -126,6 +127,7 @@ public class TableProperty implements Writable { } executeBuildDynamicProperty(); } + 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 c5de47f6e1..871389d6dd 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 @@ -89,11 +89,14 @@ public class OlapTableTest { olapTable.setTableProperty(tableProperty); olapTable.setColocateGroup("test_group"); Assert.assertTrue(olapTable.isColocateTable()); + Assert.assertTrue(olapTable.getDefaultReplicaAllocation() == ReplicaAllocation.DEFAULT_ALLOCATION); - olapTable.resetPropertiesForRestore(false); + ReplicaAllocation replicaAlloc = new ReplicaAllocation((short) 4); + olapTable.resetPropertiesForRestore(false, replicaAlloc); Assert.assertEquals(tableProperty.getProperties(), olapTable.getTableProperty().getProperties()); Assert.assertFalse(tableProperty.getDynamicPartitionProperty().isExist()); Assert.assertFalse(olapTable.isColocateTable()); + Assert.assertEquals((short) 4, olapTable.getDefaultReplicaAllocation().getTotalReplicaNum()); // restore with dynamic partition keys properties = Maps.newHashMap(); @@ -109,12 +112,13 @@ public class OlapTableTest { tableProperty = new TableProperty(properties); olapTable.setTableProperty(tableProperty); - olapTable.resetPropertiesForRestore(false); + olapTable.resetPropertiesForRestore(false, ReplicaAllocation.DEFAULT_ALLOCATION); Map expectedProperties = Maps.newHashMap(properties); expectedProperties.put(DynamicPartitionProperty.ENABLE, "false"); Assert.assertEquals(expectedProperties, olapTable.getTableProperty().getProperties()); Assert.assertTrue(olapTable.getTableProperty().getDynamicPartitionProperty().isExist()); Assert.assertFalse(olapTable.getTableProperty().getDynamicPartitionProperty().getEnable()); + Assert.assertEquals((short) 3, olapTable.getDefaultReplicaAllocation().getTotalReplicaNum()); } }