Skip to main content

[xadisk~svn:537] 1. The initialization for the value of "distanceFromRecoveryCompletion" s

  • From: nitin_verma@...
  • To: commits@...
  • Subject: [xadisk~svn:537] 1. The initialization for the value of "distanceFromRecoveryCompletion" s
  • Date: Sun, 18 Aug 2013 19:17:26 +0000

Project:    xadisk
Repository: svn
Revision:   537
Author:     nitin_verma
Date:       2013-08-18 19:17:24 UTC
Link:       

Log Message:
------------
1. The initialization for the value of "distanceFromRecoveryCompletion" 
should happen before any possible transaction completion can happen (eg via 
TransactionCompleter).
2. The order in which the log files are processed may not be the same in 
which more than 1 checkpoints of a transaction were submitted (in different 
log files).


Revisions:
----------
537


Modified Paths:
---------------
trunk/src/org/xadisk/filesystem/workers/CrashRecoveryWorker.java


Diffs:
------
Index: trunk/src/org/xadisk/filesystem/workers/CrashRecoveryWorker.java
===================================================================
--- trunk/src/org/xadisk/filesystem/workers/CrashRecoveryWorker.java    
(revision 536)
+++ trunk/src/org/xadisk/filesystem/workers/CrashRecoveryWorker.java    
(revision 537)
@@ -104,6 +104,10 @@
             }
             
collectTransactionLogPositions(logChannels.get(logIndex).position(0), 
logIndex);
         }
+
+        distanceFromRecoveryCompletion.set(preparedInDoubtTransactions.size()
+                + onePhaseCommittingTransactions.size() + 
eventsDequeuePrepared.size()
+                + heavyWriteTransactionsForRollback.size());
     }
 
     public void run() {
@@ -112,9 +116,6 @@
             recoverOnePhaseTransactions();
             recoverHeavyWriteTransactionsForRollback();
             prepareEventsToPopulate();
-            
distanceFromRecoveryCompletion.set(preparedInDoubtTransactions.size()
-                    + onePhaseCommittingTransactions.size() + 
eventsDequeuePrepared.size()
-                    + heavyWriteTransactionsForRollback.size());
             checkForRecoveryDone();
         } catch (Throwable t) {
             xaFileSystem.notifySystemFailure(t);
@@ -216,7 +217,7 @@
                     addLogPositionToTransaction(xid, logIndex, 
filePositionAtBuffersBeginning);
                 }
                 if (logEntry.getOperationType() == 
TransactionLogEntry.CHECKPOINT_AVOIDING_COPY_OR_MOVE_REDO) {
-                    transactionsLatestCheckPoint.put(xid, 
logEntry.getCheckPointPosition());
+                    updateTransactionsLatestCheckPoint(xid, 
logEntry.getCheckPointPosition());
                 }
                 if (logEntry.getOperationType() == 
TransactionLogEntry.FILES_ALREADY_ONDISK) {
                     transactionsAndFilesWithLatestViewOnDisk.put(xid, 
logEntry.getFileList());
@@ -300,6 +301,15 @@
         return latestCheckPoint == null ? -1 : latestCheckPoint;
     }
 
+    private void updateTransactionsLatestCheckPoint(TransactionInformation 
xid, int checkPoint) {
+        int currentLatestCheckPoint = getTransactionsLatestCheckPoint(xid);
+        if(currentLatestCheckPoint < checkPoint) {
+            //as the multiple checkpoints from the same transaction could be 
spread across
+            //txn-logs and we may not discover them in increasing order.
+            transactionsLatestCheckPoint.put(xid, checkPoint);
+        }
+    }
+
     public HashSet<TransactionInformation> getPreparedInDoubtTransactions() {
         return preparedInDoubtTransactions;
     }





[xadisk~svn:537] 1. The initialization for the value of "distanceFromRecoveryCompletion" s

nitin_verma 08/18/2013
 
 
Close
loading
Please Confirm
Close