From hdfs-issues-return-209628-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Wed Feb 7 05:24:12 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 E9E95180676 for ; Wed, 7 Feb 2018 05:24:11 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D926F160C45; Wed, 7 Feb 2018 04:24:11 +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 2E7C8160C5B for ; Wed, 7 Feb 2018 05:24:11 +0100 (CET) Received: (qmail 91796 invoked by uid 500); 7 Feb 2018 04:24:10 -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 91763 invoked by uid 99); 7 Feb 2018 04:24:10 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2018 04:24:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 814F718015D for ; Wed, 7 Feb 2018 04:24:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-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 (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id of_F3Js0mVVA for ; Wed, 7 Feb 2018 04:24:08 +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 1B1AE5F230 for ; Wed, 7 Feb 2018 04:24:08 +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 7FB46E0291 for ; Wed, 7 Feb 2018 04:24:06 +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 7BC4624106 for ; Wed, 7 Feb 2018 04:24:02 +0000 (UTC) Date: Wed, 7 Feb 2018 04:24:02 +0000 (UTC) From: "Haibo Yan (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=16354950#comment-16354950 ] Haibo Yan commented on HDFS-13115: ---------------------------------- Can we go this way?(Which could reply logic in getINodesWithLease, also need add log for getINodesWithLease) for (INode inode : getINodesWithLease()) { if (!cons.isUnderConstruction()) { for(BlockInfo b : blocks) { if(!b.isComplete()) { numUCBlocks++; } } } else { LOG.warn("The file {} is not under construction but has lease.", cons.getFullPathName()); } } > 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 > > > 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