hanishakoneru commented on a change in pull request #986:
URL: https://github.com/apache/hadoop-ozone/pull/986#discussion_r437073503



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -3027,30 +3017,59 @@ public TermIndex installSnapshot(String leaderId) {
     DBCheckpoint omDBcheckpoint = getDBCheckpointFromLeader(leaderId);
     Path newDBlocation = omDBcheckpoint.getCheckpointLocation();
 
-    // Check if current ratis log index is smaller than the downloaded
-    // snapshot index. If yes, proceed by stopping the ratis server so that
-    // the OM state can be re-initialized. If no, then do not proceed with
-    // installSnapshot.
     long lastAppliedIndex = omRatisServer.getLastAppliedTermIndex().getIndex();
-    long checkpointSnapshotIndex = omDBcheckpoint.getRatisSnapshotIndex();
-    long checkpointSnapshotTermIndex =
-        omDBcheckpoint.getRatisSnapshotTerm();
-    if (checkpointSnapshotIndex <= lastAppliedIndex) {
-      LOG.error("Failed to install checkpoint from OM leader: {}. The last " +
-          "applied index: {} is greater than or equal to the checkpoint's " +
-          "snapshot index: {}. Deleting the downloaded checkpoint {}", 
leaderId,
-          lastAppliedIndex, checkpointSnapshotIndex,
-          newDBlocation);
-      try {
-        FileUtils.deleteFully(newDBlocation);
-      } catch (IOException e) {
-        LOG.error("Failed to fully delete the downloaded DB checkpoint {} " +
-            "from OM leader {}.", newDBlocation,
-            leaderId, e);
+
+    // Check if current ratis log index is smaller than the downloaded
+    // checkpoint transaction index. If yes, proceed by stopping the ratis
+    // server so that the OM state can be re-initialized. If no, then do not
+    // proceed with installSnapshot.
+
+    OMTransactionInfo omTransactionInfo = null;
+    try {
+      // Set new DB location as DB path
+      OzoneConfiguration tempConfig = getConfiguration();
+
+      Path dbDir = newDBlocation.getParent();
+      if (dbDir != null) {
+        tempConfig.set(OZONE_OM_DB_DIRS, dbDir.toString());
+      } else {
+        LOG.error("Incorrect DB location path {} received from checkpoint.",
+            newDBlocation);
+        return null;
+      }
+
+      OMMetadataManager tempMetadataMgr =
+          new OmMetadataManagerImpl(configuration);

Review comment:
       This still seems very hacky. My suggestion is to move the logic inside 
OMMetadataManagerImpl#start() to a new method loadDB(File dbPath) which returns 
DBStore object. 
   
   
   ```
     public void start(OzoneConfiguration configuration) throws IOException {
       // We need to create the DB here, as when during restart, stop closes the
       // db, so we need to create the store object and initialize DB.
       if (store == null) {
           File metaDir = OMStorage.getOmDbDir(configuration);
           store = loadDB(metaDir);
           initializeOmTables();
       }
     }
   ```
   
   And after downloading the checkpoint from Leader, we would have to just call 
thie loadDB method with the location of the downloaded checkpoint. This way we 
can also keep the format of the downloaded checkpoint as before.
   
   




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

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