szetszwo commented on code in PR #5811:
URL: https://github.com/apache/ozone/pull/5811#discussion_r1434333956


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java:
##########
@@ -489,19 +489,24 @@ public OzoneManagerDoubleBuffer 
buildDoubleBufferForRatis() {
    */
   @Override
   public long takeSnapshot() throws IOException {
-    LOG.info("Current Snapshot Index {}", getLastAppliedTermIndex());
+    try {
+      awaitDoubleBufferFlush();
+    } catch (InterruptedException e) {
+      LOG.warn("double buffer wait is interrupted, ", e);
+      throw IOUtils.toInterruptedIOException("takeSnapshot is interrupted", e);
+    }
+    ozoneManager.getMetadataManager().getStore().flushDB();
+    TransactionInfo transactionInfo = ozoneManager.getMetadataManager()
+        .getTransactionInfoTable().get(TRANSACTION_INFO_KEY);
     TermIndex lastTermIndex = getLastAppliedTermIndex();
-    long lastAppliedIndex = lastTermIndex.getIndex();
+    LOG.info("Current Transaction Index {} lastAppliedTermIndex {}",
+        transactionInfo, lastTermIndex);
+    // update with lastAppliedTermIndex as snapshot have dependency with
+    // ratis commit index as triggered during notifyTermIndexUpdated after
+    // apply transaction. Can not use TRANSACTION_INFO_KEY from db
     snapshotInfo.updateTermIndex(lastTermIndex.getTerm(),

Review Comment:
   Should it be updated with `transactionInfo` instead?  We should use the on 
disk state instead of the memory state for snapshots.



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