junrao commented on code in PR #17739: URL: https://github.com/apache/kafka/pull/17739#discussion_r1844998612
########## core/src/main/java/kafka/server/share/DelayedShareFetch.java: ########## @@ -90,39 +90,50 @@ public void onExpiration() { */ @Override public void onComplete() { + // We are utilizing lock so that onComplete doesn't do a dirty read for global variables - + // partitionsAcquired and partitionsAlreadyFetched, since these variables can get updated in a different tryComplete thread. + lock.lock(); log.trace("Completing the delayed share fetch request for group {}, member {}, " + "topic partitions {}", shareFetchData.groupId(), shareFetchData.memberId(), partitionsAcquired.keySet()); - if (shareFetchData.future().isDone()) - return; + try { + if (shareFetchData.future().isDone()) + return; Review Comment: > In this case, the operation is considered completed and won't be added to the watch list of the remaining keys. This comment seems inaccurate. Currently, we add a delayed operation to either all keys or none of the keys. Nevertheless, the property that onComplete() is only called once when the operation is not completed still holds. It would be useful to fix the 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org