errose28 commented on code in PR #6385:
URL: https://github.com/apache/ozone/pull/6385#discussion_r1538360815


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -775,10 +775,19 @@ protected OmKeyInfo prepareFileInfo(
       dbKeyInfo.setReplicationConfig(replicationConfig);
 
       // Construct a new metadata map from KeyArgs.
-      // Clear the old one when the key is overwritten.
-      dbKeyInfo.getMetadata().clear();
-      dbKeyInfo.getMetadata().putAll(KeyValueUtil.getFromProtobuf(
-          keyArgs.getMetadataList()));
+      // Clear the old one when the key is overwritten unless it is a key 
overwrite
+      // using optimistic commit.
+      if (!keyArgs.hasOverwriteUpdateID()) {
+        dbKeyInfo.getMetadata().clear();
+        dbKeyInfo.getMetadata().putAll(KeyValueUtil.getFromProtobuf(
+            keyArgs.getMetadataList()));
+      }
+      if (keyArgs.hasOverwriteObjectID()) {
+        dbKeyInfo.setOverwriteObjectID(keyArgs.getOverwriteObjectID());
+      }
+      if (keyArgs.hasOverwriteUpdateID()) {
+        dbKeyInfo.setOverwriteUpdateID(keyArgs.getOverwriteUpdateID());
+      }

Review Comment:
   The original code is confusing because it copies the existing key and then 
modifies into the new key that gets aded to the open key table, while leaving 
the original in the DB. I checked the fields being modified in the original and 
it looks correct, including preserving the ACLs.



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