Remove empty queues from the queueByBlockId map (#6772)

This commit is contained in:
dannytbecker 2024-04-26 14:25:15 -07:00 committed by GitHub
parent 399299104c
commit 027b4c3259
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -112,14 +112,14 @@ void removeQueuedBlock(DatanodeStorageInfo storageInfo, Block block) {
if (storageInfo == null || block == null) {
return;
}
block = new Block(block);
Queue<ReportedBlockInfo> queue = null;
Block blk = new Block(block);
if (BlockIdManager.isStripedBlockID(block.getBlockId())) {
Block blkId = new Block(BlockIdManager.convertToStripedID(block
blk = new Block(BlockIdManager.convertToStripedID(block
.getBlockId()));
queue = getBlockQueue(blkId);
} else {
queue = getBlockQueue(block);
}
Queue<ReportedBlockInfo> queue = queueByBlockId.get(blk);
if (queue == null) {
return;
}
// We only want the latest non-future reported block to be queued for each
// DataNode. Otherwise, there can be a race condition that causes an old
@ -130,6 +130,11 @@ void removeQueuedBlock(DatanodeStorageInfo storageInfo, Block block) {
if (queue.removeIf(rbi -> storageInfo.equals(rbi.storageInfo))) {
count -= (size - queue.size());
}
// If the block message queue is now empty, we should remove the block
// from the queue.
if (queue.isEmpty()) {
queueByBlockId.remove(blk);
}
}
/**