SebastianGruza commented on code in PR #3204:
URL: https://github.com/apache/hugegraph/pull/3204#discussion_r3988128307


##########
hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/NodeTxExecutor.java:
##########
@@ -411,6 +448,40 @@ <T> Optional<T> retryingInvoke(Supplier<T> supplier) {
 
     }
 
+    /**
+     * Retry only failures that a fresh attempt can plausibly fix (a transport 
error, a
+     * leader change). A DEADLINE_EXCEEDED would wait the full deadline again, 
a CANCELLED
+     * means the caller's thread was interrupted; neither is retried, also 
when it is one of
+     * several failures of a parallel commit.
+     */
+    static boolean isRetryable(Throwable t) {
+        return isRetryable(t, Collections.newSetFromMap(new 
IdentityHashMap<>()));
+    }
+
+    private static boolean isRetryable(Throwable t, Set<Throwable> seen) {
+        Throwable c = t;
+        while (c != null && seen.add(c)) {
+            if (c instanceof InterruptedException) {
+                return false;
+            }
+            if (c instanceof StatusRuntimeException) {
+                Status.Code code = ((StatusRuntimeException) 
c).getStatus().getCode();
+                if (code == Status.Code.DEADLINE_EXCEEDED || code == 
Status.Code.CANCELLED) {

Review Comment:
   Agreed, and yes — the SIGSTOP cluster runs with the shipped 
`default-shard-count: 1`, so it never had a leader to fail over to; with 
replicas the first retry would indeed have reached the new leader. Done in 
b588aa8: `retryingInvoke()` now classifies a failure as FATAL (interrupt, 
`CANCELLED`: never retried), DEADLINE (retried exactly once per call, then 
failed on a second deadline in a row) or RETRYABLE (unchanged); suppressed 
failures of a parallel commit are classified as well and the most severe class 
wins. Javadoc updated. Tests: `testDeadlineExceededIsRetriedExactlyOnce` 
expects two attempts, `testDeadlineThenNewLeaderSucceeds` covers the failover 
case, the mixed-commit test now expects two attempts, `testClassifyFailures` 
replaces the old `isRetryable` test. 10/10 locally on JDK 17.



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