This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 51ca645c3f [fix](mtmv)Fix tablet not found when restart fe (#20095) 51ca645c3f is described below commit 51ca645c3f56a762781797af038b042a4322af82 Author: zhangdong <493738...@qq.com> AuthorDate: Sat May 27 08:20:06 2023 +0800 [fix](mtmv)Fix tablet not found when restart fe (#20095) The replayCreateTable restriction must be olapTable. If mv is used, nothing will be done, resulting in no call to invertedIndex.addReplica --- .../src/main/java/org/apache/doris/analysis/ShowDataStmt.java | 5 +++-- .../src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java | 3 ++- fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java | 6 ++++++ fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java | 4 ++++ .../main/java/org/apache/doris/common/proc/PartitionsProcDir.java | 3 +-- .../src/main/java/org/apache/doris/common/proc/TableProcDir.java | 2 +- .../src/main/java/org/apache/doris/datasource/InternalCatalog.java | 6 +++--- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java index eab2ae2636..1f7fe5d2b0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java @@ -147,7 +147,7 @@ public class ShowDataStmt extends ShowStmt { } for (Table table : sortedTables) { - if (table.getType() != TableType.OLAP) { + if (!table.isManagedTable()) { continue; } @@ -243,7 +243,8 @@ public class ShowDataStmt extends ShowStmt { dbName + ": " + tableName); } - OlapTable olapTable = (OlapTable) db.getTableOrMetaException(tableName.getTbl(), TableType.OLAP); + OlapTable olapTable = (OlapTable) db + .getTableOrMetaException(tableName.getTbl(), TableType.OLAP, TableType.MATERIALIZED_VIEW); long totalSize = 0; long totalReplicaCount = 0; long totalRemoteSize = 0; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java index d2cb8b1f0f..d7de6ee560 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java @@ -23,6 +23,7 @@ import org.apache.doris.catalog.Env; import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.Table; import org.apache.doris.catalog.TableIf; +import org.apache.doris.catalog.TableIf.TableType; import org.apache.doris.catalog.Type; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.ErrorCode; @@ -125,7 +126,7 @@ public class ShowPartitionsStmt extends ShowStmt { } DatabaseIf db = catalog.getDbOrAnalysisException(dbName); - TableIf table = db.getTableOrMetaException(tblName, Table.TableType.OLAP); + TableIf table = db.getTableOrMetaException(tblName, Table.TableType.OLAP, TableType.MATERIALIZED_VIEW); table.readLock(); try { // build proc path diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java index 3e915ce437..29d37c63f8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java @@ -27,6 +27,7 @@ import com.google.common.collect.Sets; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.Set; @@ -172,6 +173,11 @@ public interface DatabaseIf<T extends TableIf> { return table; } + default T getTableOrMetaException(String tableName, TableIf.TableType... tableTypes) + throws MetaNotFoundException { + return getTableOrMetaException(tableName, Arrays.asList(tableTypes)); + } + default T getTableOrMetaException(long tableId, TableIf.TableType tableType) throws MetaNotFoundException { T table = getTableOrMetaException(tableId); if (table.getType() != tableType) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java index 07da7b3f7c..86545fa4d3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java @@ -216,5 +216,9 @@ public interface TableIf { default Partition getPartition(String name) { return null; } + + default boolean isManagedTable() { + return getType() == TableType.OLAP || getType() == TableType.MATERIALIZED_VIEW; + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java b/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java index 422effe926..95878c9208 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java @@ -33,7 +33,6 @@ import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.Partition; import org.apache.doris.catalog.PartitionInfo; import org.apache.doris.catalog.PartitionType; -import org.apache.doris.catalog.TableIf.TableType; import org.apache.doris.catalog.Type; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.ErrorCode; @@ -219,7 +218,7 @@ public class PartitionsProcDir implements ProcDirInterface { private List<List<Comparable>> getPartitionInfos() { Preconditions.checkNotNull(db); Preconditions.checkNotNull(olapTable); - Preconditions.checkState(olapTable.getType() == TableType.OLAP); + Preconditions.checkState(olapTable.isManagedTable()); // get info List<List<Comparable>> partitionInfos = new ArrayList<List<Comparable>>(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/proc/TableProcDir.java b/fe/fe-core/src/main/java/org/apache/doris/common/proc/TableProcDir.java index 9ce12e9ab4..a06d8b4f78 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/TableProcDir.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/TableProcDir.java @@ -78,7 +78,7 @@ public class TableProcDir implements ProcDirInterface { } if (entryName.equals(PARTITIONS)) { - if (table.getType() == TableType.OLAP) { + if (table.isManagedTable()) { return new PartitionsProcDir((Database) db, (OlapTable) table, false); } else if (table.getType() == TableType.ELASTICSEARCH) { return new EsPartitionsProcDir((Database) db, (EsTable) table); 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 374224d0d5..3040fc5d3a 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 @@ -357,7 +357,7 @@ public class InternalCatalog implements CatalogIf<Database> { for (Database db : this.fullNameToDb.values()) { long dbId = db.getId(); for (Table table : db.getTables()) { - if (table.getType() != TableType.OLAP) { + if (!table.isManagedTable()) { continue; } @@ -499,7 +499,7 @@ public class InternalCatalog implements CatalogIf<Database> { try { if (!stmt.isForceDrop()) { for (Table table : tableList) { - if (table.getType() == TableType.OLAP) { + if (table.isManagedTable()) { OlapTable olapTable = (OlapTable) table; if (olapTable.getState() != OlapTableState.NORMAL) { throw new DdlException("The table [" + olapTable.getState() + "]'s state is " @@ -1229,7 +1229,7 @@ public class InternalCatalog implements CatalogIf<Database> { } if (!Env.isCheckpointThread()) { // add to inverted index - if (table.getType() == TableType.OLAP) { + if (table.isManagedTable()) { TabletInvertedIndex invertedIndex = Env.getCurrentInvertedIndex(); OlapTable olapTable = (OlapTable) table; long dbId = db.getId(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org