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/01/09 15:06:33 UTC

[GitHub] [spark] pan3793 opened a new pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

pan3793 opened a new pull request #35146:
URL: https://github.com/apache/spark/pull/35146


   ### What changes were proposed in this pull request?
   
   Change the order of `isStale || isTooLate` to leverage `||` short circuit to avoid NPE。
   
   ### Why are the changes needed?
   
   There is a chance that late push shuffle block request `PushBlockStreamCallback#onData` invoked after the merge partition finalized, which causes NPE.
   
   ```
   2022-01-07 21:06:14,464 INFO shuffle.RemoteBlockPushResolver: shuffle partition application_1640143179334_0149_-1 102 6922, chunk_size=1, meta_length=138, data_length=112632
   2022-01-07 21:06:14,615 ERROR shuffle.RemoteBlockPushResolver: Encountered issue when merging shufflePush_102_0_279_6922
   java.lang.NullPointerException
           at org.apache.spark.network.shuffle.RemoteBlockPushResolver$AppShuffleMergePartitionsInfo.access$200(RemoteBlockPushResolver.java:1017)
           at org.apache.spark.network.shuffle.RemoteBlockPushResolver$PushBlockStreamCallback.isStale(RemoteBlockPushResolver.java:806)
           at org.apache.spark.network.shuffle.RemoteBlockPushResolver$PushBlockStreamCallback.onData(RemoteBlockPushResolver.java:840)
           at org.apache.spark.network.server.TransportRequestHandler$3.onData(TransportRequestHandler.java:209)
           at org.apache.spark.network.client.StreamInterceptor.handle(StreamInterceptor.java:79)
           at org.apache.spark.network.util.TransportFrameDecoder.feedInterceptor(TransportFrameDecoder.java:263)
           at org.apache.spark.network.util.TransportFrameDecoder.channelRead(TransportFrameDecoder.java:87)
           at org.sparkproject.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
           at org.sparkproject.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
           at org.sparkproject.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
           at org.sparkproject.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
           at org.sparkproject.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
           at org.sparkproject.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
           at org.sparkproject.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
           at org.sparkproject.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
           at org.sparkproject.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
           at org.sparkproject.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
           at org.sparkproject.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
           at org.sparkproject.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
           at org.sparkproject.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
           at org.sparkproject.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
           at org.sparkproject.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
           at java.lang.Thread.run(Thread.java:748)
   ```
   
   `isTooLate` checks null but `isStale` does not, so check `isTooLate` first to avoid NPE
   ```java
      private boolean isTooLate(
           AppShuffleMergePartitionsInfo appShuffleMergePartitionsInfo,
           int reduceId) {
         return null == appShuffleMergePartitionsInfo ||
           INDETERMINATE_SHUFFLE_FINALIZED == appShuffleMergePartitionsInfo.shuffleMergePartitions ||
           !appShuffleMergePartitionsInfo.shuffleMergePartitions.containsKey(reduceId);
       }
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Bugfix, to avoid NPE in Yarn ESS.
   
   ### How was this patch tested?
   I don't think easy to write a unit test for this cause based on current code, since it's a minor change, use exsiting ut to ensue the change doesn't break the current behaviors.
   


-- 
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


[GitHub] [spark] pan3793 commented on a change in pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #35146:
URL: https://github.com/apache/spark/pull/35146#discussion_r781745328



##########
File path: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/RemoteBlockPushResolver.java
##########
@@ -789,13 +789,14 @@ private void incrementIOExceptionsAndAbortIfNecessary() {
     }
 
     /**
-     * If appShuffleMergePartitionsInfo's shuffleMergeId is
+     * If appShuffleMergePartitionsInfo is null or shuffleMergeId is
      * greater than the request shuffleMergeId then it is a stale block push.
      */
     private boolean isStale(
         AppShuffleMergePartitionsInfo appShuffleMergePartitionsInfo,
         int shuffleMergeId) {
-      return appShuffleMergePartitionsInfo.shuffleMergeId > shuffleMergeId;
+      return null == appShuffleMergePartitionsInfo ||
+             appShuffleMergePartitionsInfo.shuffleMergeId > shuffleMergeId;

Review comment:
       updated.




-- 
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


[GitHub] [spark] pan3793 commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

Posted by GitBox <gi...@apache.org>.
pan3793 commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008541752


   > Given that `isStale` is used in a few places, it would be better to fix the `null` issue there itself.
   
   I'm not sure if such change will break the semantic of `isStale`? Other calls of `isStale` always after `isLate`, so it's safe to skip `null` check


-- 
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


[GitHub] [spark] mridulm commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
mridulm commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008576652


   +CC @otterc, @Ngone51 Please take a look. Will merge it later tomorrow if no concerns.


-- 
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


[GitHub] [spark] asfgit closed pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #35146:
URL: https://github.com/apache/spark/pull/35146


   


-- 
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


[GitHub] [spark] AmplabJenkins commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008321893


   Can one of the admins verify this patch?


-- 
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


[GitHub] [spark] mridulm edited a comment on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

Posted by GitBox <gi...@apache.org>.
mridulm edited a comment on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008448763


   Given that `isStale` is used in a few places, it would be better to fix the `null` issue there itself.
   Can you try with:
   `return null == appShuffleMergePartitionsInfo || appShuffleMergePartitionsInfo.shuffleMergeId > shuffleMergeId;`
   for `isStale` @pan3793 ?
   That should work, we can merge this PR after you have validated that.
   
   We also need to ensure we have tests which check for stale but not too late as well - this specific codepath is an excellent test case for it.
   
   +CC @otterc, @Ngone51 


-- 
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


[GitHub] [spark] otterc commented on a change in pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
otterc commented on a change in pull request #35146:
URL: https://github.com/apache/spark/pull/35146#discussion_r781744412



##########
File path: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/RemoteBlockPushResolver.java
##########
@@ -789,13 +789,14 @@ private void incrementIOExceptionsAndAbortIfNecessary() {
     }
 
     /**
-     * If appShuffleMergePartitionsInfo's shuffleMergeId is
+     * If appShuffleMergePartitionsInfo is null or shuffleMergeId is
      * greater than the request shuffleMergeId then it is a stale block push.
      */
     private boolean isStale(
         AppShuffleMergePartitionsInfo appShuffleMergePartitionsInfo,
         int shuffleMergeId) {
-      return appShuffleMergePartitionsInfo.shuffleMergeId > shuffleMergeId;
+      return null == appShuffleMergePartitionsInfo ||
+             appShuffleMergePartitionsInfo.shuffleMergeId > shuffleMergeId;

Review comment:
       Nit: is this indentation ok?  It should be 4




-- 
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


[GitHub] [spark] mridulm commented on a change in pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
mridulm commented on a change in pull request #35146:
URL: https://github.com/apache/spark/pull/35146#discussion_r780917113



##########
File path: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/RemoteBlockPushResolver.java
##########
@@ -829,8 +830,8 @@ public void onData(String streamId, ByteBuffer buf) throws IOException {
       // memory, while still providing the necessary guarantee.
       synchronized (partitionInfo) {
         AppShuffleMergePartitionsInfo info = appShuffleInfo.shuffles.get(partitionInfo.shuffleId);
-        if (isStale(info, partitionInfo.shuffleMergeId) ||
-            isTooLate(info, partitionInfo.reduceId)) {
+        if (isTooLate(info, partitionInfo.reduceId) ||
+            isStale(info, partitionInfo.shuffleMergeId)) {

Review comment:
       Now that you have fixed the issue, checking `isStale` first is better: it is cheaper check to do first.




-- 
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


[GitHub] [spark] pan3793 commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

Posted by GitBox <gi...@apache.org>.
pan3793 commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008322020


   cc @mridulm @otterc 


-- 
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


[GitHub] [spark] mridulm edited a comment on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

Posted by GitBox <gi...@apache.org>.
mridulm edited a comment on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008448763


   Given that `isStale` is used in a few places, it would be better to fix the `null` issue there itself.
   Can you try with:
   `return null == appShuffleMergePartitionsInfo || appShuffleMergePartitionsInfo.shuffleMergeId > shuffleMergeId;`
   for `isStale` @pan3793 ?
   
   We also need to ensure we have tests which check for stale but not too late as well - this specific codepath is an excellent test case for it.
   
   +CC @otterc, @Ngone51 


-- 
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


[GitHub] [spark] venkata91 commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
venkata91 commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1009494424


   LGTM, but this [comment](https://github.com/apache/spark/pull/35146#discussion_r780917113) is not yet addressed right?


-- 
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


[GitHub] [spark] mridulm commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
mridulm commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1009603015


   Merged to master.
   Thanks @pan3793 for fixing this !
   Thanks @venkata91, @zhouyejoe, @otterc for the review :-)


-- 
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


[GitHub] [spark] zhouyejoe commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
zhouyejoe commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1009513800


   LGTM. @venkata91  I think that comment has been reverted.


-- 
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


[GitHub] [spark] mridulm commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

Posted by GitBox <gi...@apache.org>.
mridulm commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008448763


   Given that `isStale` is used in a few places, it would be better to fix the `null` issue there itself.
   Can you try with:
   `return null == appShuffleMergePartitionsInfo || appShuffleMergePartitionsInfo.shuffleMergeId > shuffleMergeId;`
   for isStale @pan3793 ?
   
   We also need to ensure we have tests which check for stale but not too late as well - this specific codepath is an excellent test case for it.
   
   +CC @otterc, @Ngone51 


-- 
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


[GitHub] [spark] mridulm commented on pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback should check isTooLate first to avoid NPE

Posted by GitBox <gi...@apache.org>.
mridulm commented on pull request #35146:
URL: https://github.com/apache/spark/pull/35146#issuecomment-1008558277


   There is no issues with making the change, please go ahead.


-- 
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


[GitHub] [spark] pan3793 commented on a change in pull request #35146: [SPARK-37847][CORE][SHUFFLE] PushBlockStreamCallback#isStale should check null to avoid NPE

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #35146:
URL: https://github.com/apache/spark/pull/35146#discussion_r781698304



##########
File path: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/RemoteBlockPushResolver.java
##########
@@ -829,8 +830,8 @@ public void onData(String streamId, ByteBuffer buf) throws IOException {
       // memory, while still providing the necessary guarantee.
       synchronized (partitionInfo) {
         AppShuffleMergePartitionsInfo info = appShuffleInfo.shuffles.get(partitionInfo.shuffleId);
-        if (isStale(info, partitionInfo.shuffleMergeId) ||
-            isTooLate(info, partitionInfo.reduceId)) {
+        if (isTooLate(info, partitionInfo.reduceId) ||
+            isStale(info, partitionInfo.shuffleMergeId)) {

Review comment:
       reverted change




-- 
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