jojochuang commented on code in PR #10984:
URL: https://github.com/apache/ozone/pull/10984#discussion_r3763404430
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -944,6 +944,12 @@ public static long sumBlockLengths(OmKeyInfo omKeyInfo) {
/**
* Return bucket info for the specified bucket.
+ * <p>
+ * The returned {@link OmBucketInfo} is the cached instance, returned by
+ * reference. A caller that mutates it (for example quota accounting) before
a
+ * point where the request may still fail must first take a
+ * {@link OmBucketInfo#copyObject()} and publish that copy only on success,
+ * otherwise a failed request leaks the mutation into the cache.
*/
@Nullable
public static OmBucketInfo getBucketInfo(OMMetadataManager omMetadataManager,
Review Comment:
this method is used in 25 places. From what I can tell, at least
OMDirectoryCreateRequest has the same potential problem. I think we need more
guardrails to prevent this same bug from happening again.
A long term solution could include:
* Create two separate getters: getBucketInfoForUpdate() and
getBucketInfoReadOnly().
* getBucketInfoForUpdate() returns a copy of the object.
* Return an immutable/view interface - Define ReadOnlyBucketInfo with
getters only.
getBucketInfoReadOnly() returns ReadOnlyBucketInfo, not OmBucketInfo.
Mutation methods (incrUsedBytes, setters, etc.) are unavailable at compile
time.
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneClientMultipartUploadWithFSO.java:
##########
@@ -414,6 +416,62 @@ public void testMultipartUploadWithMissingParts() throws
Exception {
() -> completeMultipartUpload(bucket, keyName, uploadID, partsMap));
}
+ @Test
+ public void testFailedCompleteAfterParentDeletionDoesNotLeakNamespaceQuota()
Review Comment:
this is good. I suspect it's possible to make unit test with mocks inside
TestS3MultipartUploadCompleteRequest instead.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]