kevin-wu24 commented on code in PR #19668: URL: https://github.com/apache/kafka/pull/19668#discussion_r2098729321
########## raft/src/main/java/org/apache/kafka/raft/RequestManager.java: ########## @@ -62,21 +67,28 @@ public RequestManager( } /** - * Returns true if there are any connections with pending requests. + * Returns true if there are any connections with pending requests for a request type. * - * This is useful for satisfying the invariant that there is only one pending Fetch request. + * This is useful for satisfying the invariant that there is only one pending Fetch + * and FetchSnapshot request. * If there are more than one pending fetch request, it is possible for the follower to write * the same offset twice. * * @param currentTimeMs the current time + * @param requestKey the api key for the request * @return true if the request manager is tracking at least one request */ - public boolean hasAnyInflightRequest(long currentTimeMs) { + public boolean hasAnyInflightRequest(long currentTimeMs, ApiKeys requestKey) { boolean result = false; - Iterator<ConnectionState> iterator = connections.values().iterator(); + final var iterator = connections.entrySet().iterator(); while (iterator.hasNext()) { - ConnectionState connection = iterator.next(); + final var entry = iterator.next(); + final var nodeAndRequestKey = entry.getKey(); + final var connection = entry.getValue(); + if (!nodeAndRequestKey.requestKey.equals(requestKey)) { + continue; + } Review Comment: Good catch, I agree we can remove other request types that have timed out or completed backoff. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org