hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (Jira)" <j...@apache.org>
Subject [jira] [Work logged] (HDFS-15532) listFiles on root/InternalDir will fail if fallback root has file
Date Sat, 12 Sep 2020 20:53:01 GMT

     [ https://issues.apache.org/jira/browse/HDFS-15532?focusedWorklogId=483073&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-483073
]

ASF GitHub Bot logged work on HDFS-15532:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Sep/20 20:52
            Start Date: 12/Sep/20 20:52
    Worklog Time Spent: 10m 
      Work Description: umamaheswararao commented on a change in pull request #2298:
URL: https://github.com/apache/hadoop/pull/2298#discussion_r487375686



##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I also realized this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I realized that, this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I also realized this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I realized that, this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I also realized this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I realized that, this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I also realized this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I realized that, this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I also realized this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks

##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
     public BlockLocation[] getFileBlockLocations(final FileStatus fs,
         final long start, final long len) throws
         FileNotFoundException, IOException {
+
+      // When application calls listFiles on internalDir, it would return
+      // RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
+      // is a chance of files exists under that internalDir in fallback.
+      // Iterator#next will call getFileBlockLocations with that files. So, we
+      // should return getFileBlockLocations on fallback. See HDFS-15532.
+      if (fs.getPath() != InodeTree.SlashPath && this.fsState
+          .getRootFallbackLink() != null) {
+        FileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path parent = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
+            InodeTree.SlashPath.toString() :
+            fs.getPath().getName();

Review comment:
       Thanks @ayushtkn for review! I have removed this redundant condition.
   I realized that, this bug exist in ViewFs as well. I fixed and added a test case for it.
Thanks




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 483073)
    Time Spent: 2h  (was: 1h 50m)

> listFiles on root/InternalDir will fail if fallback root has file
> -----------------------------------------------------------------
>
>                 Key: HDFS-15532
>                 URL: https://issues.apache.org/jira/browse/HDFS-15532
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>    Affects Versions: 3.4.0
>            Reporter: Uma Maheswara Rao G
>            Assignee: Uma Maheswara Rao G
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> listFiles implementation gets the RemoteIterator created in InternalViewFSDirFs as the
root is an InternalViewFSDir.  
> If there is a fallback and a file exist at root level, it would have collected when collecting
locatedStatuses. 
> When its iterating over to that fallbacks file from  RemoteIterator (which was returned
from InternalViewFSDirFs ), iterator's next will will call getFileBlockLocations if it's
a file.
> {code:java}
> @Override
> public LocatedFileStatus next() throws IOException {
>  System.out.println(this);
>  if (!hasNext()) {
>  throw new NoSuchElementException("No more entries in " + f);
>  }
>  FileStatus result = stats[i++];
>  // for files, use getBlockLocations(FileStatus, int, int) to avoid
>  // calling getFileStatus(Path) to load the FileStatus again
>  BlockLocation[] locs = result.isFile() ?
>  getFileBlockLocations(result, 0, result.getLen()) :
>  null;
>  return new LocatedFileStatus(result, locs);
> }{code}
>  
> this getFileBlockLocations will be made on InternalViewFSDirFs, as that Iterator created
originally from that fs. 
> InternalViewFSDirFs#getFileBlockLocations does not handle fallback cases. It's always
expecting "/", this means it always assuming the dir.
> But with the fallback and returning Iterator from InternalViewFSDirFs, will create problems.
> Probably we need to handle fallback case in getFileBlockLocations as well.( Fallback
only should be the reason for call coming to InternalViewFSDirFs with other than "/")
>  



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

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


Mime
View raw message