diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java index 8263800ea7caa6..f63a3b3e164080 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java @@ -271,39 +271,34 @@ protected AnalysisInfo buildAndAssignJob(AnalyzeTableCommand command) throws Ddl // for nereids analyze database/table public List buildAnalysisInfosForNereidsDB(DatabaseIf db, AnalyzeProperties analyzeProperties) throws AnalysisException { - db.readLock(); List tbls = db.getTables(); List analysisInfos = new ArrayList<>(); - try { - List commands = new ArrayList<>(); - for (TableIf table : tbls) { - if (table instanceof View) { - continue; - } - TableNameInfo tableNameInfo = new TableNameInfo(db.getCatalog().getName(), - db.getFullName(), table.getName()); - // columnNames null means to add all visible columns. - // Will get all the visible columns in analyzeTableOp.check() - AnalyzeTableCommand command = new AnalyzeTableCommand(analyzeProperties, tableNameInfo, - null, db.getId(), table); - try { - command.check(); - } catch (AnalysisException analysisException) { - LOG.warn("Failed to build analyze job: {}", - analysisException.getMessage(), analysisException); - } - commands.add(command); + List commands = new ArrayList<>(); + for (TableIf table : tbls) { + if (table instanceof View) { + continue; } - for (AnalyzeTableCommand command : commands) { - try { - analysisInfos.add(buildAndAssignJob(command)); - } catch (DdlException e) { - LOG.warn("Failed to build analyze job: {}", - e.getMessage(), e); - } + TableNameInfo tableNameInfo = new TableNameInfo(db.getCatalog().getName(), + db.getFullName(), table.getName()); + // columnNames null means to add all visible columns. + // Will get all the visible columns in analyzeTableOp.check() + AnalyzeTableCommand command = new AnalyzeTableCommand(analyzeProperties, tableNameInfo, + null, db.getId(), table); + try { + command.check(); + } catch (AnalysisException analysisException) { + LOG.warn("Failed to build analyze job: {}", + analysisException.getMessage(), analysisException); + } + commands.add(command); + } + for (AnalyzeTableCommand command : commands) { + try { + analysisInfos.add(buildAndAssignJob(command)); + } catch (DdlException e) { + LOG.warn("Failed to build analyze job: {}", + e.getMessage(), e); } - } finally { - db.readUnlock(); } return analysisInfos; } @@ -318,39 +313,34 @@ public void createAnalysisJobs(AnalyzeDBStmt analyzeDBStmt, boolean proxy) throw public List buildAnalysisInfosForDB(DatabaseIf db, AnalyzeProperties analyzeProperties) throws AnalysisException { - db.readLock(); List tbls = db.getTables(); List analysisInfos = new ArrayList<>(); - try { - List analyzeStmts = new ArrayList<>(); - for (TableIf table : tbls) { - if (table instanceof View) { - continue; - } + List analyzeStmts = new ArrayList<>(); + for (TableIf table : tbls) { + if (table instanceof View) { + continue; + } - TableName tableName = new TableName(db.getCatalog().getName(), db.getFullName(), table.getName()); - // columnNames null means to add all visible columns. - // Will get all the visible columns in analyzeTblStmt.check() - AnalyzeTblStmt analyzeTblStmt = new AnalyzeTblStmt(analyzeProperties, tableName, - null, db.getId(), table); - try { - analyzeTblStmt.check(); - } catch (AnalysisException analysisException) { - LOG.warn("Failed to build analyze job: {}", - analysisException.getMessage(), analysisException); - } - analyzeStmts.add(analyzeTblStmt); + TableName tableName = new TableName(db.getCatalog().getName(), db.getFullName(), table.getName()); + // columnNames null means to add all visible columns. + // Will get all the visible columns in analyzeTblStmt.check() + AnalyzeTblStmt analyzeTblStmt = new AnalyzeTblStmt(analyzeProperties, tableName, + null, db.getId(), table); + try { + analyzeTblStmt.check(); + } catch (AnalysisException analysisException) { + LOG.warn("Failed to build analyze job: {}", + analysisException.getMessage(), analysisException); } - for (AnalyzeTblStmt analyzeTblStmt : analyzeStmts) { - try { - analysisInfos.add(buildAndAssignJob(analyzeTblStmt)); - } catch (DdlException e) { - LOG.warn("Failed to build analyze job: {}", - e.getMessage(), e); - } + analyzeStmts.add(analyzeTblStmt); + } + for (AnalyzeTblStmt analyzeTblStmt : analyzeStmts) { + try { + analysisInfos.add(buildAndAssignJob(analyzeTblStmt)); + } catch (DdlException e) { + LOG.warn("Failed to build analyze job: {}", + e.getMessage(), e); } - } finally { - db.readUnlock(); } return analysisInfos; }