ozone icon indicating copy to clipboard operation
ozone copied to clipboard

HDDS-7253. Fix exception when '/' in key name

Open xichen01 opened this issue 3 years ago • 3 comments

What changes were proposed in this pull request?

Fix exception when '/' in key name

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-7253

How was this patch tested?

How to reproduce the bug

  • First put a key that containing '/'
[root@Linux /root/ozone]% bin/ozone sh key put s3v/testbucket/dir1/dir2/key1 ~/testfile
[root@Linux /root/ozone]% bin/ozone sh key ls s3v/testbucket/ | grep name
  "name" : "dir1/dir2/key1"
  • Execute command

ls command for keys containing '/' before this commit

[root@Linux /root/ozone]% bin/ozone fs -ls ofs://localhost/s3v/testbucket/
Found 1 items
drwxrwxrwx   - root root          0 2022-09-19 14:11 ofs://localhost/s3v/testbucket/dir1
[root@Linux /root/ozone]% bin/ozone fs -ls ofs://localhost/s3v/testbucket/dir1
ls: `ofs://localhost/s3v/testbucket/dir1': No such file or directory

after this commit

[root@Linux /root/ozone]% bin/ozone fs -ls ofs://localhost/s3v/testbucket/
Found 1 items
drwxrwxrwx   - root root          0 2022-09-19 14:37 ofs://localhost/s3v/testbucket/dir1
[root@Linux /root/ozone]% bin/ozone fs -ls ofs://localhost/s3v/testbucket/dir1
Found 1 items
drwxrwxrwx   - root root          0 2022-09-19 14:37 ofs://localhost/s3v/testbucket/dir1/dir2

for mv, mkdir, count command for keys containing '/'

before this commit

[root@Linux /root/ozone]% bin/ozone fs -count ofs://localhost/s3v/testbucket/
count: dir1: No such file or directory!
[root@Linux /root/ozone]% bin/ozone fs -mv ofs://localhost/s3v/testbucket/dir1 ofs://localhost/s3v/testbucket/dir2
mv: `ofs://localhost/s3v/testbucket/dir1': No such file or directory
[root@Linux /root/ozone]% bin/ozone fs -mkdir ofs://localhost/s3v/testbucket/dir1/dir2/key2
mkdir: `ofs://localhost/s3v/testbucket/dir1/dir2': No such file or directory

after this commit

[root@Linux /root/ozone]% bin/ozone fs -count ofs://localhost/s3v/testbucket/
           3            1            1048576 ofs://localhost/s3v/testbucket
[root@Linux /root/ozone]% bin/ozone fs -mv ofs://localhost/s3v/testbucket/dir1 ofs://localhost/s3v/testbucket/newdir1
[root@Linux /root/ozone]% bin/ozone fs -ls ofs://localhost/s3v/testbucket/
Found 1 items
drwxrwxrwx   - root root          0 2022-09-19 14:39 ofs://localhost/s3v/testbucket/newdir1
[root@Linux /root/ozone]% bin/ozone fs -mkdir ofs://localhost/s3v/testbucket/newdir1/dir2/dir3
[root@Linux /root/ozone]% bin/ozone fs -ls ofs://localhost/s3v/testbucket/newdir1/dir2/
Found 2 items
drwxrwxrwx   - root root          0 2022-09-19 14:43 ofs://localhost/s3v/testbucket/newdir1/dir2/dir3
-rw-rw-rw-   3 root root    1048576 2022-09-19 14:39 ofs://localhost/s3v/testbucket/newdir1/dir2/key1

xichen01 avatar Sep 22 '22 12:09 xichen01

when '/' in key name the listSatus will create a fake directory return to the client. The client will get the fake directory info through getfileStatus, but currently getfileStatus has no logic for fake directory, this is inconsistent with listStatus behavior, So some exceptions occur. This PR is to make listStatus and getFileStatus have the same behavior. https://github.com/apache/ozone/blob/6c1a5ee07eedfee3e40405bc2d36a7c07e66ab76/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java#L1700-L1711

The problem I'm currently having is that I can't use the -du/-count command. Since some keys have '/' in their names. For some already created and used buckets whose layout is LEGACY, some file system commands cannot be used due to the fake directory returned by listStatus. This should not be expected behavior, we should be able to handle this situation correctly

xichen01 avatar Sep 23 '22 03:09 xichen01

cc @duongkame

kerneltime avatar Sep 26 '22 15:09 kerneltime

@sadanand48 PTAL Thanks.

xichen01 avatar Oct 10 '22 17:10 xichen01

Thanks @xichen01 for the work, @duongkame and @sadanand48 for the review.

kaijchen avatar Oct 25 '22 12:10 kaijchen

Sorry I have to revert this commit because it's making ITestOzoneContractMkdir flaky. Please take a look and submit another PR for this fix. @xichen01

kaijchen avatar Oct 26 '22 03:10 kaijchen

@kaijchen Are there some failed operations I can refer to them? So I can find out which tests are flaky.

xichen01 avatar Oct 26 '22 08:10 xichen01

@kaijchen Are there some failed operations I can refer to them? So I can find out which tests are flaky.

Here is one of the failing case, but not the only one. Please run ITestOzoneContractMkdir multiple times to find out more. https://github.com/apache/ozone/actions/runs/3322837635/jobs/5492873757

kaijchen avatar Oct 26 '22 08:10 kaijchen

@xichen01 I think it would be better to have this fix, could you please take a look at the failures.

sadanand48 avatar Nov 28 '22 09:11 sadanand48

@xichen01 I can help take a look if you need.

kaijchen avatar Nov 28 '22 11:11 kaijchen

@sadanand48 @kaijchen Okay, I'll check this PR, I've looked at it briefly before, but I haven't identified possible reasons causing ITestOzoneContractMkdir flaky.

xichen01 avatar Nov 28 '22 16:11 xichen01

@xichen01 I can help take a look if you need.

yeah, thank you, I think it would be helpful, and if you have time, I will prioritize this issue as well

xichen01 avatar Nov 28 '22 16:11 xichen01

@xichen01 FYI, here is ITestOzoneContractMkdir repeated 100x with this PR merged. https://github.com/kaijchen/ozone/actions/runs/3570532658

kaijchen avatar Nov 29 '22 02:11 kaijchen

this is latest MR https://github.com/apache/ozone/pull/4038 @kaijchen I think the issue of ITestOzoneContractMkdir should have been fixed, can you run it multiple times to confirm the fix, I have run it multiple times on my Linux and have not reproduced the issue again, thanks a lot.

xichen01 avatar Dec 03 '22 16:12 xichen01