aswinshakil commented on code in PR #4571:
URL: https://github.com/apache/ozone/pull/4571#discussion_r1199180895
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -1574,18 +1596,35 @@ public OmSnapshot getLatestSnapshot(String volumeName,
String bucketName,
OmSnapshotManager snapshotManager)
throws IOException {
- String latestPathSnapshot =
- snapshotChainManager.getLatestPathSnapshot(volumeName
- + OM_KEY_PREFIX + bucketName);
- String snapTableKey = latestPathSnapshot != null ?
- snapshotChainManager.getTableKey(latestPathSnapshot) : null;
- SnapshotInfo snapInfo = snapTableKey != null ?
- getSnapshotInfoTable().get(snapTableKey) : null;
+ String snapshotPath = volumeName + OM_KEY_PREFIX + bucketName;
+ String latestPathSnapshot = snapshotChainManager
+ .getLatestPathSnapshot(snapshotPath);
+
+ SnapshotInfo snapInfo = null;
+ while (latestPathSnapshot != null) {
+ String snapTableKey = snapshotChainManager
+ .getTableKey(latestPathSnapshot);
+ snapInfo = getSnapshotInfoTable().get(snapTableKey);
+
+ if (snapInfo != null && snapInfo.getSnapshotStatus() ==
+ SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE) {
+ break;
+ }
+
+ // Update latestPathSnapshot if current snapshot is deleted.
+ if (snapshotChainManager.hasPreviousPathSnapshot(
+ snapshotPath, latestPathSnapshot)) {
+ latestPathSnapshot = snapshotChainManager
+ .previousPathSnapshot(snapshotPath, latestPathSnapshot);
+ } else {
+ latestPathSnapshot = null;
+ }
+ }
Review Comment:
Yes we should, I will update it.
--
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]