Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8EC62D4B9 for ; Fri, 5 Oct 2012 16:14:04 +0000 (UTC) Received: (qmail 48335 invoked by uid 500); 5 Oct 2012 16:14:04 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 48284 invoked by uid 500); 5 Oct 2012 16:14:04 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 48216 invoked by uid 99); 5 Oct 2012 16:14:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2012 16:14:03 +0000 Date: Fri, 5 Oct 2012 16:14:03 +0000 (UTC) From: "Ivan A. Veselovsky (JIRA)" To: common-issues@hadoop.apache.org Message-ID: <2029457426.1436.1349453643980.JavaMail.jiratomcat@arcas> In-Reply-To: <190828806.128016.1348663390941.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (HADOOP-8849) FileUtil#fullyDelete should grant the target directories +rwx permissions before trying to delete them 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/HADOOP-8849?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ivan A. Veselovsky updated HADOOP-8849: --------------------------------------- Status: Patch Available (was: Open) > FileUtil#fullyDelete should grant the target directories +rwx permissions before trying to delete them > ------------------------------------------------------------------------------------------------------ > > Key: HADOOP-8849 > URL: https://issues.apache.org/jira/browse/HADOOP-8849 > Project: Hadoop Common > Issue Type: Improvement > Reporter: Ivan A. Veselovsky > Assignee: Ivan A. Veselovsky > Priority: Minor > Attachments: HADOOP-8849-vs-trunk-3.patch > > > 2 improvements are suggested for implementation of methods org.apache.hadoop.fs.FileUtil.fullyDelete(File) and org.apache.hadoop.fs.FileUtil.fullyDeleteContents(File): > > 1) We should grant +rwx permissions the target directories before trying to delete them. > The mentioned methods fail to delete directories that don't have read or execute permissions. > Actual problem appears if an hdfs-related test is timed out (with a short timeout like tens of seconds), and the forked test process is killed, some directories are left on disk that are not readable and/or executable. This prevents next tests from being executed properly because these directories cannot be deleted with FileUtil#fullyDelete(), so many subsequent tests fail. So, its recommended to grant the read, write, and execute permissions the directories whose content is to be deleted. > 2) Generic reliability improvement: we shouldn't rely upon File#delete() return value, use File#exists() instead. > FileUtil#fullyDelete() uses return value of method java.io.File#delete(), but this is not reliable because File#delete() returns true only if the file was deleted as a result of the #delete() method invocation. E.g. in the following code > if (f.exists()) { // 1 > return f.delete(); // 2 > } > if the file f was deleted by another thread or process between calls "1" and "2", this fragment will return "false", while the file f does not exist upon the method return. > So, better to write > if (f.exists()) { > f.delete(); > return !f.exists(); > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira