This is an automated email from the ASF dual-hosted git repository. lijibing 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 606943828fa [improvement](statistics)Remove read lock when doing db analyze. (#49250) 606943828fa is described below commit 606943828fa7b346a985c1db722e86e3bed12609 Author: James <lijib...@selectdb.com> AuthorDate: Thu Mar 20 11:50:41 2025 +0800 [improvement](statistics)Remove read lock when doing db analyze. (#49250) ### What problem does this PR solve? Remove read lock when doing db analyze. Don't need to lock db. --- .../apache/doris/statistics/AnalysisManager.java | 104 ++++++++++----------- 1 file changed, 47 insertions(+), 57 deletions(-) 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 8263800ea7c..f63a3b3e164 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 @@ public class AnalysisManager implements Writable { // for nereids analyze database/table public List<AnalysisInfo> buildAnalysisInfosForNereidsDB(DatabaseIf<TableIf> db, AnalyzeProperties analyzeProperties) throws AnalysisException { - db.readLock(); List<TableIf> tbls = db.getTables(); List<AnalysisInfo> analysisInfos = new ArrayList<>(); - try { - List<AnalyzeTableCommand> 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<AnalyzeTableCommand> 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 class AnalysisManager implements Writable { public List<AnalysisInfo> buildAnalysisInfosForDB(DatabaseIf<TableIf> db, AnalyzeProperties analyzeProperties) throws AnalysisException { - db.readLock(); List<TableIf> tbls = db.getTables(); List<AnalysisInfo> analysisInfos = new ArrayList<>(); - try { - List<AnalyzeTblStmt> analyzeStmts = new ArrayList<>(); - for (TableIf table : tbls) { - if (table instanceof View) { - continue; - } + List<AnalyzeTblStmt> 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; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org