HDFS-16776 Erasure Coding: The length of targets should be checked when DN gets a reconstruction task (#4901)

(cherry picked from commit 9a29075f91)
This commit is contained in:
Kidd5368 2022-09-23 11:27:56 +08:00 committed by tasanuma
parent d66dea300e
commit ceec19e61a
2 changed files with 7 additions and 1 deletions

View File

@ -277,6 +277,10 @@ abstract class StripedReconstructor {
return decoder;
}
int getNumLiveBlocks(){
return liveBitSet.cardinality();
}
void cleanup() {
if (decoder != null) {
decoder.release();

View File

@ -82,8 +82,10 @@ class StripedWriter {
assert targetStorageIds != null;
writers = new StripedBlockWriter[targets.length];
targetIndices = new short[targets.length];
Preconditions.checkArgument(
targetIndices.length <= dataBlkNum + parityBlkNum - reconstructor.getNumLiveBlocks(),
"Reconstruction work gets too much targets.");
Preconditions.checkArgument(targetIndices.length <= parityBlkNum,
"Too much missed striped blocks.");
initTargetIndices();