imbajin commented on code in PR #3329:
URL: https://github.com/apache/hugegraph/pull/3329#discussion_r4266774673


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -2274,53 +2352,63 @@ public void dropGraph(String graphSpace, String name, 
boolean clear) {
                              "Retry deletion after owners exit, or restart to 
resume task admission",
                              graphName);
             }
+            // Cleanup failure must precede metadata removal and destructive 
clear.
+            this.unregisterRpcServices(g);
             this.removingGraphs.add(graphName);
             try {
                 this.metaManager.removeGraphConfig(graphSpace, name);
                 this.metaManager.notifyGraphRemove(graphSpace, name);
             } catch (Exception e) {
+                // No backend clear has started; retain RPC for the same open 
local owner.
+                synchronized (this) {
+                    if (this.graphs.get(graphName) == g && !g.closed()) {
+                        try {
+                            this.registerRpcServices(g);
+                        } catch (RuntimeException | Error restoration) {
+                            if (e != restoration) {
+                                e.addSuppressed(restoration);
+                            }
+                        }
+                    }
+                }
                 throw new HugeException(
-                        "Failed to remove graph config of '%s'", name, e);
+                        "Failed to remove graph config of '%s'", e, name);
             }
 
             g.clearBackend();
-            try {
-                g.close();
-            } catch (Exception e) {
-                if (!g.closed()) {
-                    throw new HugeException("Failed to close graph '%s', 
please retry later", e, graphName);
+        }
+        try {
+            g.close();
+        } catch (RuntimeException | Error failure) {
+            throw failure;

Review Comment:
   Updated in the current branch. Ordinary close failures remain wrapped as 
HugeException so a busy graph does not abort the remaining PD-removal batch; 
fatal Errors retain their identity. Logical closed() is no longer treated as 
proof of native release: the same graph owner retains unfinished cleanup steps 
and retries them. A successful clear is remembered for that exact owner, so a 
clearing DELETE retry does not revisit its removed scheduler or clear an 
already-cleared backend. Conversely, a closed owner without a successful-clear 
certificate is explicitly refused rather than reporting a clearing DELETE as 
successful. Real RocksDB, peer-batch and native Raft/listener/executor retry 
controls, the affected Server tests and full Commons/RPC suites pass; the 
complete source change passed three independent reviews.



##########
hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcProviderConfig.java:
##########
@@ -54,27 +55,54 @@ private <T, S extends T> String addService(String graph,
         providerConfig.setInterfaceId(interfaceId)
                       .setRef(serviceImpl);
 
-        E.checkArgument(!this.configs.containsKey(serviceId),
+        E.checkArgument(this.configs.putIfAbsent(serviceId, providerConfig) == 
null,
                         "Not allowed to add service already exist: '%s'",
                         serviceId);
-        this.configs.put(serviceId, providerConfig);
         return serviceId;
     }
 
     @Override
     public void removeService(String serviceId) {
-        ProviderConfig<?> config = this.configs.remove(serviceId);
-        E.checkArgument(config != null,
-                        "The service '%s' doesn't exist", serviceId);
-        config.unExport();
+        boolean[] removed = {false};
+        this.configs.computeIfPresent(serviceId, (key, config) -> {
+            config.unExport();
+            removed[0] = true;
+            return null;
+        });
+        E.checkArgument(removed[0], "The service '%s' doesn't exist", 
serviceId);
     }
 
     @Override
-    public void removeAllService() {
-        for (ProviderConfig<?> config : this.configs.values()) {
+    public boolean removeService(String serviceId, Object serviceImpl) {
+        boolean[] removed = {false};
+        this.configs.computeIfPresent(serviceId, (key, config) -> {
+            if (config.getRef() != serviceImpl) {
+                return config;
+            }
             config.unExport();
+            removed[0] = true;
+            return null;
+        });
+        return removed[0];
+    }
+
+    @Override
+    public void removeAllService() {
+        for (String serviceId : this.configs.keySet()) {
+            this.configs.computeIfPresent(serviceId, (key, config) -> {
+                config.unExport();
+                return null;
+            });
+        }
+    }
+
+    void exportAll(ServerConfig server, int timeout) {
+        for (String serviceId : this.configs.keySet()) {
+            this.configs.computeIfPresent(serviceId, (key, config) -> {
+                config.setServer(server).setTimeout(timeout).export();

Review Comment:
   Fixed in the current branch. exportAll attaches the server and timeout only 
to provider configurations that have not already been exported, and handles 
aliased entries by configuration identity. Repeated late graph publication 
therefore does not append duplicate server entries. Native 
repeated-export/alias regressions and the full Commons/RPC suite pass; distinct 
aliases and the existing administrative checks are retained.



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