Skip to content

[CELEBORN-2253][0.6] Fix IndexOutOfBoundsException reading shuffle data from HDFS#3697

Closed
pan3793 wants to merge 1 commit into
apache:branch-0.6from
pan3793:CELEBORN-2253-0.6
Closed

[CELEBORN-2253][0.6] Fix IndexOutOfBoundsException reading shuffle data from HDFS#3697
pan3793 wants to merge 1 commit into
apache:branch-0.6from
pan3793:CELEBORN-2253-0.6

Conversation

@pan3793
Copy link
Copy Markdown
Member

@pan3793 pan3793 commented May 21, 2026

Backport CELEBORN-2253 (#3683) to branch-0.6, code and tests are tuned to adapt branch-0.6 due to miss CELEBORN-2211 (#3548)

Assisted-by: OpenCode:mimo-v2.5-pro


Original PR description.

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.

Copy link
Copy Markdown
Contributor

@zaynt4606 zaynt4606 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM~

SteNicholas pushed a commit that referenced this pull request May 21, 2026
…ta from HDFS

Backport CELEBORN-2253 (#3683) to branch-0.6, code and tests are tuned to adapt branch-0.6 due to miss CELEBORN-2211 (#3548)

Assisted-by: OpenCode:mimo-v2.5-pro

---

Original PR description.

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

Closes #3697 from pan3793/CELEBORN-2253-0.6.

Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: SteNicholas <programgeek@163.com>
@SteNicholas
Copy link
Copy Markdown
Member

Thanks. Merged to branch-0.6(v0.6.4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants