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


##########
hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/HeartbeatService.java:
##########
@@ -200,10 +208,61 @@ protected void registerStore() {
             
this.storeInfo.setStoreAddress(IpUtil.getNearestAddress(options.getGrpcAddress()));
             
this.storeInfo.setRaftAddress(IpUtil.getNearestAddress(options.getRaftAddress()));
 
-            long storeId = pdProvider.registerStore(this.storeInfo);
+            // Recovery is needed once per process, not when an established 
stream reconnects.
+            boolean restoring = !restored;
+            this.storeInfo.setState(restoring ? Metapb.StoreState.Offline : 
Metapb.StoreState.Up);
+            long storeId;
+            try {
+                storeId = pdProvider.registerStore(this.storeInfo);
+            } finally {
+                // Retry registration after a failure instead of heartbeating 
an unregistered Store.
+                this.storeInfo.setState(Metapb.StoreState.Offline);
+            }
             if (storeId != 0) {
                 storeInfo.setId(storeId);
                 storeMetadata.save(storeInfo);
+                if (restoring && storeEngine != null) {
+                    this.clusterStats = pdProvider.getClusterStats();
+                    timerNextDelay = REGISTER_RETRY_INTERVAL * 1000;
+                    if (restoreTask == null) {
+                        restoreTask = new FutureTask<>(() -> {
+                            storeEngine.stateChanged(storeInfo, 
Metapb.StoreState.Offline, Metapb.StoreState.Up);
+                            return null;
+                        });
+                        restoreThread = new Thread(restoreTask, 
"store-partition-restore");
+                        restoreThread.start();
+                        return;
+                    }
+                    if (!restoreTask.isDone()) {
+                        return;
+                    }
+                    try {
+                        restoreTask.get();
+                    } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+                        return;
+                    } catch (ExecutionException e) {
+                        log.error("Store {} remains Offline after partition 
restore failed", storeId, e);
+                        restoreTask = null;

Review Comment:
   Updated in ebdc83863: failed restoration backs off from one second to the 
heartbeat interval, Offline registration is throttled to five seconds, and 
unchanged failures no longer repeat the full aggregate trace. Deterministic 
tests cover independent renewal, retry deadlines and refused registration, 
alongside the lifecycle suite and local quality gates.



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