prashantpogde commented on code in PR #7193:
URL: https://github.com/apache/ozone/pull/7193#discussion_r1763705894
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyPurgeRequest.java:
##########
@@ -58,30 +63,46 @@ public OMKeyPurgeRequest(OMRequest omRequest) {
@Override
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
TermIndex termIndex) {
PurgeKeysRequest purgeKeysRequest = getOmRequest().getPurgeKeysRequest();
- List<DeletedKeys> bucketDeletedKeysList = purgeKeysRequest
- .getDeletedKeysList();
- List<SnapshotMoveKeyInfos> keysToUpdateList = purgeKeysRequest
- .getKeysToUpdateList();
- String fromSnapshot = purgeKeysRequest.hasSnapshotTableKey() ?
- purgeKeysRequest.getSnapshotTableKey() : null;
- List<String> keysToBePurgedList = new ArrayList<>();
+ List<DeletedKeys> bucketDeletedKeysList =
purgeKeysRequest.getDeletedKeysList();
+ List<SnapshotMoveKeyInfos> keysToUpdateList =
purgeKeysRequest.getKeysToUpdateList();
+ String fromSnapshot = purgeKeysRequest.hasSnapshotTableKey() ?
purgeKeysRequest.getSnapshotTableKey() : null;
OmMetadataManagerImpl omMetadataManager = (OmMetadataManagerImpl)
ozoneManager.getMetadataManager();
OMResponse.Builder omResponse = OmResponseUtil.getOMResponseBuilder(
getOmRequest());
- OMClientResponse omClientResponse = null;
- for (DeletedKeys bucketWithDeleteKeys : bucketDeletedKeysList) {
- for (String deletedKey : bucketWithDeleteKeys.getKeysList()) {
- keysToBePurgedList.add(deletedKey);
+
+ final SnapshotInfo fromSnapshotInfo;
+ try {
+ fromSnapshotInfo = fromSnapshot != null ?
SnapshotUtils.getSnapshotInfo(ozoneManager,
+ fromSnapshot) : null;
+ // Checking if this request is an old request or new one.
+ if (purgeKeysRequest.hasExpectedPreviousSnapshotID()) {
+ // Validating previous snapshot since while purging deletes, a
snapshot create request could make this purge
+ // directory request invalid on AOS since the deletedDirectory would
be in the newly created snapshot. Adding
+ // subdirectories could lead to not being able to reclaim sub-files
and subdirectories since the
+ // file/directory would be present in the newly created snapshot.
+ // Validating previous snapshot can ensure the chain hasn't changed.
+ UUID expectedPreviousSnapshotId =
purgeKeysRequest.getExpectedPreviousSnapshotID().hasUuid()
+ ?
fromProtobuf(purgeKeysRequest.getExpectedPreviousSnapshotID().getUuid()) : null;
+ validatePreviousSnapshotId(fromSnapshotInfo,
omMetadataManager.getSnapshotChainManager(),
+ expectedPreviousSnapshotId);
}
+ } catch (IOException e) {
+ LOG.error("Error occured while performing OMDirectoriesPurge. ", e);
+ return new OMKeyPurgeResponse(createErrorOMResponse(omResponse, e));
}
- final SnapshotInfo fromSnapshotInfo;
- try {
- fromSnapshotInfo = fromSnapshot == null ? null :
SnapshotUtils.getSnapshotInfo(ozoneManager, fromSnapshot);
- } catch (IOException ex) {
- return new OMKeyPurgeResponse(createErrorOMResponse(omResponse, ex));
+ List<String> keysToBePurgedList = new ArrayList<>();
+
+ for (DeletedKeys bucketWithDeleteKeys : bucketDeletedKeysList) {
+ keysToBePurgedList.addAll(bucketWithDeleteKeys.getKeysList());
+ }
+
+ if (keysToBePurgedList.isEmpty()) {
+ return new OMKeyPurgeResponse(createErrorOMResponse(omResponse,
Review Comment:
is this message right for this condition ?
--
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]