ivandika3 commented on code in PR #10023:
URL: https://github.com/apache/ozone/pull/10023#discussion_r3031887283


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCreateRequest.java:
##########
@@ -497,20 +498,34 @@ protected void validateAtomicRewrite(OmKeyInfo dbKeyInfo, 
KeyArgs keyArgs)
       }
     }
 
-    if (keyArgs.hasExpectedETag()) {
-      String expectedETag = keyArgs.getExpectedETag();
-      if (dbKeyInfo == null) {
-        throw new OMException("Key not found for If-Match",
-            OMException.ResultCodes.KEY_NOT_FOUND);
-      }
-      if (!dbKeyInfo.hasEtag()) {
-        throw new OMException("Key does not have an ETag",
-            OMException.ResultCodes.ETAG_NOT_AVAILABLE);
-      }
-      if (!dbKeyInfo.isEtagEquals(expectedETag)) {
-        throw new OMException("ETag mismatch",
-            OMException.ResultCodes.ETAG_MISMATCH);
-      }
+  }

Review Comment:
   Ok after think a bit more, I think using expectedDataGeneration ensure that 
only one PutObject can succeed even if two PutObject are using the same valid 
If-Match. 
   
   From the if-match semantic, if there are two concurrent clients that are 
calling PutObject with the same if-match, both should succeed since the ETag is 
the same although expectedDataGeneration are not the same. 
   
   So in the end, our implementation of if-match is more strict (not 
necessarily a bad thing). However, it might cause duplicated requests to be 
rejected. Let me know what you think. 



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCreateRequest.java:
##########
@@ -497,20 +498,34 @@ protected void validateAtomicRewrite(OmKeyInfo dbKeyInfo, 
KeyArgs keyArgs)
       }
     }
 
-    if (keyArgs.hasExpectedETag()) {
-      String expectedETag = keyArgs.getExpectedETag();
-      if (dbKeyInfo == null) {
-        throw new OMException("Key not found for If-Match",
-            OMException.ResultCodes.KEY_NOT_FOUND);
-      }
-      if (!dbKeyInfo.hasEtag()) {
-        throw new OMException("Key does not have an ETag",
-            OMException.ResultCodes.ETAG_NOT_AVAILABLE);
-      }
-      if (!dbKeyInfo.isEtagEquals(expectedETag)) {
-        throw new OMException("ETag mismatch",
-            OMException.ResultCodes.ETAG_MISMATCH);
-      }
+  }

Review Comment:
   Ok after thinking a bit more, I think using expectedDataGeneration ensure 
that only one PutObject can succeed even if two PutObject are using the same 
valid If-Match. 
   
   From the if-match semantic, if there are two concurrent clients that are 
calling PutObject with the same if-match, both should succeed since the ETag is 
the same although expectedDataGeneration are not the same. 
   
   So in the end, our implementation of if-match is more strict (not 
necessarily a bad thing). However, it might cause duplicated requests to be 
rejected. Let me know what you think. 



-- 
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]

Reply via email to