rpuch commented on code in PR #5679: URL: https://github.com/apache/ignite-3/pull/5679#discussion_r2060326912
########## modules/raft/src/main/java/org/apache/ignite/internal/raft/RaftGroupServiceImpl.java: ########## @@ -768,7 +765,8 @@ private void handleErrorResponse(CompletableFuture<? extends NetworkMessage> fut leader = newTargetPeer; } - scheduleRetry(fut, retryContext.nextAttempt(newTargetPeer)); + String shortReasonMessage = "Peer " + shortPeerString(retryContext.targetPeer()) + " returned code " + error; Review Comment: This is duplicated a few times. How about introducing a method to build this string? ########## modules/raft/src/main/java/org/apache/ignite/internal/raft/RetryContext.java: ########## @@ -60,6 +69,11 @@ class RetryContext { */ private final Set<Peer> unavailablePeers = new HashSet<>(); + /** + * List of last {@value MAX_RETRY_REASONS} retry reasons. {@link LinkedList} in order to allow fast head removal upon overflow. + */ + private final List<RetryReason> retryReasons = new LinkedList<>(); Review Comment: Would it make sense to use `ArrayDeque`? ########## modules/raft/src/main/java/org/apache/ignite/internal/raft/RetryContext.java: ########## @@ -146,9 +164,37 @@ RetryContext nextAttempt(Peer newTargetPeer) { * * @return {@code this}. */ - RetryContext nextAttemptForUnavailablePeer(Peer newTargetPeer) { + RetryContext nextAttemptForUnavailablePeer(Peer newTargetPeer, String shortReasonMessage) { unavailablePeers.add(targetPeer); - return nextAttempt(newTargetPeer); + return nextAttempt(newTargetPeer, shortReasonMessage); + } + + TimeoutException createTimeoutException() { + return new TimeoutException(format( + "Send with retry timed out [retryCount = {}, groupId = {}, traceId = {}, request = {}, originCommand = {}," + + " retryReasons={}].", + retryCount, + groupId, + errorTraceId, + request.toStringForLightLogging(), + originDescription.get(), + retryReasons.toString() + )); + } + + private static class RetryReason { + final long timestamp; + final String reason; + + RetryReason(String reason) { + this.timestamp = System.currentTimeMillis(); + this.reason = reason; + } + + @Override + public String toString() { + return "[time=" + timestamp + ", msg=" + reason + "]"; Review Comment: Isn't `S.toString()` used for brevity? If yes, please add a comment -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org