You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "xloya (via GitHub)" <gi...@apache.org> on 2024/08/20 04:37:08 UTC
[PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
xloya opened a new pull request, #4592:
URL: https://github.com/apache/gravitino/pull/4592
### What changes were proposed in this pull request?
When the storage location of fileset has a trailing slash, the problem of not finding files may occur when traversing the directory using like the hadoop command: `hadoop dfs -ls -R gvfs://fileset/catalog/tmp/test/`. This PR detects the trailing slash when converting to a virtual path and aligns the prefix to be replaced.
### Why are the changes needed?
Fix: #4586
### How was this patch tested?
Add some UTs and test shell command locally.

--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1728225124
##########
clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java:
##########
@@ -607,4 +651,52 @@ public void testGetDefaultBlockSize() throws IOException {
assertEquals(32 * 1024 * 1024, fs.getDefaultBlockSize(managedFilesetPath));
}
}
+
+ @Test
+ public void testConvertFileStatusPathPrefix() throws IOException {
+ try (GravitinoVirtualFileSystem fs =
+ (GravitinoVirtualFileSystem) managedFilesetPath.getFileSystem(conf)) {
+ FileStatus fileStatus =
+ new FileStatus(1024, false, 1, 32 * 1024 * 1024, 1024, new Path("hdfs://hive:9000/test"));
+ // storage location end with "/"
+ String storageLocation = "hdfs://hive:9000/";
+ String virtualLocation = "gvfs://fileset/test_catalog/tmp/test_fileset";
Review Comment:
Yes, the current logic does not rely on the external truncate logic, and python can handle it correctly too.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1728200634
##########
clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java:
##########
@@ -607,4 +651,52 @@ public void testGetDefaultBlockSize() throws IOException {
assertEquals(32 * 1024 * 1024, fs.getDefaultBlockSize(managedFilesetPath));
}
}
+
+ @Test
+ public void testConvertFileStatusPathPrefix() throws IOException {
+ try (GravitinoVirtualFileSystem fs =
+ (GravitinoVirtualFileSystem) managedFilesetPath.getFileSystem(conf)) {
+ FileStatus fileStatus =
+ new FileStatus(1024, false, 1, 32 * 1024 * 1024, 1024, new Path("hdfs://hive:9000/test"));
+ // storage location end with "/"
+ String storageLocation = "hdfs://hive:9000/";
+ String virtualLocation = "gvfs://fileset/test_catalog/tmp/test_fileset";
Review Comment:
Do we support virtual path like this "gvfs://fileset/test_catalog/tmp/test_fileset/"? @xloya
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#issuecomment-2302305867
Hi @xloya have you verified the case mentioned in the issue, seems the issue reporter still has issues after applying your fix.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1728214117
##########
clients/client-python/gravitino/filesystem/gvfs.py:
##########
@@ -500,6 +501,12 @@ def _convert_actual_path(self, path, context: FilesetContext):
f"Path {path} does not start with valid prefix {actual_prefix}."
)
virtual_location = self._get_virtual_location(context.get_name_identifier())
+ # if the storage location is end with "/",
+ # we should truncate this to avoid replace issues.
+ if actual_prefix.endswith(self.SLASH) and not virtual_location.endswith(
Review Comment:
Virtual location which concated in the method of `_get_virtual_location` will not have the tailing slash, so we only need check the actual_prefix which actually is the storage location.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #4592:
URL: https://github.com/apache/gravitino/pull/4592
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#issuecomment-2301230132
Is this problem only existed in Hadoop command line, do we have similar issue when using gvfs SDK in both Java and Python?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1728217630
##########
clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java:
##########
@@ -607,4 +651,52 @@ public void testGetDefaultBlockSize() throws IOException {
assertEquals(32 * 1024 * 1024, fs.getDefaultBlockSize(managedFilesetPath));
}
}
+
+ @Test
+ public void testConvertFileStatusPathPrefix() throws IOException {
+ try (GravitinoVirtualFileSystem fs =
+ (GravitinoVirtualFileSystem) managedFilesetPath.getFileSystem(conf)) {
+ FileStatus fileStatus =
+ new FileStatus(1024, false, 1, 32 * 1024 * 1024, 1024, new Path("hdfs://hive:9000/test"));
+ // storage location end with "/"
+ String storageLocation = "hdfs://hive:9000/";
+ String virtualLocation = "gvfs://fileset/test_catalog/tmp/test_fileset";
Review Comment:
> the tailing slash will be truncated by Hadoop path class.
What if for the python code, do we have similar guarantees?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1728214117
##########
clients/client-python/gravitino/filesystem/gvfs.py:
##########
@@ -500,6 +501,12 @@ def _convert_actual_path(self, path, context: FilesetContext):
f"Path {path} does not start with valid prefix {actual_prefix}."
)
virtual_location = self._get_virtual_location(context.get_name_identifier())
+ # if the storage location is end with "/",
+ # we should truncate this to avoid replace issues.
+ if actual_prefix.endswith(self.SLASH) and not virtual_location.endswith(
Review Comment:
Virtual location which concated in the method of `_get_virtual_location` will not have the tailing slash, so we only need check the `actual_prefix` which actually is the storage location.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1728202699
##########
clients/client-python/gravitino/filesystem/gvfs.py:
##########
@@ -500,6 +501,12 @@ def _convert_actual_path(self, path, context: FilesetContext):
f"Path {path} does not start with valid prefix {actual_prefix}."
)
virtual_location = self._get_virtual_location(context.get_name_identifier())
+ # if the storage location is end with "/",
+ # we should truncate this to avoid replace issues.
+ if actual_prefix.endswith(self.SLASH) and not virtual_location.endswith(
Review Comment:
What if `actual_prefix` is not end with SLASH, whereas `virtual_location` is end with SLASH?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1728212383
##########
clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java:
##########
@@ -607,4 +651,52 @@ public void testGetDefaultBlockSize() throws IOException {
assertEquals(32 * 1024 * 1024, fs.getDefaultBlockSize(managedFilesetPath));
}
}
+
+ @Test
+ public void testConvertFileStatusPathPrefix() throws IOException {
+ try (GravitinoVirtualFileSystem fs =
+ (GravitinoVirtualFileSystem) managedFilesetPath.getFileSystem(conf)) {
+ FileStatus fileStatus =
+ new FileStatus(1024, false, 1, 32 * 1024 * 1024, 1024, new Path("hdfs://hive:9000/test"));
+ // storage location end with "/"
+ String storageLocation = "hdfs://hive:9000/";
+ String virtualLocation = "gvfs://fileset/test_catalog/tmp/test_fileset";
Review Comment:
Yeah, we support this case. Because the virtual location we concat is in a format similar to "gvfs://fileset/catalog/tmp/test_fileset", no matter whether the virtual path actually accessed has a trailing slash or not, it can be replaced correctly as long as the storage location is handled correctly. Actually when we use `new Path("gvfs://fileset/test_catalog/tmp/test_fileset/")`, the tailing slash will be truncated by Hadoop path class.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#issuecomment-2301274715
> Is this problem only existed in Hadoop command line, do we have similar issue when using gvfs SDK in both Java and Python?
I have added UTs for calling Hadoop GVFS's `getFileStatus` and `listStatus` methods directly, and the issue has been fixed.
I will see if Python GVFS has similar issues.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#issuecomment-2303513492
> Hi @xloya have you verified the case mentioned in the issue, seems the issue reporter still has issues after applying your fix.
Yeah, I have tested the issue locally on Hadoop 2.7.3 and Hadoop 3.1.0, and the issue has been fixed. Can you help me do a double-check locally?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1726134292
##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java:
##########
@@ -294,7 +296,27 @@ private Path getActualPathByIdentifier(
return new Path(storageLocation);
} else {
- return new Path(virtualPath.replaceFirst(virtualLocation, storageLocation));
+ // if the storage location ends with "/",
+ // we should handle the conversion specially
+ if (storageLocation.endsWith(SLASH)) {
+ String subPath = virtualPath.substring(virtualLocation.length());
+ // For example, if the virtual path is `gvfs://fileset/catalog/schema/test_fileset/ttt`,
+ // and the storage location is `hdfs://cluster:8020/user/`,
+ // we should replace `gvfs://fileset/catalog/schema/test_fileset` with
+ // `hdfs://localhost:8020/`.
Review Comment:
Fixed. It's `hdfs://localhost:8020/user` without the tailing slash, because the virtual path `gvfs://fileset/catalog/schema/test_fileset/ttt` already has a slash before the `ttt`.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "xloya (via GitHub)" <gi...@apache.org>.
xloya commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1726134292
##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java:
##########
@@ -294,7 +296,27 @@ private Path getActualPathByIdentifier(
return new Path(storageLocation);
} else {
- return new Path(virtualPath.replaceFirst(virtualLocation, storageLocation));
+ // if the storage location ends with "/",
+ // we should handle the conversion specially
+ if (storageLocation.endsWith(SLASH)) {
+ String subPath = virtualPath.substring(virtualLocation.length());
+ // For example, if the virtual path is `gvfs://fileset/catalog/schema/test_fileset/ttt`,
+ // and the storage location is `hdfs://cluster:8020/user/`,
+ // we should replace `gvfs://fileset/catalog/schema/test_fileset` with
+ // `hdfs://localhost:8020/`.
Review Comment:
Fixed. It's 'hdfs://localhost:8020/user' without tailing slash, because the virtual path `gvfs://fileset/catalog/schema/test_fileset/ttt` already has a slash before the `ttt`.
##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java:
##########
@@ -294,7 +296,27 @@ private Path getActualPathByIdentifier(
return new Path(storageLocation);
} else {
- return new Path(virtualPath.replaceFirst(virtualLocation, storageLocation));
+ // if the storage location ends with "/",
+ // we should handle the conversion specially
+ if (storageLocation.endsWith(SLASH)) {
+ String subPath = virtualPath.substring(virtualLocation.length());
+ // For example, if the virtual path is `gvfs://fileset/catalog/schema/test_fileset/ttt`,
+ // and the storage location is `hdfs://cluster:8020/user/`,
+ // we should replace `gvfs://fileset/catalog/schema/test_fileset` with
+ // `hdfs://localhost:8020/`.
Review Comment:
Fixed. It's `hdfs://localhost:8020/user` without tailing slash, because the virtual path `gvfs://fileset/catalog/schema/test_fileset/ttt` already has a slash before the `ttt`.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#4586] fix(filesystem): Fix convert the actual path which storage location end with slash [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #4592:
URL: https://github.com/apache/gravitino/pull/4592#discussion_r1725255421
##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java:
##########
@@ -294,7 +296,27 @@ private Path getActualPathByIdentifier(
return new Path(storageLocation);
} else {
- return new Path(virtualPath.replaceFirst(virtualLocation, storageLocation));
+ // if the storage location ends with "/",
+ // we should handle the conversion specially
+ if (storageLocation.endsWith(SLASH)) {
+ String subPath = virtualPath.substring(virtualLocation.length());
+ // For example, if the virtual path is `gvfs://fileset/catalog/schema/test_fileset/ttt`,
+ // and the storage location is `hdfs://cluster:8020/user/`,
+ // we should replace `gvfs://fileset/catalog/schema/test_fileset` with
+ // `hdfs://localhost:8020/`.
Review Comment:
It should be "hdfs://localhost:8020/user/", right? The comment seems not so correct.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org