From hdfs-issues-return-209738-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Wed Feb 7 23:16:05 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id D231A18065B for ; Wed, 7 Feb 2018 23:16:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C16AA160C5B; Wed, 7 Feb 2018 22:16:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 14F57160C3A for ; Wed, 7 Feb 2018 23:16:04 +0100 (CET) Received: (qmail 79769 invoked by uid 500); 7 Feb 2018 22:16:04 -0000 Mailing-List: contact hdfs-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list hdfs-issues@hadoop.apache.org Received: (qmail 79758 invoked by uid 99); 7 Feb 2018 22:16:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2018 22:16:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 99F97C0042 for ; Wed, 7 Feb 2018 22:16:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id FiSnQN8FFEwv for ; Wed, 7 Feb 2018 22:16:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id F24735F230 for ; Wed, 7 Feb 2018 22:16:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 0138BE018A for ; Wed, 7 Feb 2018 22:16:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 5C62121E85 for ; Wed, 7 Feb 2018 22:16:00 +0000 (UTC) Date: Wed, 7 Feb 2018 22:16:00 +0000 (UTC) From: "Hudson (JIRA)" To: hdfs-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HDFS-13115) In getNumUnderConstructionBlocks(), ignore the inodeIds for which the inodes have been deleted MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HDFS-13115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16356159#comment-16356159 ] Hudson commented on HDFS-13115: ------------------------------- SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #13632 (See [https://builds.apache.org/job/Hadoop-trunk-Commit/13632/]) HDFS-13115. In getNumUnderConstructionBlocks(), ignore the inodeIds for (yzhang: rev f491f717e9ee6b75ad5cfca48da9c6297e94a8f7) * (edit) hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java > In getNumUnderConstructionBlocks(), ignore the inodeIds for which the inodes have been deleted > ----------------------------------------------------------------------------------------------- > > Key: HDFS-13115 > URL: https://issues.apache.org/jira/browse/HDFS-13115 > Project: Hadoop HDFS > Issue Type: Bug > Reporter: Yongjun Zhang > Assignee: Yongjun Zhang > Priority: Major > Attachments: HDFS-13115.001.patch, HDFS-13115.002.patch > > > In LeaseManager, > {code} > private synchronized INode[] getINodesWithLease() { > List inodes = new ArrayList<>(leasesById.size()); > INode currentINode; > for (long inodeId : leasesById.keySet()) { > currentINode = fsnamesystem.getFSDirectory().getInode(inodeId); > // A file with an active lease could get deleted, or its > // parent directories could get recursively deleted. > if (currentINode != null && > currentINode.isFile() && > !fsnamesystem.isFileDeleted(currentINode.asFile())) { > inodes.add(currentINode); > } > } > return inodes.toArray(new INode[0]); > } > {code} > we can see that given an {{inodeId}}, {{fsnamesystem.getFSDirectory().getInode(inodeId)}} could return NULL . The reason is explained in the comment. > HDFS-12985 RCAed a case and solved that case, we saw that it fixes some cases, but we are still seeing NullPointerException from FSnamesystem > {code} > public long getCompleteBlocksTotal() { > // Calculate number of blocks under construction > long numUCBlocks = 0; > readLock(); > try { > numUCBlocks = leaseManager.getNumUnderConstructionBlocks(); <=== here > return getBlocksTotal() - numUCBlocks; > } finally { > readUnlock(); > } > } > {code} > The exception happens when the inode is removed for the given inodeid, see LeaseManager code below: > {code} > synchronized long getNumUnderConstructionBlocks() { > assert this.fsnamesystem.hasReadLock() : "The FSNamesystem read lock wasn't" > + "acquired before counting under construction blocks"; > long numUCBlocks = 0; > for (Long id : getINodeIdWithLeases()) { > final INodeFile cons = fsnamesystem.getFSDirectory().getInode(id).asFile(); <=== here > Preconditions.checkState(cons.isUnderConstruction()); > BlockInfo[] blocks = cons.getBlocks(); > if(blocks == null) > continue; > for(BlockInfo b : blocks) { > if(!b.isComplete()) > numUCBlocks++; > } > } > LOG.info("Number of blocks under construction: " + numUCBlocks); > return numUCBlocks; > } > {code} > Create this jira to add a check whether the inode is removed, as a safeguard, to avoid the NullPointerException. > Looks that after the inodeid is returned by {{getINodeIdWithLeases()}}, it got deleted from FSDirectory map. > Ideally we should find out who deleted it, like in HDFS-12985. > But it seems reasonable to me to have a safeguard here, like other code that calls to {{fsnamesystem.getFSDirectory().getInode(id)}} in the code base. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org