kaijchen commented on code in PR #3286:
URL: https://github.com/apache/ozone/pull/3286#discussion_r859919660
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequest.java:
##########
@@ -196,36 +196,41 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager,
}
}
+ // If bucket versioning is turned on during the update, between key
+ // creation and key commit, old versions will be just overwritten and
+ // not kept. Bucket versioning will be effective from the first key
+ // creation after the knob turned on.
+ RepeatedOmKeyInfo oldKeyVersionsToDelete = null;
+ OmKeyInfo keyToDelete =
+ omMetadataManager.getKeyTable(getBucketLayout()).get(dbOzoneKey);
+ if (keyToDelete != null && !omBucketInfo.getIsVersionEnabled()) {
+ oldKeyVersionsToDelete = getOldVersionsToCleanUp(dbOzoneKey,
+ keyToDelete, omMetadataManager,
+ trxnLogIndex, ozoneManager.isRatisEnabled());
+ }
+
omKeyInfo =
omMetadataManager.getOpenKeyTable(getBucketLayout()).get(dbOpenKey);
if (omKeyInfo == null) {
throw new OMException("Failed to commit key, as " + dbOpenKey +
"entry is not found in the OpenKey table", KEY_NOT_FOUND);
}
+ omBucketInfo = getBucketInfo(omMetadataManager, volumeName, bucketName);
omKeyInfo.setDataSize(commitKeyArgs.getDataSize());
-
omKeyInfo.setModificationTime(commitKeyArgs.getModificationTime());
-
// Update the block length for each block
- List<OmKeyLocationInfo> allocatedLocationInfoList =
- omKeyInfo.getLatestVersionLocations().getLocationList();
omKeyInfo.updateLocationInfoList(locationInfoList, false);
-
// Set the UpdateID to current transactionLogIndex
omKeyInfo.setUpdateID(trxnLogIndex, ozoneManager.isRatisEnabled());
- // If bucket versioning is turned on during the update, between key
- // creation and key commit, old versions will be just overwritten and
- // not kept. Bucket versioning will be effective from the first key
- // creation after the knob turned on.
- RepeatedOmKeyInfo oldKeyVersionsToDelete = null;
- OmKeyInfo keyToDelete =
- omMetadataManager.getKeyTable(getBucketLayout()).get(dbOzoneKey);
- if (keyToDelete != null && !omBucketInfo.getIsVersionEnabled()) {
- oldKeyVersionsToDelete = getOldVersionsToCleanUp(dbOzoneKey,
- keyToDelete, omMetadataManager,
- trxnLogIndex, ozoneManager.isRatisEnabled());
+ long correctedSpace = omKeyInfo.getReplicatedSize();
+ // Subtract the size of blocks to be overwritten.
+ if (keyToDelete != null) {
+ correctedSpace -= keyToDelete.getReplicatedSize();
Review Comment:
If `keyToDelete` isn't `null`, we shouldn't increase usedNamespace.
--
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]