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/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new d46fc59 Add send_clear_alter_tasks operation
d46fc59 is described below
commit d46fc59cc3d3c57b6ccb716eea61328395d5af4e
Author: Mingyu Chen <[email protected]>
AuthorDate: Wed Oct 9 22:32:48 2019 +0800
Add send_clear_alter_tasks operation
ALTER TABLE tbl SET ("send_clear_alter_tasks" = "true");
---
.../apache/doris/alter/SchemaChangeHandler.java | 34 ++++++++++++++++++++++
.../analysis/ModifyTablePropertiesClause.java | 5 ++++
.../apache/doris/common/util/PropertyAnalyzer.java | 1 +
3 files changed, 40 insertions(+)
diff --git a/fe/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
b/fe/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
index f48e3d2..5cfddd2 100644
--- a/fe/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
+++ b/fe/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
@@ -37,6 +37,7 @@ import
org.apache.doris.catalog.DistributionInfo.DistributionInfoType;
import org.apache.doris.catalog.HashDistributionInfo;
import org.apache.doris.catalog.KeysType;
import org.apache.doris.catalog.MaterializedIndex;
+import org.apache.doris.catalog.MaterializedIndex.IndexExtState;
import org.apache.doris.catalog.MaterializedIndex.IndexState;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.OlapTable.OlapTableState;
@@ -61,6 +62,9 @@ import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.common.util.Util;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.task.AgentBatchTask;
+import org.apache.doris.task.AgentTaskExecutor;
+import org.apache.doris.task.ClearAlterTask;
import org.apache.doris.thrift.TStorageMedium;
import com.google.common.base.Preconditions;
@@ -1305,6 +1309,12 @@ public class SchemaChangeHandler extends AlterHandler {
} else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_DISTRIBUTION_TYPE)) {
Catalog.getCurrentCatalog().convertDistributionType(db,
olapTable);
return;
+ } else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_SEND_CLEAR_ALTER_TASK)) {
+ /*
+ * This is only for fixing bug when upgrading Doris from
0.9.x to 0.10.x.
+ */
+ sendClearAlterTask(db, olapTable);
+ return;
}
}
@@ -1334,6 +1344,30 @@ public class SchemaChangeHandler extends AlterHandler {
createJob(db.getId(), olapTable, indexSchemaMap, propertyMap);
}
+ private void sendClearAlterTask(Database db, OlapTable olapTable) {
+ AgentBatchTask batchTask = new AgentBatchTask();
+ db.readLock();
+ try {
+ for (Partition partition : olapTable.getPartitions()) {
+ for (MaterializedIndex index :
partition.getMaterializedIndices(IndexExtState.VISIBLE)) {
+ int schemaHash =
olapTable.getSchemaHashByIndexId(index.getId());
+ for (Tablet tablet : index.getTablets()) {
+ for (Replica replica : tablet.getReplicas()) {
+ ClearAlterTask alterTask = new
ClearAlterTask(replica.getBackendId(), db.getId(),
+ olapTable.getId(), partition.getId(),
index.getId(), tablet.getId(), schemaHash);
+ batchTask.addTask(alterTask);
+ }
+ }
+ }
+ }
+ } finally {
+ db.readUnlock();
+ }
+
+ AgentTaskExecutor.submit(batchTask);
+ LOG.info("send clear alter task for table {}, number: {}",
olapTable.getName(), batchTask.getTaskNum());
+ }
+
@Override
public void cancel(CancelStmt stmt) throws DdlException {
CancelAlterTableStmt cancelAlterTableStmt = (CancelAlterTableStmt)
stmt;
diff --git
a/fe/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
b/fe/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
index 2cd7d94..b831087 100644
---
a/fe/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
+++
b/fe/src/main/java/org/apache/doris/analysis/ModifyTablePropertiesClause.java
@@ -55,6 +55,11 @@ public class ModifyTablePropertiesClause extends AlterClause
{
if
(!properties.get(PropertyAnalyzer.PROPERTIES_DISTRIBUTION_TYPE).equalsIgnoreCase("hash"))
{
throw new AnalysisException("Can only change distribution type
to HASH");
}
+ } else if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_SEND_CLEAR_ALTER_TASK)) {
+ if
(!properties.get(PropertyAnalyzer.PROPERTIES_SEND_CLEAR_ALTER_TASK).equalsIgnoreCase("true"))
{
+ throw new AnalysisException(
+ "Property " +
PropertyAnalyzer.PROPERTIES_SEND_CLEAR_ALTER_TASK + " should be set to true");
+ }
} else {
throw new AnalysisException("Unknown table property: " +
properties.keySet());
}
diff --git
a/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
b/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
index 0a74a70..440d03e 100644
--- a/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
+++ b/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
@@ -71,6 +71,7 @@ public class PropertyAnalyzer {
public static final String PROPERTIES_TIMEOUT = "timeout";
public static final String PROPERTIES_DISTRIBUTION_TYPE =
"distribution_type";
+ public static final String PROPERTIES_SEND_CLEAR_ALTER_TASK =
"send_clear_alter_tasks";
public static DataProperty analyzeDataProperty(Map<String, String>
properties, DataProperty oldDataProperty)
throws AnalysisException {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]