change
authorjihoonl <jihoonl>
Wed, 23 Jun 2010 06:47:09 +0000 (06:47 +0000)
committerjihoonl <jihoonl>
Wed, 23 Jun 2010 06:47:09 +0000 (06:47 +0000)
Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c
Robust/src/Runtime/DSTM/interface_recovery/trans.c
Robust/src/Runtime/DSTM/interface_recovery/translist.h

index a35a55c5a97a3ae53b06dcf6597bc21d4c5f734a..b9d594c59d4d31fc605c99b8459da0203e983cbe 100644 (file)
@@ -869,6 +869,10 @@ int readClientReq(trans_commit_data_t *transinfo, int acceptfd) {
     return 0;
   }
 
+  pthread_mutex_lock(&translist_mutex);
+  transList = tlistInsertNode(transList,fixed.transid,TRYING_TO_COMMIT,TRYING_TO_COMMIT,fixed.epoch_num);  
+  pthread_mutex_unlock(&translist_mutex);                                                    
+    
   /* Create an array of oids for modified objects */
   oidmod = (unsigned int *) calloc(fixed.nummod, sizeof(unsigned int));
   if (oidmod == NULL) {
@@ -944,16 +948,13 @@ int processClientReq(fixed_data_t *fixed, trans_commit_data_t *transinfo,
   if(timeout1 < 0 || timeout2 < 0) {  // timeout. failed to receiving data from coordinator
     control = DECISION_LOST;
   }
-  
-  pthread_mutex_lock(&translist_mutex);
-  transList = tlistInsertNode(transList,fixed->transid,control,TRYING_TO_COMMIT,epoch_num);
-  pthread_mutex_unlock(&translist_mutex);
 
   pthread_mutex_lock(&translist_mutex);
   tNode = tlistSearch(transList,fixed->transid);  
   pthread_mutex_unlock(&translist_mutex);         
   
   // check if it is allowed to commit
+  tNode->decision = control;
   do {
     tNode->status = TRANS_INPROGRESS; 
     if(okCommit != TRANS_BEFORE) {
@@ -969,7 +970,7 @@ int processClientReq(fixed_data_t *fixed, trans_commit_data_t *transinfo,
       }
     }
     else {
-      tNode->status = TRYING_TO_COMMIT;
+      tNode->status = TRANS_WAIT;
       printf("%s -> Waiting!! \ttransID : %u decision : %d status : %d \n",__func__,tNode->transid,tNode->decision,tNode->status);
       sleep(3);
       randomdelay();
@@ -1864,10 +1865,12 @@ int stopTransactions(int TRANS_FLAG,unsigned int epoch_num)
       while(walker)
       {
         // locking
-        while(walker->status == TRANS_INPROGRESS) {
-          printf("%s ->transid : %u - decision %d Status : %d Waitflag = %d\n",__func__,walker->transid,walker->decision,walker->status,TRANS_FLAG);
-          if(inspectEpoch(walker->epoch_num,"stopTrans_Before") < 0)
-            return -1;                                                
+        while(walker->status != TRANS_WAIT && tlistSearch(transList,walker->transid) != NULL) {
+          printf("%s -> BEFORE transid : %u - decision %d Status : %d \n",__func__,walker->transid,walker->decision,walker->status);
+          if(inspectEpoch(epoch_num,"stopTrans_Before") < 0) {
+            printf("%s -> Higher Epoch is seen, walker->epoch = %u currentEpoch = %u\n",__func__,epoch_num,currentEpoch);
+            return -1;                                     
+         }
           sleep(3);
         }
       walker = walker->next;
@@ -1889,13 +1892,15 @@ int stopTransactions(int TRANS_FLAG,unsigned int epoch_num)
       printf("%s -> okCommit = %d\n",__func__,okCommit);
       walker = transList->head;
       while(walker){
-        printf("%s ->transid : %u - decision %d Status : %d epoch = %u  current epoch : %u\n",__func__,walker->transid,walker->decision,walker->status,walker->epoch_num,currentEpoch);
+        printf("%s -> AFTER transid : %u - decision %d Status : %d epoch = %u  current epoch : %u\n",__func__,walker->transid,walker->decision,walker->status,walker->epoch_num,currentEpoch);
         walker = walker->next;
       }
       pthread_mutex_unlock(&translist_mutex);
 
-      if(inspectEpoch(epoch_num,"stopTrans_Before") < 0)
+      if(inspectEpoch(epoch_num,"stopTrans_Before") < 0) {
+        printf("%s -> 222Higher Epoch is seen, walker->epoch = %u currentEpoch = %u\n",__func__,epoch_num,currentEpoch);
         return -1;
+      }
 
       sleep(3);
     }while(size != 0);
index 6be4344dbfb9c97f85dfe37697a179e27dc106b9..1ad2913acfbd4a11e460f0ce215eba7579f33689 100644 (file)
@@ -1251,7 +1251,7 @@ int transCommit() {
     pthread_mutex_unlock(&recovery_mutex);
 
     pthread_mutex_lock(&translist_mutex);
-    transList = tlistInsertNode(transList,transID,TRYING_TO_COMMIT,TRYING_TO_COMMIT,epoch_num);
+    transList = tlistInsertNode(transList,transID,-3,TRYING_TO_COMMIT,epoch_num);
     tNode = tlistSearch(transList,transID);
     pthread_mutex_unlock(&translist_mutex);
 
index 9364fb4ded4e1b26e9675c0ed69e89f12124b3d0..9d2ab9da2cbb3802f5d6a56a99dfd6eac5e549df 100644 (file)
@@ -14,6 +14,7 @@
 #define TRANS_BEFORE 4
 #define TRANS_INPROGRESS   5
 #define TRANS_AFTER  6
+#define TRANS_WAIT   7
 
 /*
    Status