You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Lisheng Sun (JIRA)" <ji...@apache.org> on 2019/02/15 02:19:00 UTC

[jira] [Created] (HADOOP-16112) fs.TrashPolicyDefault: can't create trash directory and race condition

Lisheng Sun created HADOOP-16112:
------------------------------------

             Summary: fs.TrashPolicyDefault: can't create trash directory and race condition
                 Key: HADOOP-16112
                 URL: https://issues.apache.org/jira/browse/HADOOP-16112
             Project: Hadoop Common
          Issue Type: Bug
          Components: common
    Affects Versions: 3.2.0
            Reporter: Lisheng Sun


here is race condition in method moveToTrash class TrashPolicyDefault

try {
if (!fs.mkdirs(baseTrashPath, PERMISSION))

{ // create current LOG.warn("Can't create(mkdir) trash directory: " + baseTrashPath); return false; }

} catch (FileAlreadyExistsException e) {
// find the path which is not a directory, and modify baseTrashPath
// & trashPath, then mkdirs
Path existsFilePath = baseTrashPath;
while (!fs.exists(existsFilePath))

{ existsFilePath = existsFilePath.getParent(); }

{color:#ff0000}// case{color}

{color:#ff0000}  other thread deletes existsFilePath here ,the results doesn't  meet expectation{color}

{color:#ff0000} for example{color}

{color:#ff0000}   there is /user/u_sunlisheng/.Trash/Current/user/u_sunlisheng/b{color}

{color:#ff0000}   when delete /user/u_sunlisheng/b/a. if existsFilePath is deleted, the result is /user/u_sunlisheng/.Trash/Current/user/u_sunlisheng+timstamp/b/a{color}

{color:#ff0000}  so  when existsFilePath is deleted, don't modify baseTrashPath.    {color}

baseTrashPath = new Path(baseTrashPath.toString().replace(
existsFilePath.toString(), existsFilePath.toString() + Time.now())
);

trashPath = new Path(baseTrashPath, trashPath.getName());
// retry, ignore current failure
--i;
continue;
} catch (IOException e)

{ LOG.warn("Can't create trash directory: " + baseTrashPath, e); cause = e; break; }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-dev-help@hadoop.apache.org