hello-stephen commented on code in PR #71418:
URL: https://github.com/apache/doris/pull/71418#discussion_r4795934691


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java:
##########
@@ -477,23 +502,29 @@ public void alterCatalogProps(String catalogName, 
Map<String, String> newPropert
             // taking the global catalog write lock, then retry if another 
ALTER changed the snapshot.
             boolean validatedWithoutMutation = catalog instanceof 
ExternalCatalog
                     && validateCatalogPropsBeforeUpdate((ExternalCatalog) 
catalog, oldProperties, preparedUpdates);
-            Runnable resourceCleanup = () -> { };
-            writeLock();
-            try {
-                if (nameToCatalog.get(catalogName) != catalog
-                        || !oldProperties.equals(catalog.getProperties())) {
-                    continue;
+            Map<String, String> validatedUpdates = preparedUpdates;
+            try (CatalogPropertyUpdate update = new CatalogPropertyUpdate()) {
+                // Initialization holds the catalog monitor during remote IO. 
Wait without the manager lock,
+                // then recheck the same identity and properties before 
publishing the validated update.
+                this.<DdlException>withCatalogForMutation(() -> 
nameToCatalog.get(catalogName), current -> {

Review Comment:
   [P3] Skip the monitor wait for a replacement catalog. If an HMS catalog is 
dropped and recreated as a remote Doris catalog while an ALTER submitting its 
original `type=hms` is validating, this lookup selects the replacement. The 
helper can wait for the replacement’s remote health check before the identity 
comparison triggers a retry. That retry will reject the type immediately. 
Filter the lookup by the validated identity before selecting the monitor, and 
retain the identity and property rechecks under the locks.



##########
regression-test/suites/external_table_p0/test_catalog_property_update_concurrency.groovy:
##########
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+suite("test_catalog_property_update_concurrency", "p0,external") {
+    sql "DROP CATALOG IF EXISTS test_property_update_concurrency"
+    sql "DROP CATALOG IF EXISTS test_property_update_unrelated"
+    sql """
+        CREATE CATALOG test_property_update_concurrency PROPERTIES (
+            "type" = "hms",
+            "hive.metastore.uris" = "thrift://127.0.0.1:9083",
+            "test_connection" = "false",
+            "meta.cache.max-weight" = "128MB",
+            "meta.cache.hive.file.max-weight" = "64MB"
+        )
+    """
+    sql """
+        CREATE CATALOG test_property_update_unrelated PROPERTIES (
+            "type" = "hms",
+            "hive.metastore.uris" = "thrift://127.0.0.1:9083",
+            "test_connection" = "false"
+        )
+    """
+
+    CountDownLatch ready = new CountDownLatch(2)
+    CountDownLatch start = new CountDownLatch(1)
+    def updateBudget = thread("catalog-update-total-budget") {

Review Comment:
   [P3] Give the two ALTER workers dedicated threads. `thread()` uses the 
shared action pool. With `-actionParallel 1`, the first worker holds the only 
slot while waiting for `start`. The second worker cannot decrement `ready`, so 
the suite times out before dispatching either statement. `extraThread()` gives 
each worker its own slot and preserves the barrier.



-- 
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