[ 
https://issues.apache.org/jira/browse/HDFS-12855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16269303#comment-16269303
 ] 

Manoj Govindassamy commented on HDFS-12855:
-------------------------------------------

The latest trunk code is also similar to 2.7.x line. 
{{NamenodeFsck.blockIdCK()}} works on BlockManager and FSNameSystem layer 
directly without holding NameSystem locks. One race I can think of is fsck with 
block id option running in parallel with a file deletion which contains the 
same block. Since the BlockInfo is obtained without holding a lock, the file 
could get deleted and later the INode retrieval could return null and could 
face NPE when accessing INode members. Haven't proved this with a test yet 
though.  

{noformat}
  public void blockIdCK(String blockId) {
    ...
    try {
      //get blockInfo
      Block block = new Block(Block.getBlockId(blockId));
      //find which file this block belongs to
      BlockInfo blockInfo = blockManager.getStoredBlock(block);
      if(blockInfo == null) {
        out.println("Block "+ blockId +" " + NONEXISTENT_STATUS);
        LOG.warn("Block "+ blockId + " " + NONEXISTENT_STATUS);
        return;
      }
      final INodeFile iNode = 
namenode.getNamesystem().getBlockCollection(blockInfo);
      NumberReplicas numberReplicas= blockManager.countNodes(blockInfo);
      out.println("Block Id: " + blockId);
      out.println("Block belongs to: "+iNode.getFullPathName());
      out.println("No. of Expected Replica: " +
          blockManager.getExpectedRedundancyNum(blockInfo));
{noformat}

> Fsck violates namesystem locking 
> ---------------------------------
>
>                 Key: HDFS-12855
>                 URL: https://issues.apache.org/jira/browse/HDFS-12855
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 2.7.4
>            Reporter: Konstantin Shvachko
>
> {{NamenodeFsck}} access {{FSNamesystem}} structures, such as INodes, 
> BlockInfo without holding a lock. See e.g. {{NamenodeFsck.blockIdCK()}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to