You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celeborn.apache.org by ni...@apache.org on 2026/04/01 07:48:56 UTC
(celeborn) branch main updated: [CELEBORN-2292] Fix ArithmeticException when PUSH_DATA_HAND_SHAKE fails before any data written
This is an automated email from the ASF dual-hosted git repository.
nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git
The following commit(s) were added to refs/heads/main by this push:
new d3b75132d [CELEBORN-2292] Fix ArithmeticException when PUSH_DATA_HAND_SHAKE fails before any data written
d3b75132d is described below
commit d3b75132daeaa0484ae2562fe2a9c9fadfa70c92
Author: luogen.lg <lu...@alibaba-inc.com>
AuthorDate: Wed Apr 1 15:48:42 2026 +0800
[CELEBORN-2292] Fix ArithmeticException when PUSH_DATA_HAND_SHAKE fails before any data written
### What changes were proposed in this pull request?
NOTE: This is the same patch with #3637 pushing to main branch. Because some code has been refactored, the original patch can not be simply cherry-picked.
Handle the case where numSubpartitions is zero in MapPartitionDataReader.open(). When the partition is empty, treat it as a normal empty partition and notify consumers accordingly.
### Why are the changes needed?
When the first PUSH_DATA_HAND_SHAKE request fails (e.g., timeout), client triggers revive with reason HARD_SPLIT. Manager adds the failed partition to partition locations, but numSubpartitions remains uninitialized (zero). Reading such partition causes ArithmeticException: / by zero.
Since this is caused by client-side behavior, we handle it on worker side first for cross-version compatibility. The issue that flink shuffle client revives with fixed reason HARD_SPLIT can be addressed in later PRs.
### Does this PR resolve a correctness bug?
No.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Manually tested with a hacked version that throws exception on the first handshake invocation. But the test code is too hacky to included into this PR. Advices are welcomed on how to add a proper unit test for this scenario without introducing too much complexity.
Closes #3641 from pltbkd/CELEBORN-2292-on-main.
Authored-by: luogen.lg <lu...@alibaba-inc.com>
Signed-off-by: SteNicholas <pr...@163.com>
---
.../flink/client/FlinkShuffleClientImpl.java | 19 ++++++++++++++--
.../worker/storage/MapPartitionDataReader.java | 26 +++++++++++++++++++++-
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/client-flink/common/src/main/java/org/apache/celeborn/plugin/flink/client/FlinkShuffleClientImpl.java b/client-flink/common/src/main/java/org/apache/celeborn/plugin/flink/client/FlinkShuffleClientImpl.java
index 6f52b4aab..9dfe48a9e 100644
--- a/client-flink/common/src/main/java/org/apache/celeborn/plugin/flink/client/FlinkShuffleClientImpl.java
+++ b/client-flink/common/src/main/java/org/apache/celeborn/plugin/flink/client/FlinkShuffleClientImpl.java
@@ -462,7 +462,15 @@ public class FlinkShuffleClientImpl extends ShuffleClientImpl {
.toByteBuffer(),
pushDataTimeout);
} catch (IOException e) {
- // ioexeption revive
+ // IOException during handshake, need to revive. TODO revive with handshake failure
+ // reason
+ logger.warn(
+ "PushDataHandShake failed for shuffle {} mapId {} attemptId {} locationId {}. Triggering revive.",
+ shuffleId,
+ mapId,
+ attemptId,
+ location.getUniqueId(),
+ e);
return revive(shuffleId, mapId, attemptId, location);
}
if (pushDataHandShakeResponse.hasRemaining()
@@ -513,7 +521,14 @@ public class FlinkShuffleClientImpl extends ShuffleClientImpl {
.toByteBuffer(),
pushDataTimeout);
} catch (IOException e) {
- // ioexeption revive
+ // IOException during regionStart, need to revive
+ logger.warn(
+ "RegionStart failed for shuffle {} mapId {} attemptId {} locationId {}. Triggering revive.",
+ shuffleId,
+ mapId,
+ attemptId,
+ location.getUniqueId(),
+ e);
return revive(shuffleId, mapId, attemptId, location);
}
diff --git a/worker/src/main/java/org/apache/celeborn/service/deploy/worker/storage/MapPartitionDataReader.java b/worker/src/main/java/org/apache/celeborn/service/deploy/worker/storage/MapPartitionDataReader.java
index 1db2f81b4..b9a361f7b 100644
--- a/worker/src/main/java/org/apache/celeborn/service/deploy/worker/storage/MapPartitionDataReader.java
+++ b/worker/src/main/java/org/apache/celeborn/service/deploy/worker/storage/MapPartitionDataReader.java
@@ -142,7 +142,31 @@ public class MapPartitionDataReader implements Comparable<MapPartitionDataReader
: new LocalPartitionDataReader(
fileInfo, dataFileChannel, indexFileChannel, headerBuffer, indexBuffer);
// index is (offset,length)
- long indexRegionSize = mapFileMeta.getNumSubpartitions() * (long) INDEX_ENTRY_SIZE;
+ int numSubpartitions = mapFileMeta.getNumSubpartitions();
+ // If numSubpartitions is 0, it means pushDataHandShake was never successfully called.
+ // This can happen when the first handshake failed before any data was written.
+ // In this case, check if data file is empty, and if so, treat this as an empty partition.
+ if (numSubpartitions == 0) {
+ if (partitionDataReader.getDataFileSize() == 0) {
+ logger.warn(
+ "Partition {} has numSubpartitions=0 and empty data file, this indicates a failed "
+ + "handshake before any data was written. Treating as empty partition.",
+ fileInfo.getFilePath());
+ isOpen = true;
+ // Mark as finished and notify consumer with backlog=1 so they can complete normally
+ closeReader();
+ notifyBacklog(1);
+ return;
+ } else {
+ // Data file has content but numSubpartitions is 0, this is a corrupted state
+ throw new FileCorruptedException(
+ "Partition "
+ + fileInfo.getFilePath()
+ + " has numSubpartitions=0 but data file size is "
+ + partitionDataReader.getDataFileSize());
+ }
+ }
+ long indexRegionSize = numSubpartitions * (long) INDEX_ENTRY_SIZE;
this.numRegions =
Utils.checkedDownCast(partitionDataReader.getIndexFileSize() / indexRegionSize);