morningman commented on code in PR #18592:
URL: https://github.com/apache/doris/pull/18592#discussion_r1164017919


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/external/ExternalDatabase.java:
##########
@@ -107,21 +107,25 @@ public boolean isInitialized() {
     }
 
     public final synchronized void makeSureInitialized() {
-        if (!initialized) {
-            if (!Env.getCurrentEnv().isMaster()) {
-                // Forward to master and wait the journal to replay.
-                int waitTimeOut = ConnectContext.get() == null ? 300 : 
ConnectContext.get().getExecTimeout();
-                MasterCatalogExecutor remoteExecutor = new 
MasterCatalogExecutor(waitTimeOut * 1000);
-                try {
-                    remoteExecutor.forward(extCatalog.getId(), id);
-                } catch (Exception e) {
-                    Util.logAndThrowRuntimeException(LOG,
-                            String.format("failed to forward init external db 
%s operation to master", name), e);
-                }
-                return;
+        if (initialized && extCatalog.isInitialized()) {
+            return;
+        }
+        if (!extCatalog.isInitialized()) {

Review Comment:
   I think we can move `extCatalog.isInitialized()` into 
`extCatalog.makeSureInitialized()`. Because `extCatalog.makeSureInitialized();` 
is a reentryable method



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/external/ExternalTable.java:
##########
@@ -103,7 +105,16 @@ public boolean isView() {
     }
 
     protected void makeSureInitialized() {
-        throw new NotImplementedException();
+        try {
+            // getDbOrAnalysisException will call makeSureInitialized in 
ExternalCatalog.
+            ExternalDatabase db = catalog.getDbOrAnalysisException(dbName);
+            if (db.isInitialized()) {
+                return;
+            }
+            db.makeSureInitialized();

Review Comment:
   I think we can move `db.isInitialized()` into `db.makeSureInitialized()`. 
Because `db.makeSureInitialized();` is a reentryable method



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to