You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/05/06 09:20:40 UTC
[incubator-doris] 01/11: [fix](backup) Remove colocate_with property when backing up a table (#9142)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 706e6cda1227218d676eb1dbb496d5f2353140ca
Author: Mingyu Chen <mo...@gmail.com>
AuthorDate: Thu May 5 20:44:27 2022 +0800
[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.
---
.../src/main/java/org/apache/doris/backup/BackupJob.java | 7 +++++++
.../src/main/java/org/apache/doris/catalog/OlapTable.java | 3 ++-
.../src/main/java/org/apache/doris/catalog/TableProperty.java | 1 +
.../src/test/java/org/apache/doris/catalog/OlapTableTest.java | 11 +++++++----
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
index f23177950e..5f07552c79 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
@@ -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()) {
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 0c2c99ad97..29f7faea4a 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
@@ -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) {
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 7c0d6f277e..38d85dc4c1 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
@@ -107,6 +107,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();
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 cc9d7f47f5..2c57fe054d 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
@@ -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();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org