-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-17050. Erasure coding: fix bug for invalidating duplicated block when two ec block at the same datanode but different storage. #5753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ | |
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't play with the licence |
||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
|
@@ -128,8 +128,25 @@ boolean addStorage(DatanodeStorageInfo storage, Block reportedBlock) { | |
DatanodeStorageInfo old = getStorageInfo(index); | ||
if (old != null && !old.equals(storage)) { // over replicated | ||
// check if the storage has been stored | ||
boolean blockIdNotEquals = false; | ||
long blockGroupId = BlockIdManager.convertToStripedID(reportedBlock.getBlockId() - blockIndex); | ||
Iterator<BlockInfo> blockIterator = old.getBlockIterator(); | ||
while (blockIterator.hasNext()) { | ||
BlockInfo blockInfo = blockIterator.next(); | ||
if (!blockInfo.isStriped()) { | ||
continue; | ||
} else { | ||
if (BlockIdManager.convertToStripedID(blockInfo.getBlockId()) == blockGroupId) { | ||
Block blockOnOldStorage = ((BlockInfoStriped) blockInfo).getBlockOnStorage(old); | ||
if (blockOnOldStorage.getBlockId() != reportedBlock.getBlockId()) { | ||
blockIdNotEquals = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'm a bit confused here. We retrieve There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zhangshuyan0 Thanks shuyan for your reviewing, this PR still has some problems, I will fix it soonly and push it. I think it is efficent for us to disscuss after then. |
||
break; | ||
} | ||
} | ||
} | ||
} | ||
int i = findStorageInfo(storage); | ||
if (i == -1) { | ||
if (i == -1 || blockIdNotEquals) { | ||
index = findSlot(); | ||
} else { | ||
return true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2550,16 +2550,18 @@ DatanodeDescriptor[] chooseSourceDatanodes(BlockInfo block, | |
|
||
BitSet liveBitSet = null; | ||
BitSet decommissioningBitSet = null; | ||
HashSet<DatanodeDescriptor> alreadyCorruptedSet = null; | ||
if (isStriped) { | ||
int blockNum = ((BlockInfoStriped) block).getTotalBlockNum(); | ||
liveBitSet = new BitSet(blockNum); | ||
decommissioningBitSet = new BitSet(blockNum); | ||
alreadyCorruptedSet = new HashSet<>(); | ||
} | ||
|
||
for (DatanodeStorageInfo storage : blocksMap.getStorages(block)) { | ||
final DatanodeDescriptor node = getDatanodeDescriptorFromStorage(storage); | ||
final StoredReplicaState state = checkReplicaOnStorage(numReplicas, block, | ||
storage, corruptReplicas.getNodes(block), false); | ||
storage, corruptReplicas.getNodes(block), false, alreadyCorruptedSet); | ||
if (state == StoredReplicaState.LIVE) { | ||
if (storage.getStorageType() == StorageType.PROVIDED) { | ||
storage = new DatanodeStorageInfo(node, storage.getStorageID(), | ||
|
@@ -4543,25 +4545,32 @@ public NumberReplicas countNodes(BlockInfo b) { | |
NumberReplicas countNodes(BlockInfo b, boolean inStartupSafeMode) { | ||
NumberReplicas numberReplicas = new NumberReplicas(); | ||
Collection<DatanodeDescriptor> nodesCorrupt = corruptReplicas.getNodes(b); | ||
HashSet<DatanodeDescriptor> alreadyCorruptSet = null; | ||
if (b.isStriped()) { | ||
alreadyCorruptSet = new HashSet<>(); | ||
countReplicasForStripedBlock(numberReplicas, (BlockInfoStriped) b, | ||
nodesCorrupt, inStartupSafeMode); | ||
nodesCorrupt, inStartupSafeMode, alreadyCorruptSet); | ||
} else { | ||
for (DatanodeStorageInfo storage : blocksMap.getStorages(b)) { | ||
checkReplicaOnStorage(numberReplicas, b, storage, nodesCorrupt, | ||
inStartupSafeMode); | ||
inStartupSafeMode, alreadyCorruptSet); | ||
} | ||
} | ||
return numberReplicas; | ||
} | ||
|
||
private StoredReplicaState checkReplicaOnStorage(NumberReplicas counters, | ||
BlockInfo b, DatanodeStorageInfo storage, | ||
Collection<DatanodeDescriptor> nodesCorrupt, boolean inStartupSafeMode) { | ||
Collection<DatanodeDescriptor> nodesCorrupt, boolean inStartupSafeMode, | ||
HashSet<DatanodeDescriptor> alreadyCorrupt) { | ||
final StoredReplicaState s; | ||
if (storage.getState() == State.NORMAL) { | ||
final DatanodeDescriptor node = storage.getDatanodeDescriptor(); | ||
if (nodesCorrupt != null && nodesCorrupt.contains(node)) { | ||
if (nodesCorrupt != null && nodesCorrupt.contains(node) && | ||
(alreadyCorrupt == null || !alreadyCorrupt.contains(node))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this new added condition mean? I think the current implement of |
||
if (alreadyCorrupt != null) { | ||
alreadyCorrupt.add(node); | ||
} | ||
s = StoredReplicaState.CORRUPT; | ||
} else if (inStartupSafeMode) { | ||
s = StoredReplicaState.LIVE; | ||
|
@@ -4607,12 +4616,12 @@ private StoredReplicaState checkReplicaOnStorage(NumberReplicas counters, | |
*/ | ||
private void countReplicasForStripedBlock(NumberReplicas counters, | ||
BlockInfoStriped block, Collection<DatanodeDescriptor> nodesCorrupt, | ||
boolean inStartupSafeMode) { | ||
boolean inStartupSafeMode, HashSet<DatanodeDescriptor> alreadyCorrupt) { | ||
BitSet liveBitSet = new BitSet(block.getTotalBlockNum()); | ||
BitSet decommissioningBitSet = new BitSet(block.getTotalBlockNum()); | ||
for (StorageAndBlockIndex si : block.getStorageAndIndexInfos()) { | ||
StoredReplicaState state = checkReplicaOnStorage(counters, block, | ||
si.getStorage(), nodesCorrupt, inStartupSafeMode); | ||
si.getStorage(), nodesCorrupt, inStartupSafeMode, alreadyCorrupt); | ||
countLiveAndDecommissioningReplicas(counters, state, liveBitSet, | ||
decommissioningBitSet, si.getBlockIndex()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be changed to debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhangshuyan0 Hi, shuyan, thanks for your reviewing. Here is my fault, i modify this to disable JVMPause log in my loal. I will fix it.