sodonnel commented on code in PR #6385:
URL: https://github.com/apache/ozone/pull/6385#discussion_r1535349852
##########
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:
I was also not sure why the meta data is explicitly cleared here in the
original code, while other key attributes are not. The metadata here, is a map
of key value pairs that can be attached to a key. For the overwrite case, we
just want to keep whatever is there hence the change here.
--
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]