-
Notifications
You must be signed in to change notification settings - Fork 589
HDDS-7497. Fix mkdir does not update bucket's usedNamespace #3969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sadanand48
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xichen01 for working on this, left a few comments inline , please take a look
...-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMDirectoryCreateRequest.java
Show resolved
Hide resolved
...r/src/main/java/org/apache/hadoop/ozone/om/request/file/OMDirectoryCreateRequestWithFSO.java
Show resolved
Hide resolved
...ration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
Outdated
Show resolved
Hide resolved
...ration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
Outdated
Show resolved
Hide resolved
|
This is a user facing change, it would be good to describe the desired behavior for FSO, OBS and Legacy. |
|
This is more of a system specification rather than a bug. This is from Another example, would be considering how Recon's namespace disk usage works. When calculating disk usage we only consider the As you can see below, With all that said, I don't think we should make these changes. |
|
Thanks @xBis7 for your comments.
Currently Ozone directory create doesn’t account to an increment in the
I agree directories are zero sized keys and so they don't account for cc @ChenSammi @sumitagrawl any thoughts? |
@sadanand48 I wasn't aware of this issue. You are right, we don't have to correlate the namespace with the disk usage.
Although Hadoop is a separate project and |
|
The initial issue I encountered was finding that the |
xBis7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xichen01 I've left some comments inline. I confirmed in docker that it works with ozone fs commands such as mkdir and touch but usedNamespace should also be counting directories created with the ozone sh commands. It counts a key if it is created with ozone sh key put but if the keyname contains a directory that doesn't exist but is to be created then this directory won't be counted.
We might be able to fix this without having a different implementation for each bucket layout, by counting the levels of the keyName before incrementing usedNamespace. For this to work we should check if the directory already exists or needs to be created.
| @Nonnull List<OmKeyInfo> parentKeyInfos, @Nonnull Result result, | ||
| @Nonnull BucketLayout bucketLayout) { | ||
| @Nonnull List<OmKeyInfo> parentKeyInfos, @Nonnull OmBucketInfo bucketInfo, | ||
| @Nonnull Result result, @Nonnull BucketLayout bucketLayout) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding a new parameter to a method, it's best to add it at the end. This will make debugging easier and diffs much cleaner.
| @Nonnull Result result, @Nonnull BucketLayout bucketLayout) { | |
| @Nonnull BucketLayout bucketLayout, @Nonnull OmBucketInfo bucketInfo) { |
| super(omResponse, bucketLayout); | ||
| this.dirKeyInfo = dirKeyInfo; | ||
| this.parentKeyInfos = parentKeyInfos; | ||
| this.bucketInfo = bucketInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since we are changing the order of the parameters and adding bucketInfo at the end, this should also be moved at the end.
| @Nonnull OmDirectoryInfo dirInfo, | ||
| @Nonnull List<OmDirectoryInfo> pDirInfos, @Nonnull Result result, | ||
| @Nonnull List<OmDirectoryInfo> pDirInfos, | ||
| @Nonnull OmBucketInfo bucketInfo, @Nonnull Result result, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, @Nonnull OmBucketInfo bucketInfo should be the last parameter of the method.
| super(omResponse, bucketLayout); | ||
| this.dirInfo = dirInfo; | ||
| this.parentDirInfos = pDirInfos; | ||
| this.bucketInfo = bucketInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be below result.
| Optional.of(missingParentInfos), trxnLogIndex); | ||
| OmBucketInfo omBucketInfo = | ||
| getBucketInfo(omMetadataManager, volumeName, bucketName); | ||
| omBucketInfo.incrUsedNamespace(numMissingParents + 1L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be adding the number of missing keys to the used namespace? I can see that below call to logResult() is updating the metrics with the number.
| OMDirectoryCreateResponseWithFSO omDirectoryCreateResponseWithFSO = | ||
| new OMDirectoryCreateResponseWithFSO(omResponse, volumeId, bucketId, | ||
| omDirInfo, new ArrayList<>(), | ||
| omDirInfo, new ArrayList<>(), omBucketInfo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order of parameters
| public void testBucketUsedNamespace(BucketLayout layout) throws IOException { | ||
| String volumeName = UUID.randomUUID().toString(); | ||
| String bucketName = UUID.randomUUID().toString(); | ||
| OzoneVolume volume = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This is redundant. We can declare OzoneVolume along with the initialization below.
| String value = "sample value"; | ||
| int valueLength = value.getBytes(UTF_8).length; | ||
| store.createVolume(volumeName); | ||
| volume = store.getVolume(volumeName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| volume = store.getVolume(volumeName); | |
| OzoneVolume volume = store.getVolume(volumeName); |
| client.createDirectory(volumeName, bucketName, directoryName); | ||
| Assert.assertEquals(1L, | ||
| store.getVolume(volumeName).getBucket(bucketName).getUsedNamespace()); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be best to create multiple keys and directories and check in every step that we have the expected value in usedNamespace. Also we should check for the case where we are providing the directory directly with the key.
For example, if we create dir1/key1 and dir1/key2 without creating dir1 in advance, then unless we have an OBS bucket, the system will create dir1 and then two keys under it. In this case, usedNamespace should be 3.
| OMDirectoryCreateResponse omDirectoryCreateResponse = | ||
| new OMDirectoryCreateResponse(omResponse, omKeyInfo, | ||
| new ArrayList<>(), Result.SUCCESS, getBucketLayout()); | ||
| new ArrayList<>(), omBucketInfo, Result.SUCCESS, getBucketLayout()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order of parameters.
|
@xBis7 [root@linux ~/root/ozone]$ ozone sh bucket create s3v/bucket4 -l FILE_SYSTEM_OPTIMIZED
[root@linux ~/root/ozone]$ ozone sh key put /s3v/bucket4/dir1/dir2/dir3/dir4/file119 ~/1M.img
[root@linux ~/root/ozone]$ ozone sh key ls s3v/bucket4 | grep name
"name" : "dir1/",
"name" : "dir1/dir2/",
"name" : "dir1/dir2/dir3/",
"name" : "dir1/dir2/dir3/dir4/",
"name" : "dir1/dir2/dir3/dir4/file119",But for the Object bucket, these "missing paths" will not be created, they are not real, and should not increase Do you have any suggestions? |
@xichen01 From what I saw,
I agree.
You could get the We should count directories only for FSO buckets and LEGACY buckets with |
Yes agree @xBis7 , we should increment only if missing directories are created as part of key creates which is not the case for OBS. |
sadanand48
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xichen01 for updating the PR, the changes look good to me.
|
Thanks @xichen01 for the changes and @sadanand48 for the review. LGTM! I tested it locally and everything works as expected. |
* master: (110 commits) HDDS-7472. EC: Fix NSSummaryEndpoint#getDiskUsage for EC keys (apache#3987) HDDS-5704. Ozone URI syntax description in help content needs to mention about ozone service id (apache#3862) HDDS-7555. Upgrade Ratis to 2.4.2-8b8bdda-SNAPSHOT. (apache#4028) HDDS-7541. FSO recursive delete directory with hierarchy takes much time for cleanup (apache#4008) HDDS-7581. Fix update-jar-report for snapshot (apache#4034) HDDS-7253. Fix exception when '/' in key name (apache#4038) HDDS-7579. Use Netty 4.1.77 for consistency (apache#4031) HDDS-7562. Suppress warning about long filenames in tar (apache#4017) HDDS-7563. Add a handler for under replicated Ratis containers in RM (apache#4025) HDDS-7497. Fix mkdir does not update bucket's usedNamespace (apache#3969) HDDS-7567. Invalid entries in LICENSE (apache#4020) HDDS-7575. Correct showing of RATIS-THREE icon in Recon UI (apache#4026) HDDS-7540. Let reusable workflow inherit secrets (apache#4012) HDDS-7568. Bump copyright year in NOTICE (apache#4018) HDDS-7394. OM RPC FairCallQueue decay decision metrics list caller username in the metric (apache#3878) HDDS-7510. Recon: Return number of open containers in `/clusterState` endpoint (apache#3989) HDDS-7561. Improve setquota, clrquota CLI usage (apache#4016) HDDS-6615. EC: Improve write performance by pipelining encode and flush (apache#3994) HDDS-7554. Recon UI should show DORMANT in pipeline status filter (apache#4010) HDDS-7540. Separate scheduled CI from push/PR workflows (apache#4004) ...
What changes were proposed in this pull request?
Fix
Ozonefsmkdirdoes not update bucket'susedNamespaceWhat is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-7497
How was this patch tested?
Before this PR:
Bucket property
usedNamespacewill become negative after delete a directory, because themkdirwill not increase theusedNamespaceof bucket butrmdirwill decreaseusedNamespace.After this PR:
Bucket property
usedNamespacewill not be negative