Details
Description
When removing volumes, we need to invalidate all the blocks in the volumes. In the following code (FsDatasetImpl), we keep the blocks that will be invalidate in blkToInvalidate map. However as the key of the map is bpid (Block Pool ID), it will be overwritten by other removed volumes. As a result, the map will have only the blocks of the last volume we are removing, and invalidate only them:
for (String bpid : volumeMap.getBlockPoolList()) { List<ReplicaInfo> blocks = new ArrayList<>(); for (Iterator<ReplicaInfo> it = volumeMap.replicas(bpid).iterator(); it.hasNext();) { ReplicaInfo block = it.next(); final StorageLocation blockStorageLocation = block.getVolume().getStorageLocation(); LOG.trace("checking for block " + block.getBlockId() + " with storageLocation " + blockStorageLocation); if (blockStorageLocation.equals(sdLocation)) { blocks.add(block); it.remove(); } } blkToInvalidate.put(bpid, blocks); }