w41ter commented on code in PR #43409:
URL: https://github.com/apache/doris/pull/43409#discussion_r1842043620
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java:
##########
Review Comment:
Pick this file is unnecessary
##########
fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java:
##########
@@ -2094,29 +2094,24 @@ private Status allTabletCommitted(boolean isReplay) {
}
private Status dropAllNonRestoredTableAndPartitions(Database db) {
- Set<String> restoredViews = jobInfo.newBackupObjects.views.stream()
- .map(view -> view.name).collect(Collectors.toSet());
-
try {
for (Table table : db.getTables()) {
long tableId = table.getId();
String tableName = table.getName();
TableType tableType = table.getType();
- if (tableType == TableType.OLAP) {
- BackupOlapTableInfo backupTableInfo =
jobInfo.backupOlapTableObjects.get(tableName);
- if (tableType == TableType.OLAP && backupTableInfo !=
null) {
- // drop the non restored partitions.
- dropNonRestoredPartitions(db, (OlapTable) table,
backupTableInfo);
- } else if (isCleanTables) {
- // otherwise drop the entire table.
- LOG.info("drop non restored table {}, table id: {}.
{}", tableName, tableId, this);
- boolean isForceDrop = false; // move this table into
recyclebin.
- env.getInternalCatalog().dropTableWithoutCheck(db,
table, isForceDrop);
- }
- } else if (tableType == TableType.VIEW && isCleanTables &&
!restoredViews.contains(tableName)) {
- LOG.info("drop non restored view {}, table id: {}. {}",
tableName, tableId, this);
- boolean isForceDrop = false; // move this view into
recyclebin.
- env.getInternalCatalog().dropTableWithoutCheck(db, table,
isForceDrop);
+ BackupOlapTableInfo backupTableInfo =
jobInfo.backupOlapTableObjects.get(tableName);
+ if (tableType != TableType.OLAP && tableType != TableType.ODBC
&& tableType != TableType.VIEW) {
+ continue;
+ }
+ if (tableType == TableType.OLAP && backupTableInfo != null) {
+ // drop the non restored partitions.
+ dropNonRestoredPartitions(db, (OlapTable) table,
backupTableInfo);
+ } else if (isCleanTables) {
+ // otherwise drop the entire table.
+ LOG.info("drop non restored table {}({}). {}", tableName,
tableId, this);
+ boolean isView = false;
+ boolean isForceDrop = false; // move this table into
recyclebin.
+ env.getInternalCatalog().dropTableWithoutCheck(db, table,
isView, isForceDrop);
Review Comment:
@wyxxxcat This patch is staled, please update.
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -1044,6 +1044,42 @@ public void replayRecoverTable(RecoverInfo info) throws
MetaNotFoundException, D
}
}
+ public void eraseTableDropBackendReplicas(OlapTable olapTable, boolean
isReplay) {
+ if (isReplay || Env.isCheckpointThread()) {
+ return;
+ }
+
+ // drop all replicas
+ AgentBatchTask batchTask = new AgentBatchTask();
+ for (Partition partition : olapTable.getAllPartitions()) {
+ List<MaterializedIndex> allIndices =
partition.getMaterializedIndices(IndexExtState.ALL);
+ for (MaterializedIndex materializedIndex : allIndices) {
+ long indexId = materializedIndex.getId();
+ int schemaHash = olapTable.getSchemaHashByIndexId(indexId);
+ for (Tablet tablet : materializedIndex.getTablets()) {
+ long tabletId = tablet.getId();
+ List<Replica> replicas = tablet.getReplicas();
+ for (Replica replica : replicas) {
+ long backendId = replica.getBackendId();
+ long replicaId = replica.getId();
+ DropReplicaTask dropTask = new
DropReplicaTask(backendId, tabletId,
+ replicaId, schemaHash, true);
+ batchTask.addTask(dropTask);
+ } // end for replicas
+ } // end for tablets
+ } // end for indices
+ } // end for partitions
+ AgentTaskExecutor.submit(batchTask);
+ }
+
+ public void erasePartitionDropBackendReplicas(List<Partition> partitions) {
+ // no need send be delete task, when be report its tablets, fe will
send delete task then.
+ }
+
+ public void eraseDroppedIndexBackendReplicas(long tableId, List<Long>
indexIdList) {
+ // nothing to do in non cloud mode
+ }
Review Comment:
Remove it
##########
fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java:
##########
@@ -962,6 +968,7 @@ public void
processDropMaterializedView(DropMaterializedViewStmt dropMaterialize
} finally {
olapTable.writeUnlock();
}
+
Env.getCurrentInternalCatalog().eraseDroppedIndexBackendReplicas(olapTable.getId(),
deleteIndexList);
Review Comment:
remove it
##########
fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java:
##########
@@ -931,15 +933,18 @@ public void processBatchDropRollup(List<AlterClause>
dropRollupClauses, Database
long tableId = olapTable.getId();
String tableName = olapTable.getName();
editLog.logBatchDropRollup(new BatchDropInfo(dbId, tableId,
tableName, indexIdSet));
+ deleteIndexList = indexIdSet.stream().collect(Collectors.toList());
LOG.info("finished drop rollup index[{}] in table[{}]",
String.join("", rollupNameSet), olapTable.getName());
} finally {
olapTable.writeUnlock();
}
+
Env.getCurrentInternalCatalog().eraseDroppedIndexBackendReplicas(olapTable.getId(),
deleteIndexList);
}
public void processDropMaterializedView(DropMaterializedViewStmt
dropMaterializedViewStmt, Database db,
OlapTable olapTable) throws DdlException, MetaNotFoundException {
+ List<Long> deleteIndexList = new ArrayList<Long>();
Review Comment:
remove
##########
fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java:
##########
@@ -951,7 +956,8 @@ public void
processDropMaterializedView(DropMaterializedViewStmt dropMaterialize
// Step3: log drop mv operation
EditLog editLog = Env.getCurrentEnv().getEditLog();
editLog.logDropRollup(
- new DropInfo(db.getId(), olapTable.getId(),
olapTable.getName(), mvIndexId, false, 0));
+ new DropInfo(db.getId(), olapTable.getId(),
olapTable.getName(), mvIndexId, false, false, 0));
+ deleteIndexList.add(mvIndexId);
Review Comment:
remove
##########
fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java:
##########
@@ -1049,6 +1056,10 @@ public void replayDropRollup(DropInfo dropInfo, Env env)
throws MetaNotFoundExce
} finally {
olapTable.writeUnlock();
}
+
+ List<Long> deleteIndexList = new ArrayList<Long>();
+ deleteIndexList.add(rollupIndexId);
+
Env.getCurrentInternalCatalog().eraseDroppedIndexBackendReplicas(olapTable.getId(),
deleteIndexList);
Review Comment:
remove it
##########
fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java:
##########
@@ -931,15 +933,18 @@ public void processBatchDropRollup(List<AlterClause>
dropRollupClauses, Database
long tableId = olapTable.getId();
String tableName = olapTable.getName();
editLog.logBatchDropRollup(new BatchDropInfo(dbId, tableId,
tableName, indexIdSet));
+ deleteIndexList = indexIdSet.stream().collect(Collectors.toList());
LOG.info("finished drop rollup index[{}] in table[{}]",
String.join("", rollupNameSet), olapTable.getName());
} finally {
olapTable.writeUnlock();
}
+
Env.getCurrentInternalCatalog().eraseDroppedIndexBackendReplicas(olapTable.getId(),
deleteIndexList);
Review Comment:
remove
##########
fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java:
##########
@@ -931,15 +933,18 @@ public void processBatchDropRollup(List<AlterClause>
dropRollupClauses, Database
long tableId = olapTable.getId();
String tableName = olapTable.getName();
editLog.logBatchDropRollup(new BatchDropInfo(dbId, tableId,
tableName, indexIdSet));
+ deleteIndexList = indexIdSet.stream().collect(Collectors.toList());
Review Comment:
remove
##########
fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java:
##########
@@ -901,6 +902,7 @@ private long checkAndGetBaseIndex(String baseIndexName,
OlapTable olapTable) thr
public void processBatchDropRollup(List<AlterClause> dropRollupClauses,
Database db, OlapTable olapTable)
throws DdlException, MetaNotFoundException {
+ List<Long> deleteIndexList = null;
Review Comment:
remove
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]