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


##########
hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/HeartbeatService.java:
##########
@@ -415,6 +451,29 @@ public void shutdown() {
         }
     }
 
+    private void reportOffline() {
+        if (fatalExitRequested.get() || storeInfo == null) {
+            return;
+        }
+        storeInfo.setState(Metapb.StoreState.Offline);
+        if (storeInfo.getId() == 0 || pdProvider == null ||
+            pdProvider.getPDClient() == null) {
+            return;
+        }
+        try {
+            // Preserve PD's current metadata, and never use Exiting for a 
temporary restart.
+            var client = pdProvider.getPDClient();
+            client.getCache().removeStore(storeInfo.getId());
+            Metapb.Store current = client.getStore(storeInfo.getId());
+            if (current.getState() == Metapb.StoreState.Up) {
+                
client.updateStore(current.toBuilder().setState(Metapb.StoreState.Offline).build());

Review Comment:
   [P2] Distinguish shutdown reporting from administrative offlining
   
   This new updateStore(Offline) call goes through 
[PDService.setStore](https://github.com/apache/hugegraph/blob/9c08bf6fb6e6c02e4a762172959d1df84a975564/hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/service/PDService.java#L469-L480),
 which rejects every Offline update while clusterStats is not Cluster_OK. For 
example, with initial-store-count=3 and one Store's keepalive already expired, 
gracefully stopping another Up Store leaves that Store recorded Up even though 
PD is reachable. PDClient turns the error header into PDException; the catch 
below only logs it after the heartbeat producers have stopped, so the record 
stays Up until expiry.
   
   Please provide a temporary-shutdown reporting path that records Offline 
independently of cluster readiness while retaining the existing keepalive TTL. 
Keep the administrative offlining safety check intact. Add a service-level 
regression with a non-OK cluster; the current tests mock PDClient or call 
StoreNodeService directly and bypass this guard. This is a source-confirmed 
shutdown-state consistency gap, not a demonstrated new write outage; no live 
cluster or real-TTL test was run.



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