diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java index 8392f1e6cf8842..89c2d95f4aecce 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java @@ -828,7 +828,7 @@ private void replaceTableInternal(Database db, OlapTable origTable, OlapTable ne // not swap, the origin table is not used anymore, need to drop all its tablets. // put original table to recycle bin. if (isForce) { - Env.getCurrentEnv().onEraseOlapTable(origTable, isReplay); + Env.getCurrentEnv().onEraseOlapTable(db.getId(), origTable, isReplay); } else { Env.getCurrentRecycleBin().recycleTable(db.getId(), origTable, isReplay, isForce, 0); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/CloudRollupJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/CloudRollupJobV2.java index ea11f2a175aa3f..8ce6e8192617e2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/CloudRollupJobV2.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/CloudRollupJobV2.java @@ -140,7 +140,7 @@ protected void onCancel() { while (true) { try { ((CloudInternalCatalog) Env.getCurrentInternalCatalog()) - .dropMaterializedIndex(tableId, rollupIndexList, false); + .dropMaterializedIndex(dbId, tableId, rollupIndexList, false); for (Map.Entry> partitionEntry : partitionIdToBaseRollupTabletIdMap.entrySet()) { Long partitionId = partitionEntry.getKey(); Map rollupTabletIdToBaseTabletId = partitionEntry.getValue(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java index 8b7a7dba1cfc69..e26c3a24898fcc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/CloudSchemaChangeJobV2.java @@ -160,7 +160,7 @@ private void dropIndex(List idxList) { while (true) { try { ((CloudInternalCatalog) Env.getCurrentInternalCatalog()) - .dropMaterializedIndex(tableId, idxList, false); + .dropMaterializedIndex(dbId, tableId, idxList, false); break; } catch (Exception e) { LOG.warn("drop index failed, retry times {}, dbId: {}, tableId: {}, jobId: {}, idxList: {}:", diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java index 90569f3d2f13d4..997e91f6079b33 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java @@ -985,7 +985,7 @@ public void processBatchDropRollup(List dropRollupClauses, Database } finally { olapTable.writeUnlock(); } - Env.getCurrentInternalCatalog().eraseDroppedIndex(olapTable.getId(), deleteIndexList); + Env.getCurrentInternalCatalog().eraseDroppedIndex(db.getId(), olapTable.getId(), deleteIndexList); } public void processDropMaterializedView(DropMaterializedViewCommand dropMaterializedViewCommand, Database db, @@ -1014,7 +1014,7 @@ public void processDropMaterializedView(DropMaterializedViewCommand dropMaterial } finally { olapTable.writeUnlock(); } - Env.getCurrentInternalCatalog().eraseDroppedIndex(olapTable.getId(), deleteIndexList); + Env.getCurrentInternalCatalog().eraseDroppedIndex(db.getId(), olapTable.getId(), deleteIndexList); } /** @@ -1105,7 +1105,7 @@ public void replayDropRollup(DropInfo dropInfo, Env env) throws MetaNotFoundExce List deleteIndexList = new ArrayList(); deleteIndexList.add(rollupIndexId); - Env.getCurrentInternalCatalog().eraseDroppedIndex(olapTable.getId(), deleteIndexList); + Env.getCurrentInternalCatalog().eraseDroppedIndex(db.getId(), olapTable.getId(), deleteIndexList); LOG.info("replay drop rollup {}", dropInfo.getIndexId()); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java index 1a5ed4cd75c793..e7bb52f98e3fb6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java @@ -2606,7 +2606,7 @@ private Status atomicReplaceOlapTables(Database db, boolean isReplay) { try { LOG.info("drop the origin olap table {}. table={}" + " isAtomicRestore: {}", originOlapTbl.getName(), originOlapTbl.getId(), isAtomicRestore); - Env.getCurrentEnv().onEraseOlapTable(originOlapTbl, isReplay); + Env.getCurrentEnv().onEraseOlapTable(db.getId(), originOlapTbl, isReplay); } finally { originOlapTbl.writeUnlock(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java index 60d9f2746e23c7..e8514e70f30ab5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java @@ -406,7 +406,7 @@ private void eraseAllTables(RecycleDatabaseInfo dbInfo) { Table table = tableInfo.getTable(); if (table.isManagedTable()) { - Env.getCurrentEnv().onEraseOlapTable((OlapTable) table, false); + Env.getCurrentEnv().onEraseOlapTable(dbId, (OlapTable) table, false); } iterator.remove(); idToRecycleTime.remove(table.getId()); @@ -469,7 +469,7 @@ private void eraseTable(long currentTimeMs, int keepNum) { } Table table = tableInfo.getTable(); if (table.isManagedTable()) { - Env.getCurrentEnv().onEraseOlapTable((OlapTable) table, false); + Env.getCurrentEnv().onEraseOlapTable(tableInfo.getDbId(), (OlapTable) table, false); } idToRecycleTime.remove(tableId); @@ -527,7 +527,7 @@ private void eraseTableWithSameName(long dbId, String tableName, long currentTim } Table table = tableInfo.getTable(); if (table.isManagedTable()) { - Env.getCurrentEnv().onEraseOlapTable((OlapTable) table, false); + Env.getCurrentEnv().onEraseOlapTable(dbId, (OlapTable) table, false); } idToTable.remove(tableId); @@ -566,7 +566,7 @@ public void replayEraseTable(long tableId) { Table table = tableInfo.getTable(); if (table.isManagedTable()) { - Env.getCurrentEnv().onEraseOlapTable((OlapTable) table, true); + Env.getCurrentEnv().onEraseOlapTable(tableInfo.getDbId(), (OlapTable) table, true); } LOG.info("replay erase table[{}]", tableId); } finally { @@ -1226,7 +1226,7 @@ public void eraseTableInstantly(long tableId) throws DdlException { long dbId = tableInfo.getDbId(); Table table = tableInfo.getTable(); if (table.getType() == TableType.OLAP || table.getType() == TableType.MATERIALIZED_VIEW) { - Env.getCurrentEnv().onEraseOlapTable((OlapTable) table, false); + Env.getCurrentEnv().onEraseOlapTable(dbId, (OlapTable) table, false); } idToTable.remove(tableId); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index 67a4c442273898..8471dcee9dab47 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -7041,7 +7041,7 @@ public void eraseDatabase(long dbId, boolean needEditLog) { } } - public void onEraseOlapTable(OlapTable olapTable, boolean isReplay) { + public void onEraseOlapTable(long dbId, OlapTable olapTable, boolean isReplay) { // inverted index TabletInvertedIndex invertedIndex = Env.getCurrentInvertedIndex(); Collection allPartitions = olapTable.getAllPartitions(); @@ -7057,7 +7057,7 @@ public void onEraseOlapTable(OlapTable olapTable, boolean isReplay) { // colocation Env.getCurrentColocateIndex().removeTable(olapTable.getId()); - getInternalCatalog().eraseTableDropBackendReplicas(olapTable, isReplay); + getInternalCatalog().eraseTableDropBackendReplicas(dbId, olapTable, isReplay); } public void onErasePartition(Partition partition) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java index cc027c1659455f..0c7891c50b270c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java @@ -811,7 +811,7 @@ public void checkMaterializedIndex(long dbId, long tableId, List indexIds) // BEGIN DROP TABLE @Override - public void eraseTableDropBackendReplicas(OlapTable olapTable, boolean isReplay) { + public void eraseTableDropBackendReplicas(long dbId, OlapTable olapTable, boolean isReplay) { if (!Env.getCurrentEnv().isMaster()) { return; } @@ -837,7 +837,7 @@ public void eraseTableDropBackendReplicas(OlapTable olapTable, boolean isReplay) if (indexs.isEmpty()) { break; } - dropMaterializedIndex(olapTable.getId(), indexs, true); + dropMaterializedIndex(dbId, olapTable.getId(), indexs, true); } catch (Exception e) { LOG.warn("failed to drop index {} of table {}, try cnt {}, execption {}", indexs, olapTable.getId(), tryCnt, e); @@ -1020,7 +1020,8 @@ public void removeSchemaChangeJob(long jobId, long dbId, long tableId, long inde } } - public void dropMaterializedIndex(long tableId, List indexIds, boolean dropTable) throws DdlException { + public void dropMaterializedIndex(long dbId, long tableId, List indexIds, boolean dropTable) + throws DdlException { if (Config.enable_check_compatibility_mode) { LOG.info("skip dropping materialized index in compatibility checking mode"); return; @@ -1031,6 +1032,7 @@ public void dropMaterializedIndex(long tableId, List indexIds, boolean dro indexRequestBuilder.setCloudUniqueId(Config.cloud_unique_id); indexRequestBuilder.addAllIndexIds(indexIds); indexRequestBuilder.setTableId(tableId); + indexRequestBuilder.setDbId(dbId); final Cloud.IndexRequest indexRequest = indexRequestBuilder.build(); Cloud.IndexResponse response = null; @@ -1061,7 +1063,7 @@ public void dropMaterializedIndex(long tableId, List indexIds, boolean dro * @param tableId * @param indexIdList */ - public void eraseDroppedIndex(long tableId, List indexIdList) { + public void eraseDroppedIndex(long dbId, long tableId, List indexIdList) { if (indexIdList == null || indexIdList.size() == 0) { LOG.warn("indexIdList is empty"); return; @@ -1075,7 +1077,7 @@ public void eraseDroppedIndex(long tableId, List indexIdList) { } try { - dropMaterializedIndex(tableId, indexIdList, false); + dropMaterializedIndex(dbId, tableId, indexIdList, false); break; } catch (Exception e) { LOG.warn("tryCnt:{}, eraseDroppedIndex exception:", tryCnt, e); diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java index 3e1bf3b2133a71..e4342753aaba0b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java @@ -1069,7 +1069,7 @@ public void replayRecoverTable(RecoverInfo info) throws MetaNotFoundException, D } } - public void eraseTableDropBackendReplicas(OlapTable olapTable, boolean isReplay) { + public void eraseTableDropBackendReplicas(long dbId, OlapTable olapTable, boolean isReplay) { if (isReplay || Env.isCheckpointThread()) { return; } @@ -1101,7 +1101,7 @@ public void erasePartitionDropBackendReplicas(List partitions) { // no need send be delete task, when be report its tablets, fe will send delete task then. } - public void eraseDroppedIndex(long tableId, List indexIdList) { + public void eraseDroppedIndex(long dbId, long tableId, List indexIdList) { // nothing to do in non cloud mode }