Skip to content

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ public void run() {

if (extraSleepTime > warnThresholdMs) {
++numGcWarnThresholdExceeded;
LOG.warn(formatMessage(
LOG.debug(formatMessage(
Copy link
Contributor

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?

Copy link
Contributor Author

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.

extraSleepTime, gcTimesAfterSleep, gcTimesBeforeSleep));
} else if (extraSleepTime > infoThresholdMs) {
++numGcInfoThresholdExceeded;
LOG.info(formatMessage(
LOG.debug(formatMessage(
extraSleepTime, gcTimesAfterSleep, gcTimesBeforeSleep));
}
totalGcExtraSleepTime += extraSleepTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ DatanodeStorageInfo findStorageInfo(DatanodeDescriptor dn) {
*/
int findStorageInfo(DatanodeStorageInfo storageInfo) {
int len = getCapacity();
for(int idx = 0; idx < len; idx++) {
for (int idx = 0; idx < len; idx++) {
DatanodeStorageInfo cur = getStorageInfo(idx);
if (cur == storageInfo) {
return idx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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.
Expand Down Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I'm a bit confused here. We retrieve old using index, How can blockOnOldStorage.getBlockId() and reportedBlock.getBlockId() be different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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))) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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 corruptReplicasMap can not distinguish between different internal blocks on the same datanode.

if (alreadyCorrupt != null) {
alreadyCorrupt.add(node);
}
s = StoredReplicaState.CORRUPT;
} else if (inStartupSafeMode) {
s = StoredReplicaState.LIVE;
Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,19 @@ public AddBlockResult addBlock(BlockInfo b, Block reportedBlock) {

if (otherStorage != null) {
if (otherStorage != this) {
// The block belongs to a different storage. Remove it first.
otherStorage.removeBlock(b);
result = AddBlockResult.REPLACED;
if (!b.isStriped()) {
// The block belongs to a different storage. Remove it first.
otherStorage.removeBlock(b);
result = AddBlockResult.REPLACED;
} else {
long reportBlockId = reportedBlock.getBlockId();
Block blockOnOtherStorage = ((BlockInfoStriped) b).getBlockOnStorage(otherStorage);
if (reportBlockId == blockOnOtherStorage.getBlockId()) {
// The block belongs to a different storage. Remove it first.
otherStorage.removeBlock(b);
result = AddBlockResult.REPLACED;
}
}
} else {
// The block is already associated with this storage.
return AddBlockResult.ALREADY_EXIST;
Expand Down