aswinshakil commented on code in PR #4935:
URL: https://github.com/apache/ozone/pull/4935#discussion_r1239083832
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotPurgeRequest.java:
##########
@@ -52,14 +66,61 @@ public OMClientResponse validateAndUpdateCache(OzoneManager
ozoneManager,
SnapshotPurgeRequest snapshotPurgeRequest = getOmRequest()
.getSnapshotPurgeRequest();
- List<String> snapshotDbKeys = snapshotPurgeRequest
- .getSnapshotDBKeysList();
+ try {
+ List<String> snapshotDbKeys = snapshotPurgeRequest
+ .getSnapshotDBKeysList();
+ List<String> snapInfosToUpdate = snapshotPurgeRequest
+ .getUpdatedSnapshotDBKeyList();
+ HashMap<String, SnapshotInfo> updatedSnapInfo = new HashMap<>();
- omClientResponse = new OMSnapshotPurgeResponse(omResponse.build(),
- snapshotDbKeys);
- addResponseToDoubleBuffer(trxnLogIndex, omClientResponse,
- omDoubleBufferHelper);
+ // Snapshots that are already deepCleaned by the KeyDeletingService
+ // can be marked as deepCleaned.
+ for (String snapTableKey : snapInfosToUpdate) {
+ SnapshotInfo snapInfo = omMetadataManager.getSnapshotInfoTable()
+ .get(snapTableKey);
+
+ updateSnapshotInfoAndCache(snapInfo, omMetadataManager,
+ trxnLogIndex, updatedSnapInfo, false);
+ }
+
+ // Snapshots that are purged by the SnapshotDeletingService
+ // will update the next snapshot so that is can be deep cleaned
+ // by the KeyDeletingService in the next run.
+ for (String snapTableKey : snapshotDbKeys) {
+ SnapshotInfo fromSnapshot = omMetadataManager.getSnapshotInfoTable()
+ .get(snapTableKey);
+
+ SnapshotInfo nextSnapshot = SnapshotUtils
+ .getNextActiveSnapshot(fromSnapshot,
+ snapshotChainManager, omSnapshotManager);
+ updateSnapshotInfoAndCache(nextSnapshot, omMetadataManager,
Review Comment:
It can go to `true` and `false` multiple times. Posting the example we
discussed here.
1. Create S1,S2,S3 -> all set to `true`
2. Deep Cleaning is done -> all set to `false` for S1,S2,S3.
3. Now we delete S2
4. S1 -> `false`, S3 -> `true` because for S3 previous reference has changed
as S2 no longer exists. So there can be other keys that can be reclaimed as
well
5. No we deep clean S3 -> then S3 becomes `false`
--
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]