Skip to content

Commit ceec19e

Browse files
RuinanGutasanuma
authored andcommitted
HDFS-16776 Erasure Coding: The length of targets should be checked when DN gets a reconstruction task (apache#4901)
(cherry picked from commit 9a29075)
1 parent d66dea3 commit ceec19e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedReconstructor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ RawErasureDecoder getDecoder() {
277277
return decoder;
278278
}
279279

280+
int getNumLiveBlocks(){
281+
return liveBitSet.cardinality();
282+
}
283+
280284
void cleanup() {
281285
if (decoder != null) {
282286
decoder.release();

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedWriter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ class StripedWriter {
8282
assert targetStorageIds != null;
8383

8484
writers = new StripedBlockWriter[targets.length];
85-
8685
targetIndices = new short[targets.length];
86+
Preconditions.checkArgument(
87+
targetIndices.length <= dataBlkNum + parityBlkNum - reconstructor.getNumLiveBlocks(),
88+
"Reconstruction work gets too much targets.");
8789
Preconditions.checkArgument(targetIndices.length <= parityBlkNum,
8890
"Too much missed striped blocks.");
8991
initTargetIndices();

0 commit comments

Comments
 (0)