-
Notifications
You must be signed in to change notification settings - Fork 9.2k
[ Indiscoverable bug in HDFS] FsDatasetSpi.isValidBlock() lacks null pointer check inside and neither do the callers #253
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
Conversation
BlockIteratorImpl.nextBlock() will look for the blocks in the source volume, if there are no blocks any more,it will retrurn null to DiskBalancer.getBlockToCopy().However, the DiskBalancer.getBlockToCopy() will check whether it's a valid block. when I look into the FsDatasetSpi.isValidBlock(), I find that it doesn't check the null pointer! in fact,we firstly need to check whether it's null or not, or exception will occur. this bug is hard to find, because the DiskBalancer hardly copy all the data of one volume to others.even if some times we may copy all the data of one volume to other volumes, when the bug occurs, the copy process has done. However, when we try to copy all the data of two or more volumes to other volumes in more than one step, the thread will be shut down,which is caused by the bug above. the bug can fixed by two ways: 1)before the call of FsDatasetSpi.isValidBlock(), we check the null pointer 2)check the null pointer inside the implementation of FsDatasetSpi.isValidBlock()
…ely. Author: Shanthoosh Venkataraman <[email protected]> Reviewers: Navina Ramesh <[email protected]> Closes apache#253 from shanthoosh/SAMZA-1365
|
|
||
| //null pointer should not be passed to FsDatasetSpi.isValidBlock() | ||
| if(block == null){ | ||
| return block; | ||
| } |
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.
Resolved by https://issues.apache.org/jira/browse/HDFS-12487
| if(b == null){ | ||
| throw new NullPointerException("Input Block is null!"); | ||
| } |
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.
I checked the call hierarchy of the method and b is always non-null.
|
Closing this. If you disagree, please file a JIRA and feel free to reopen this. |
…) (apache#253) (cherry picked from commit 22b8fcd) Co-authored-by: Ferenc Erdelyi <[email protected]>
Dear Hadoop Developers,
I'm from Alibaba, China. Recently, I meet a scenario where user want to migrate all the data in the old volumes to newly added volumes. Although HDFS now has a DiskBalancer tool, but it doesn't meet the requirement of us. So, we develop a new tool DiskMigration, which can migrate all the data in the current volumes to the new volumes and keep balance of data distribution at the same time.
After introduce the work I'm doing, now we get to the point of the bug of the newest version hadoop3.0:
BlockIteratorImpl.nextBlock() will look for the blocks in the source volume, if there are no blocks any more, it will return null up to DiskBalancer.getBlockToCopy(). However, the DiskBalancer.getBlockToCopy() will check whether it's a valid block.
When I look into the FsDatasetSpi.isValidBlock(), I find that it doesn't check the null pointer! In fact, we firstly need to check whether it's null or not, or exception will occur.
This bug is hard to find, because the DiskBalancer hardly copy all the data of one volume to others. Even if some times we may copy all the data of one volume to other volumes, when the bug occurs, the copy process has already done.
However, when we try to copy all the data of two or more volumes to other volumes in more than one step, the thread will be shut down, which is caused by the bug above.
The bug can fixed by two ways:
1)Before the call of FsDatasetSpi.isValidBlock(), we check the null pointer
2)Check the null pointer inside the implementation of FsDatasetSpi.isValidBlock()