You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "SebastianGruza (via GitHub)" <gi...@apache.org> on 2026/09/14 12:32:36 UTC

Re: [PR] fix(store-client): bound DEADLINE_EXCEEDED retries to one per call and honour thread interrupts in NodeTxExecutor [hugegraph]

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


##########
hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/NodeTxExecutor.java:
##########
@@ -373,35 +391,75 @@ boolean ifAnyTrue(Supplier<Stream<HgPair<HgStoreNode, NodeTkv>>> nodeStreamSuppl
     }
 
     <T> Optional<T> retryingInvoke(Supplier<T> supplier) {
+        boolean[] deadlineRetried = {false};
         return IntStream.rangeClosed(0, NODE_MAX_RETRYING_TIMES).boxed()
                         .map(
                                 i -> {
+                                    if (Thread.currentThread().isInterrupted()) {
+                                        // The caller (e.g. a REST worker hitting
+                                        // restserver.request_timeout) gave up: stop
+                                        // retrying instead of holding its thread.
+                                        // InterruptedException as the root cause: the
+                                        // server's task cancel path recognises it
+                                        // (HugeException.isInterrupted()).
+                                        throw HgStoreClientException.of(
+                                                "Interrupted before retry " + i,
+                                                new InterruptedException());
+                                    }
                                     T buffer = null;
                                     try {
                                         buffer = supplier.get();
                                     } catch (Throwable t) {
-                                        if (i + 1 <= NODE_MAX_RETRYING_TIMES) {
-                                            try {
-                                                int sleepTime;
-                                                // The first three times try once every second
-                                                if (i < 3) {
-                                                    sleepTime = 1;
-                                                } else {
-                                                    // Subsequent incremental
-                                                    sleepTime = i - 1;
-                                                }
-                                                log.info("Waiting {} seconds " +
-                                                         "for the next try.",
-                                                         sleepTime);
-                                                Thread.sleep(sleepTime * 1000L);
-                                            } catch (InterruptedException e) {
-                                                log.error("Failed to sleep", e);
+                                        Failure failure = classify(t);
+                                        if (failure != Failure.DEADLINE) {
+                                            // a different failure in between means the
+                                            // next deadline is not "in a row" again
+                                            deadlineRetried[0] = false;

Review Comment:
   Agreed, the reset reopened the long wait through D, X, D, X. Done in 5ffb221 — the budget is a per-call counter now: the second `DEADLINE_EXCEEDED` ends the call whatever failed in between, so one call blocks on at most two deadlines. `testDeadlineBudgetResetsAfterAnotherFailure` became `testSecondDeadlineFailsEvenWithAnotherFailureInBetween` (D, UNAVAILABLE, D → three attempts, then the deadline is thrown); the `Failure` javadoc and the PR description say "at most once per call" instead of "in a row". Title changed to "bound DEADLINE_EXCEEDED retries to one per call" as you suggested. `NodeTxExecutorTest` 11/11 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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org