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


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -2627,41 +2839,64 @@ private <T> void graphAddHandler(T response) {
                 continue;
             }
             LOG.info("Accept graph add signal from etcd for {}", graphName);
-            if (this.graphs.containsKey(graphName) ||
-                this.creatingGraphs.contains(graphName)) {
-                this.creatingGraphs.remove(graphName);
-                continue;
+            HugeGraph retryOwner = null;
+            synchronized (this) {
+                HugeGraph owner = (HugeGraph) this.graphs.get(graphName);
+                if (owner != null || this.creatingGraphs.contains(graphName)) {
+                    if (owner != null) {
+                        // Independent key watches can deliver a replacement 
ADD before the old REMOVE.
+                        this.pendingGraphAdds.add(graphName);

Review Comment:
   Important: on the server that creates a graph through REST, its own PD ADD 
arrives while the owner is healthy, so the name is added here and stays in 
`pendingGraphAdds` until that owner is next dropped.
   
   `PUT .../graphs/manage` with `action=reload` then calls `dropGraph(..., 
false)`, `replayAdd` is true, and `loadAddedGraph` rereads the still present 
config and republishes the graph. `reload()` waits 10 s for `graphs` to empty 
and throws `Failed to reload grahps, try later` before `loadGraphsFromMeta`, so 
every other dropped graph stays unloaded until reload is called again. A test 
that creates a graph, delivers its own ADD and calls `reload()` fails after 
about 10 s; without the ADD it passes in 35 ms.
   
   `creatingGraphs` already marks this server's own ADD, so skip recording it 
in that case (or clear pending adds in `reload()`), and add a reload test after 
a self ADD.



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