ChenSammi commented on code in PR #10183:
URL: https://github.com/apache/ozone/pull/10183#discussion_r4236632717


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -1439,24 +1489,28 @@ protected void validateIfMatchETag(KeyArgs keyArgs, 
OmKeyInfo dbKeyInfo)
    * Validates If-Match ETag condition and converts it to 
expectedDataGeneration.
    * <p>
    * This method checks if the existing key's ETag matches the expected ETag.
-   * If it matches, the ETag condition is converted to a generation-based 
condition
-   * for atomic commit validation in two-phase operations (CreateKey → 
CommitKey).
+   * If it matches, the ETag condition is converted to a generation-based
+   * condition for commit-time atomic rewrite validation.
    *
    * @param keyArgs the key arguments containing expected ETag
    * @param dbKeyInfo the existing key info from the database
+   * @param auditMap the audit map to update with the resolved generation
    * @return updated KeyArgs with expectedDataGeneration set (if ETag matched)
    * @throws OMException if validation fails
    */
-  protected KeyArgs validateAndRewriteIfMatchAsExpectedGeneration(
-      KeyArgs keyArgs, OmKeyInfo dbKeyInfo) throws OMException {
+  private KeyArgs validateAndResolveIfMatchAsExpectedGeneration(
+      KeyArgs keyArgs, OmKeyInfo dbKeyInfo, Map<String, String> auditMap) 
throws OMException {
     validateIfMatchETag(keyArgs, dbKeyInfo);
 
-    if (!keyArgs.hasExpectedETag() || keyArgs.hasExpectedDataGeneration()) {
+    if (!keyArgs.hasExpectedETag()) {
       return keyArgs;
     }
 
+    long expectedGen = dbKeyInfo.getUpdateID();
+    addRewriteGenerationToAuditMap(expectedGen, auditMap);
+
     return keyArgs.toBuilder()
-        .setExpectedDataGeneration(dbKeyInfo.getUpdateID())
+        .setExpectedDataGeneration(expectedGen)

Review Comment:
   BTW, it looks like verify the UpdateID in Ozone is stricter than AWS S3 in 
Etag case, since any metadata update will increase the UpdateID, while the 
content can still remains the same. 
   
   So if another client update the object's any metadata between the createKey 
and commitKey, then commitKey will fail in this case. 



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