Copilot commented on code in PR #2871:
URL: https://github.com/apache/hugegraph/pull/2871#discussion_r4100947664


##########
hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/PartitionEngine.java:
##########
@@ -577,6 +579,9 @@ public void shutdown() {
      * Restart raft engine
      */
     public void restartRaftNode() {
+        if (this.stateMachineError) {
+            return;
+        }

Review Comment:
   This one-time flag check does not make the terminal transition atomic with 
the existing asynchronous activity check. `checkActivity()` can already have 
queued a `restartRaftNode()` runnable, and that runnable can pass this guard 
just before `onError()` sets `stateMachineError`; it will then shut down and 
re-init the node even though the state-machine failure has occurred, 
potentially replaying the failed entry. Guard the complete shutdown/init 
transition with the same lifecycle lock or an atomic terminal-state transition 
so no restart can pass concurrently with latching the error.



##########
hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/raft/PartitionStateMachine.java:
##########
@@ -87,7 +88,7 @@ public void onApply(Iterator iter) {
                         // Leader branch, call locally
                         RaftOperation operation = done.getOperation();
                         if (handler.invoke(groupId, operation.getOp(), 
operation.getReq(),
-                                           done.getClosure())) {
+                                           done)) {

Review Comment:
   Passing `done` here changes the runtime type seen by the Store handlers from 
the original `GrpcClosure` to `DefaultRaftClosure`. The leader path in 
`HgStoreNodeService` passes this response to `GrpcClosure.setResult`, which 
unconditionally casts it to `GrpcClosure` 
(`hg-store-node/.../GrpcClosure.java:37-40`); every leader-side 
BATCH/TABLE/GRAPH/CLEAN apply will therefore throw `ClassCastException` after 
the business handler runs and report a state-machine failure. Preserve the 
original typed response while adding callback-failure isolation through a 
type-preserving wrapper or by unwrapping before that cast.



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