sumitagrawl commented on code in PR #5891:
URL: https://github.com/apache/ozone/pull/5891#discussion_r1447299934


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java:
##########
@@ -493,15 +451,32 @@ public OzoneManagerDoubleBuffer 
buildDoubleBufferForRatis() {
    */
   @Override
   public long takeSnapshot() throws IOException {
-    LOG.info("Current Snapshot Index {}", getLastAppliedTermIndex());
-    TermIndex lastTermIndex = getLastAppliedTermIndex();
-    final TransactionInfo build = TransactionInfo.valueOf(lastTermIndex);
-    ozoneManager.setTransactionInfo(build);
-    Table<String, TransactionInfo> txnInfoTable =
-        ozoneManager.getMetadataManager().getTransactionInfoTable();
-    txnInfoTable.put(TRANSACTION_INFO_KEY, build);
+    // wait until applied == skipped
+    while (getLastAppliedTermIndex().getIndex() < lastSkippedIndex) {
+      try {
+        ozoneManagerDoubleBuffer.awaitFlush();
+      } catch (InterruptedException e) {
+        throw IOUtils.toInterruptedIOException("Interrupted 
ozoneManagerDoubleBuffer.awaitFlush", e);
+      }
+    }
+
+    return takeSnapshotImpl();
+  }
+
+  private synchronized long takeSnapshotImpl() throws IOException {
+    final TermIndex applied = getLastAppliedTermIndex();
+    final TermIndex notified = getLastNotifiedTermIndex();
+    final TermIndex snapshot = applied.compareTo(notified) > 0 ? applied : 
notified;
+    LOG.info(" applied = {}", applied);
+    LOG.info(" skipped = {}", lastSkippedIndex);
+    LOG.info("notified = {}", notified);
+    LOG.info("snapshot = {}", snapshot);
+
+    final TransactionInfo transactionInfo = TransactionInfo.valueOf(snapshot);
+    ozoneManager.setTransactionInfo(transactionInfo);
+    
ozoneManager.getMetadataManager().getTransactionInfoTable().put(TRANSACTION_INFO_KEY,
 transactionInfo);

Review Comment:
   As discussed, before call snapshot,
   1. applyTransaction executed previously is finished for response
   2. double buffer is flushed
   So based on this, no task pending which can cause parallel update



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