aswinshakil commented on code in PR #4571:
URL: https://github.com/apache/ozone/pull/4571#discussion_r1199178915


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/snapshot/OMSnapshotPurgeResponse.java:
##########
@@ -110,9 +119,18 @@ private void cleanupSnapshotChain(OmMetadataManagerImpl 
metadataManager,
 
       String snapshotTableKey = snapshotChainManager
           .getTableKey(nextGlobalSnapshotId);
-      SnapshotInfo nextGlobalSnapInfo =
-          metadataManager.getSnapshotInfoTable().get(snapshotTableKey);
-      if (nextGlobalSnapInfo != null) {
+      nextGlobalSnapInfo = metadataManager.getSnapshotInfoTable()
+          .get(snapshotTableKey);
+      // If both next global and path snapshot are same, it may overwrite
+      // nextPathSnapInfo.setPathPreviousSnapshotID(), adding this check
+      // will prevent it.
+      if (nextGlobalSnapInfo != null && nextGlobalSnapInfo.getSnapshotID()
+          .equals(nextPathSnapInfo.getSnapshotID())) {
+        nextPathSnapInfo.setGlobalPreviousSnapshotID(
+            snapInfo.getPathPreviousSnapshotID());
+        metadataManager.getSnapshotInfoTable().putWithBatch(batchOperation,
+            nextPathSnapInfo.getTableKey(), nextPathSnapInfo);
+      } else if (nextGlobalSnapInfo != null) {

Review Comment:
   The reason for using `else if` because `nextGlobalSnapInfo` can be `null` if 
we are deleting the last snapshot, so we need that 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