You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/08/31 06:56:56 UTC

[GitHub] [incubator-doris] ccoffline commented on a change in pull request #6416: #6386 Enforce null check at Catalog.getDb and Database.getTable

ccoffline commented on a change in pull request #6416:
URL: https://github.com/apache/incubator-doris/pull/6416#discussion_r695365237



##########
File path: fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
##########
@@ -1165,15 +1152,15 @@ private void getOldAlterJobInfos(Database db, List<List<Comparable>> rollupJobIn
 
 
         for (AlterJob selectedJob : jobs) {
-            OlapTable olapTable = (OlapTable) db.getTable(selectedJob.getTableId());
-            if (olapTable == null) {
-                continue;
-            }
-            olapTable.readLock();
             try {
-                selectedJob.getJobInfo(rollupJobInfos, olapTable);
-            } finally {
-                olapTable.readUnlock();
+                OlapTable olapTable = db.getTableOrMetaException(selectedJob.getTableId(), Table.TableType.OLAP);
+                olapTable.readLock();
+                try {
+                    selectedJob.getJobInfo(rollupJobInfos, olapTable);
+                } finally {
+                    olapTable.readUnlock();
+                }
+            } catch (MetaNotFoundException ignored) {

Review comment:
       This is equals to `continue`

##########
File path: fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
##########
@@ -883,26 +878,20 @@ private void removeJobFromRunningQueue(AlterJobV2 alterJob) {
     }
 
     private void changeTableStatus(long dbId, long tableId, OlapTableState olapTableState) {
-        Database db = Catalog.getCurrentCatalog().getDb(dbId);
-        if (db == null) {
-            LOG.warn("db {} has been dropped when changing table {} status after rollup job done",
-                    dbId, tableId);
-            return;
-        }
-        OlapTable tbl = (OlapTable) db.getTable(tableId);
-        if (tbl == null) {
-            LOG.warn("table {} has been dropped when changing table status after rollup job done",
-                    tableId);
-            return;
-        }
-        tbl.writeLock();
         try {
-            if (tbl.getState() == olapTableState) {
-                return;
+            Database db = Catalog.getCurrentCatalog().getDbOrMetaException(dbId);
+            OlapTable olapTable = db.getTableOrMetaException(tableId, Table.TableType.OLAP);
+            olapTable.writeLock();
+            try {
+                if (olapTable.getState() == olapTableState) {
+                    return;
+                }
+                olapTable.setState(olapTableState);
+            } finally {
+                olapTable.writeUnlock();
             }
-            tbl.setState(olapTableState);
-        } finally {
-            tbl.writeUnlock();
+        } catch (MetaNotFoundException e) {
+            LOG.warn("[INCONSISTENT META] changing table status failed after rollup job done", e);

Review comment:
       This is called by `replayAlterJobV2()` and `onJobDone()`, which should both not throw this exception.




-- 
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-unsubscribe@doris.apache.org

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



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