neils-dev commented on code in PR #4525:
URL: https://github.com/apache/ozone/pull/4525#discussion_r1156623070


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java:
##########
@@ -180,6 +180,18 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager,
       omClientResponse = new OMSnapshotCreateResponse(
           omResponse.build(), snapshotInfo);
     } catch (IOException ex) {
+      // Remove snapshot from the SnapshotChainManager in case of any failure.
+      // It is possible that createSnapshot request fails after snapshot gets
+      // added to snapshot chain manager because couldn't add it to cache/DB.
+      // In that scenario, SnapshotChainManager#globalSnapshotId will point to
+      // failed createSnapshot request's snapshotId but in actual it doesn't
+      // exist in the SnapshotInfo table.
+      // If it doesn't get removed, OM restart will crash on
+      // SnapshotChainManager#loadFromSnapshotInfoTable because it could not
+      // find the previous snapshot which doesn't exist because it was never
+      // added to the SnapshotInfo table.
+      removeSnapshotInfoFromSnapshotChainManager(snapshotChainManager,

Review Comment:
   Thanks @hemantk-12 for finding the cause of this problem on restart and for 
your patch.
   
   We can check to see that if at time of exception the snapshot was added to 
the snapshotChain and needs to be removed by checking,
   `this.snapshotId == snapshotChainManager.getLatestGlobalSnapshot()`
   if _true_, then `removeSnapshotInfoFromSnapshotChainManager`, or similar.



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