bharatviswa504 commented on a change in pull request #1613:
URL: https://github.com/apache/ozone/pull/1613#discussion_r536432935



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/upgrade/OMPrepareRequest.java
##########
@@ -166,36 +166,29 @@ private static void waitForDoubleBufferFlush(
    */
   public static long takeSnapshotAndPurgeLogs(RaftServerImpl impl)
       throws IOException {
-
     StateMachine stateMachine = impl.getStateMachine();
     long snapshotIndex = stateMachine.takeSnapshot();
+    RaftLog raftLog = impl.getState().getLog();
+    long raftLogIndex = raftLog.getLastEntryTermIndex().getIndex();
 
-    // If the snapshot indices from Ratis and the state machine do not match,
-    // the exception is propagated, resulting in an error response to the
-    // client. They can retry the prepare request.
-    if (snapshotIndex != stateMachine.getLastAppliedTermIndex().getIndex()) {
-      throw new IOException("Index from Snapshot does not match last applied " 
+
-          "Index");
+    if (snapshotIndex != raftLogIndex) {

Review comment:
       Right now adding this logic might have issue, as there is no safeguard 
logic to not allow further requests after PUR.

##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/upgrade/OMPrepareRequest.java
##########
@@ -137,16 +137,21 @@ private static void waitForDoubleBufferFlush(
       // If no transactions have been persisted to the DB, transaction info
       // will be null, not zero, causing a null pointer exception within
       // ozoneManager#getRatisSnaphotIndex.
-      // Get the transaction directly instead.
-      OMTransactionInfo txnInfo = ozoneManager.getMetadataManager()
+      // Get the transaction directly instead to handle the case when it is
+      // null.
+      OMTransactionInfo dbTxnInfo = ozoneManager.getMetadataManager()
           .getTransactionInfoTable().get(TRANSACTION_INFO_KEY);
-      if (txnInfo == null) {
-        success = (txnLogIndex == 0);
+      if (dbTxnInfo == null) {
+        // If there are no transactions in the DB, we are prepared to log

Review comment:
       When PUR is flushed, in DB of transactionInfo table still it is null 
means something wrong right?




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