Add send_clear_alter_tasks operation
ALTER TABLE tbl SET ("send_clear_alter_tasks" = "true");
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user