morrySnow commented on code in PR #45290:
URL: https://github.com/apache/doris/pull/45290#discussion_r1883258696


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/RefreshMTMVInfo.java:
##########
@@ -67,13 +73,41 @@ public void analyze(ConnectContext ctx) {
             Database db = 
Env.getCurrentInternalCatalog().getDbOrDdlException(mvName.getDb());
             MTMV mtmv = (MTMV) db.getTableOrMetaException(mvName.getTbl(), 
TableType.MATERIALIZED_VIEW);
             if (!CollectionUtils.isEmpty(partitions)) {
-                MTMVPartitionUtil.getPartitionsIdsByNames(mtmv, partitions);
+                checkPartitionExist(mtmv);
             }
         } catch (org.apache.doris.common.AnalysisException | 
MetaNotFoundException | DdlException e) {
             throw new AnalysisException(e.getMessage());
         }
     }
 
+    private void checkPartitionExist(MTMV mtmv) throws 
org.apache.doris.common.AnalysisException {
+        MTMVRelatedTableIf relatedTable = 
mtmv.getMvPartitionInfo().getRelatedTable();
+        // todo: Unified locking sequence
+        mtmv.readLock();
+        relatedTable.readLock();

Review Comment:
   yes should lock by id, maybe u could use
   ```
   List<TableIf> tables = Lists.newArrayList(mtmv, relatedTable);
   tables.sort(Comparator.comparing(TableIf::getId));
   MetaLockUtils.readLockTables(tables);
   try {
       ...
   } finally {
       MetaLockUtils.readUnlockTables(tableIfs);
   }
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/RefreshMTMVInfo.java:
##########
@@ -67,13 +73,41 @@ public void analyze(ConnectContext ctx) {
             Database db = 
Env.getCurrentInternalCatalog().getDbOrDdlException(mvName.getDb());
             MTMV mtmv = (MTMV) db.getTableOrMetaException(mvName.getTbl(), 
TableType.MATERIALIZED_VIEW);
             if (!CollectionUtils.isEmpty(partitions)) {
-                MTMVPartitionUtil.getPartitionsIdsByNames(mtmv, partitions);
+                checkPartitionExist(mtmv);
             }
         } catch (org.apache.doris.common.AnalysisException | 
MetaNotFoundException | DdlException e) {
             throw new AnalysisException(e.getMessage());
         }
     }
 
+    private void checkPartitionExist(MTMV mtmv) throws 
org.apache.doris.common.AnalysisException {
+        MTMVRelatedTableIf relatedTable = 
mtmv.getMvPartitionInfo().getRelatedTable();
+        // todo: Unified locking sequence
+        mtmv.readLock();
+        relatedTable.readLock();

Review Comment:
   yes should lock by id, maybe u could use
   ```java
   List<TableIf> tables = Lists.newArrayList(mtmv, relatedTable);
   tables.sort(Comparator.comparing(TableIf::getId));
   MetaLockUtils.readLockTables(tables);
   try {
       ...
   } finally {
       MetaLockUtils.readUnlockTables(tableIfs);
   }
   ```



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to