You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/06/28 11:11:31 UTC

[GitHub] [spark] cxzl25 commented on a diff in pull request #37015: [SPARK-39628][CORE] Fix a race condition when handling of IdleStateEvent again

cxzl25 commented on code in PR #37015:
URL: https://github.com/apache/spark/pull/37015#discussion_r908351409


##########
common/network-common/src/main/java/org/apache/spark/network/server/TransportChannelHandler.java:
##########
@@ -158,10 +158,12 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
       // To avoid a race between TransportClientFactory.createClient() and this code which could
       // result in an inactive client being returned, this needs to run in a synchronized block.
       synchronized (this) {
+        // Do not modify the order of hasInFlightRequests and isActuallyOverdue (see SPARK-27073)
+        boolean hasInFlightRequests = responseHandler.hasOutstandingRequests();
         boolean isActuallyOverdue =
           System.nanoTime() - responseHandler.getTimeOfLastRequestNs() > requestTimeoutNs;
         if (e.state() == IdleState.ALL_IDLE && isActuallyOverdue) {
-          if (responseHandler.hasOutstandingRequests()) {
+          if (hasInFlightRequests) {

Review Comment:
   Are you referring to adding more comments to the code, or explaining why this happens in this PR?
   
   Original PR #23989 should explain:
   > When TransportChannelHandler processes IdleStateEvent, it first calculates whether the last request time has timed out.
   At this time, TransportClient.sendRpc initiates a request.
   TransportChannelHandler gets responseHandler.numOutstandingRequests() > 0, causing the normal connection to be closed.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org