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


##########
hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/raft/RaftStateMachine.java:
##########
@@ -214,24 +217,29 @@ public void onLeaderStart(final long term) {
     @Override
     public void onLeaderStop(final Status status) {
         this.leaderTerm.set(-1);
-        // TODO: keep STATE_ERROR set by onError instead of overwriting it 
with STATE_FOLLOWER, so
-        // the probe view, and with it /v1/ready, reports a PD that stepped 
down for good after a
-        // snapshot failure. /v1/health does not read this view; making it 
report the state is the
-        // separate TODO at StoreAPI.checkHealthy. The Helm chart 
(helm/hugegraph) works around both
-        // by deriving a single PD's startup and liveness probes to /v1/ready.
-        // https://github.com/apache/hugegraph/issues/3222
-        this.probeView = new ProbeView(State.STATE_FOLLOWER, false);
+        // JRaft steps down after reporting a fatal error. That callback does 
not recover the node.
+        if (!isTerminal()) {
+            this.probeView = new ProbeView(State.STATE_FOLLOWER, false);
+        }
         super.onLeaderStop(status);
         log.info("Raft  lost leader ");
     }
 
     @Override
     public void onStartFollowing(final LeaderChangeContext ctx) {
+        if (isTerminal()) {
+            return;
+        }
         this.probeView = new ProbeView(State.STATE_FOLLOWER, true);
         super.onStartFollowing(ctx);
         notifyStateListeners();
     }
 
+    private boolean isTerminal() {

Review Comment:
   Fixed in e7e66661a: init resets the probe view and leader term before 
starting the new node, and re-enables listener callbacks. The new 
shutdown/reset/leader regression passes, along with all 151 PD core cases (two 
existing skips) and nine focused health cases.



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