SaketaChalamchala commented on code in PR #10387:
URL: https://github.com/apache/ozone/pull/10387#discussion_r3583100892


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotLocalDataManager.java:
##########
@@ -392,25 +392,135 @@ private void init(OzoneConfiguration configuration, 
SnapshotChainManager chainMa
 
   }
 
-  private void checkOrphanSnapshotVersions(OMMetadataManager metadataManager, 
SnapshotChainManager chainManager)
+  /**
+   * Drains the snapshots currently queued in {@link 
#snapshotToBeCheckedForOrphans}.
+   * Each queued snapshot becomes a seed for a same-run ancestor cascade.
+   */
+  private void checkQueuedOrphanSnapshotVersions(OMMetadataManager 
metadataManager,
+      SnapshotChainManager chainManager)
       throws IOException {
-    for (Map.Entry<UUID, Integer> entry : 
snapshotToBeCheckedForOrphans.entrySet()) {
-      UUID snapshotId = entry.getKey();
-      int countBeforeCheck = entry.getValue();
-      checkOrphanSnapshotVersions(metadataManager, chainManager, snapshotId);
-      decrementOrphanCheckCount(snapshotId, countBeforeCheck);
+    Set<UUID> processedSnapshotIds = new HashSet<>();
+    List<UUID> queuedSnapshotIds = 
getQueuedSnapshotIdsByCreationTimeDesc(metadataManager, chainManager);

Review Comment:
   Using `creationTime` may be a good starting point. For purged snapshot it's 
most likely that `snapshotInfo` is removed from `snapshotInfoTable` by the time 
the YAML is processed for cleaning so `creationTime` will be null for those 
snapshots in that case. 
   Also in rare cases `creationTime` may be vulnerable to clock skew between 
OMs. 
   For ex, 
    - S1 `creationTime` is T3 
    - Leader change happens to an OM that is behind previous leader
    - S2 is created with `creationTime` T2. 
   
   What do you think about adding snapshot's `creationTxnInfo` at the time of 
YAML creation and using that to order the snapshots to check?



-- 
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]

Reply via email to