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


##########
hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/ConfigService.java:
##########
@@ -93,6 +94,38 @@ public Metapb.GraphSpace setGraphSpaceUsage(String name, 
long usedSize) throws P
         }
     }
 
+    /**
+     * Recheck current PD graphs before recreating missing usage. A quota 
collection may
+     * have started before the Server removed the graphs and their space's 
statistics.
+     */
+    public Metapb.GraphSpace refreshGraphSpaceUsage(String name, long usedSize,
+                                                   PartitionService 
partitions) throws PDException {
+        synchronized (GRAPH_SPACE_LOCK) {
+            if (this.meta.getGraphSpaceExact(name) == null && !hasGraphs(name, 
partitions)) {
+                return null;
+            }
+            return this.setGraphSpaceUsage(name, usedSize);
+        }
+    }
+
+    public void deleteGraphSpace(String name, PartitionService partitions) 
throws PDException {
+        if (name == null || name.isEmpty() || name.indexOf('/') >= 0) {
+            throw new PDException(Pdpb.ErrorType.UNKNOWN_VALUE, "Invalid graph 
space name");
+        }
+        synchronized (GRAPH_SPACE_LOCK) {
+            if (hasGraphs(name, partitions)) {

Review Comment:
   Important: Graph records PD keeps for graphs the Server no longer has now 
block graph-space deletion for good. On master, `HstoreSessionsImpl.clear()` 
ignored a failed `delGraph` (`catch (PDException ignored)`), and 
`GraphManager.dropGraph` removes the graph config before `g.clearBackend()`. A 
graph dropped while PD was briefly unavailable therefore finished dropping on 
the Server but left its `shop/<graph>/...` records in PD. `dropGraphSpace` only 
drops graphs in this Server's `this.graphs` map, so it never reaches those 
records. This check then finds them under `shop/` and refuses, and the Server 
reports `Failed to remove graph space 'shop' statistics from PD` and keeps the 
space. Every retry fails the same way, while the same deletion succeeded before 
this PR. The message does not name the graph. Neither the Server API nor PD's 
REST API can remove a PD graph record with no Server graph behind it: PD's only 
REST delete is `DELETE /v1/store/{storeId}`. The workaround is to find t
 he name in `GET /v1/graphs`, recreate a graph with that name, and drop it.
   
   Please handle records that no Server graph owns. For example, before calling 
`deleteGraphSpace`, have `dropGraphSpace` call `delGraph` for every PD graph 
under `name + "/"` that has no graph config left in the meta store. At minimum, 
put the remaining graph names in this error so an operator can act on it. A 
test with a leftover `shop/old/g` record and no matching Server graph would 
cover the case.



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