You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Ayush Saxena (Jira)" <ji...@apache.org> on 2020/12/10 07:59:00 UTC

[jira] [Created] (HDDS-4574) Inconsistencies in case the parent of a open file is deleted/renamed.

Ayush Saxena created HDDS-4574:
----------------------------------

             Summary: Inconsistencies in case the parent of a open file is deleted/renamed.
                 Key: HDDS-4574
                 URL: https://issues.apache.org/jira/browse/HDDS-4574
             Project: Hadoop Distributed Data Store
          Issue Type: Bug
            Reporter: Ayush Saxena
            Assignee: Ayush Saxena


A test to depict the behaviour(if kept in TestRootedOzoneFileSystem)

 
{code:java}
public void testCloseFileWithMissingParent() throws Exception {
  // Test if the parent directory gets deleted before commit.
  Path parent = new Path(bucketPath, "parent");
  Path file = new Path(parent, "file");
  // Create file with missing parent, this would create parent directory.
  FSDataOutputStream stream = fs.create(file);
  stream.write("data".getBytes());
  // Delete the parent.
  fs.delete(parent, false);
  stream.close();
  assertTrue(fs.exists(file)); // File exists
  assertFalse(fs.exists(file.getParent())); // But the parent doesn't exist
  // (Breaks FileSystem semantics)

  //cleanup
  fs.delete(file,true);

  // Test if the parent directory gets renamed before commit.
  FSDataOutputStream stream1 = fs.create(file);
  stream1.write("data".getBytes());
  // Rename the parent.
  Path renamedPath = new Path(bucketPath, "parent1");
  assertTrue(fs.rename(parent, renamedPath));
  fs.exists(renamedPath);
  // Close should throw exception.
  stream1.close();
  assertTrue(fs.exists(file)); // File exists
  assertFalse(fs.exists(file.getParent())); // But the parent doesn't exist

  // Inconsistency induced in listing.
  FileStatus[] ls = fs.listStatus(bucketPath);
  assertTrue(ls.length == 2); // Only one elem should there that should be
  // the renamed path, but both renamed and original are shown. // Though only the renamed is accessible 
}
{code}
We should not allow committing a key, if the parent doesn't exist.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org