Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16989#discussion_r124959257
  
    --- Diff: 
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/OneForOneBlockFetcher.java
 ---
    @@ -126,4 +150,38 @@ private void failRemainingBlocks(String[] 
failedBlockIds, Throwable e) {
           }
         }
       }
    +
    +  private class DownloadCallback implements StreamCallback {
    +
    +    private WritableByteChannel channel = null;
    +    private File targetFile = null;
    +    private int chunkIndex;
    +
    +    public DownloadCallback(File targetFile, int chunkIndex) throws 
IOException {
    +      this.targetFile = targetFile;
    +      this.channel = Channels.newChannel(new FileOutputStream(targetFile));
    --- End diff --
    
    @jinxing64 The retry logic is here: 
https://github.com/apache/spark/blob/88a536babf119b7e331d02aac5d52b57658803bf/common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/RetryingBlockFetcher.java#L215
    
    The issue is there will be two `DownloadCallback`s download the same 
content to the same target file. While the first one finishes, 
ShuffleBlockFetcherIterator may start to read it, however, the second 
`DownloadCallback` may be still running and writing to the target file. It 
could cause `ShuffleBlockFetcherIterator` reading a partial result.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to