[fix](backup) Remove colocate_with property when backing up a table (#9142)

We currently not support backup table with colocation property.
So that we have to remove colocate_with property from a table when backing up.
This commit is contained in:
Mingyu Chen
2022-05-05 20:44:27 +08:00
committed by GitHub
parent 0604ecba17
commit e222a50c42
6 changed files with 21 additions and 5 deletions

View File

@ -507,6 +507,8 @@ public class BackupJob extends AbstractJob {
status = new Status(ErrCode.COMMON_ERROR, "failed to copy table: " + tblName);
return;
}
removeUnsupportProperties(copiedTbl);
copiedTables.add(copiedTbl);
} else if (table.getType() == TableType.VIEW) {
View view = (View) table;
@ -543,6 +545,11 @@ public class BackupJob extends AbstractJob {
backupMeta = new BackupMeta(copiedTables, copiedResources);
}
private void removeUnsupportProperties(OlapTable tbl) {
// We cannot support the colocate attribute because the colocate information is not backed up
// synchronously when backing up.
tbl.setColocateGroup(null);
}
private void waitingAllSnapshotsFinished() {
if (unfinishedTaskIds.isEmpty()) {

View File

@ -424,10 +424,11 @@ public class OlapTable extends Table {
* Reset properties to correct values.
*/
public void resetPropertiesForRestore() {
// disable dynamic partition
if (tableProperty != null) {
tableProperty.resetPropertiesForRestore();
}
// remove colocate property.
setColocateGroup(null);
}
public Status resetIdsForRestore(Catalog catalog, Database db, ReplicaAllocation restoreReplicaAlloc) {

View File

@ -110,6 +110,7 @@ public class TableProperty implements Writable {
* @return this for chained
*/
public TableProperty resetPropertiesForRestore() {
// disable dynamic partition
if (properties.containsKey(DynamicPartitionProperty.ENABLE)) {
properties.put(DynamicPartitionProperty.ENABLE, "false");
executeBuildDynamicProperty();

View File

@ -17,10 +17,6 @@
package org.apache.doris.catalog;
import com.google.common.collect.Maps;
import mockit.Mock;
import mockit.MockUp;
import org.apache.doris.analysis.IndexDef;
import org.apache.doris.catalog.Table.TableType;
import org.apache.doris.common.FeConstants;
@ -28,6 +24,7 @@ import org.apache.doris.common.io.FastByteArrayOutputStream;
import org.apache.doris.common.util.UnitTestUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.junit.Assert;
import org.junit.Test;
@ -38,6 +35,9 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import mockit.Mock;
import mockit.MockUp;
public class OlapTableTest {
@Test
@ -88,10 +88,13 @@ public class OlapTableTest {
OlapTable olapTable = new OlapTable();
olapTable.setTableProperty(tableProperty);
olapTable.setColocateGroup("test_group");
Assert.assertTrue(olapTable.isColocateTable());
olapTable.resetPropertiesForRestore();
Assert.assertEquals(tableProperty.getProperties(), olapTable.getTableProperty().getProperties());
Assert.assertFalse(tableProperty.getDynamicPartitionProperty().isExist());
Assert.assertFalse(olapTable.isColocateTable());
// restore with dynamic partition keys
properties = Maps.newHashMap();