slfan1989 commented on code in PR #8886:
URL: https://github.com/apache/hadoop/pull/8886#discussion_r4505484550
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java:
##########
@@ -529,36 +529,41 @@ public void addVolume(final StorageLocation location,
StorageType storageType = location.getStorageType();
final FsVolumeImpl fsVolume =
createFsVolume(sd.getStorageUuid(), sd, location);
- // no need to add lock
- final ReplicaMap tempVolumeMap = new ReplicaMap();
- ArrayList<IOException> exceptions = Lists.newArrayList();
+ try {
+ // no need to add lock
+ final ReplicaMap tempVolumeMap = new ReplicaMap();
+ ArrayList<IOException> exceptions = Lists.newArrayList();
- for (final NamespaceInfo nsInfo : nsInfos) {
- String bpid = nsInfo.getBlockPoolID();
- try {
- fsVolume.addBlockPool(bpid, this.conf, this.timer);
- fsVolume.getVolumeMap(bpid, tempVolumeMap, ramDiskReplicaTracker);
- } catch (IOException e) {
- LOG.warn("Caught exception when adding " + fsVolume +
- ". Will throw later.", e);
- exceptions.add(e);
+ for (final NamespaceInfo nsInfo : nsInfos) {
+ String bpid = nsInfo.getBlockPoolID();
+ try {
+ fsVolume.addBlockPool(bpid, this.conf, this.timer);
+ fsVolume.getVolumeMap(bpid, tempVolumeMap, ramDiskReplicaTracker);
+ } catch (IOException e) {
+ LOG.warn("Caught exception when adding " + fsVolume +
+ ". Will throw later.", e);
+ exceptions.add(e);
+ }
}
- }
- if (!exceptions.isEmpty()) {
- try {
- sd.unlock();
- } catch (IOException e) {
- exceptions.add(e);
+ if (!exceptions.isEmpty()) {
+ try {
+ sd.unlock();
+ } catch (IOException e) {
+ exceptions.add(e);
+ }
+ throw MultipleIOException.createIOException(exceptions);
}
- throw MultipleIOException.createIOException(exceptions);
- }
- final FsVolumeReference ref = fsVolume.obtainReference();
- setupAsyncLazyPersistThread(fsVolume);
+ final FsVolumeReference ref = fsVolume.obtainReference();
+ setupAsyncLazyPersistThread(fsVolume);
- builder.build();
- activateVolume(tempVolumeMap, sd, storageType, ref);
- LOG.info("Added volume - " + location + ", StorageType: " + storageType);
+ builder.build();
+ activateVolume(tempVolumeMap, sd, storageType, ref);
Review Comment:
Could we validate the same-mount capacity ratio before publishing the
volume, or roll back the registrations if activation fails?
`FsVolumeList.addVolume()` inserts the volume before checking the ratio.
For example, adding a 60% ARCHIVE volume to a mount with an existing 60%
DISK volume fails the check after the new volume has already been registered.
The new catch block calls `shutdown()`, but the volume remains eligible for
selection.
Could we add a test that verifies the failed volume is absent from the
dataset?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]