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


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -2627,41 +2845,66 @@ 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);
+                boolean retryPeerCleanup = owner != null && 
this.failedPeerRemovals.contains(owner);
+                if (this.creatingGraphs.remove(graphName) && 
!retryPeerCleanup) {
+                    // The acknowledgement of local creation is not a 
replacement ADD.
+                    continue;
+                }
+                if (owner != null) {
+                    // Independent key watches can deliver a replacement ADD 
before the old REMOVE.
+                    this.pendingGraphAdds.add(graphName);

Review Comment:
   Minor: a healthy owner can still get a stale entry here when the ADD is not 
this server's own. One path is two servers creating the same graph name at 
about the same time (the existence check in `createGraph` is local only). 
Server A consumes its own marker, then B's ADD finds A's healthy owner with no 
marker and lands here. Nothing removes it until that owner is dropped.
   
   The next `action=reload` on A replays the load inside `dropGraph`, the 10 x 
1s wait in `reload()` never sees an empty map, and it throws before 
`loadGraphsFromMeta`. The other graphs it already dropped stay unloaded until 
reload is retried. Since reload rereads metadata anyway, skipping the replay 
(or clearing `pendingGraphAdds`) for the reload drops would close this.



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