1fanwang opened a new pull request, #3683:
URL: https://github.com/apache/celeborn/pull/3683

   ### What changes were proposed in this pull request?
   
   `HdfsFlushTask.writeAndRecordMetrics` calls `hdfsStream.write(bytes)`, which 
writes the full `bytes.length`. When the provider passes a reusable `copyBytes` 
buffer (whose length is `>= size`), this leaks trailing bytes from previous 
flushes into the current partition file. Pass the actual readable size to write 
only `size` bytes.
   
   ### Why are the changes needed?
   
   The S3 and OSS flush paths had the same bug and were fixed in #3600 for 
CELEBORN-2263; the HDFS path was missed. Without the fix, shuffle data flushed 
to HDFS can be corrupted when `copyBytes` is reused across flushes, and readers 
later fail with `IndexOutOfBoundsException` in 
`CelebornInputStream.fillBuffer`, for example:
   
   ```
   IndexOutOfBoundsException: readerIndex(4154253) + length(808530018)
     exceeds writerIndex(12457470)
   ```
   
   ### Does this PR resolve a correctness bug?
   
   Yes.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   New unit test in `FlushTaskSuite` mirrors the S3/OSS coverage added in 
#3600. It drives `HdfsFlushTask.flush` with `copyBytes` arrays of three sizes 
(equal, larger, smaller than the buffer payload), captures the 
`FSDataOutputStream.write` arguments via Mockito's `ArgumentCaptor`, and 
asserts the offset/length pair matches the buffer content. The test fails on 
master with `ArgumentsAreDifferent` at `FlushTask.scala:128` and passes with 
the fix.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to