From: jihoonl Date: Thu, 1 Jul 2010 15:45:52 +0000 (+0000) Subject: change some bugs are fixed X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=83cc78b8a47fa51ede112ee27df622fc9247a6d2;p=IRC.git change some bugs are fixed --- diff --git a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c index dbd4b745..8c31e2dc 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c @@ -527,7 +527,7 @@ void *dstmAccept(void *acceptfd) { send_data((int)acceptfd,&response,sizeof(char)); } else { -// printf("Got new Leader! : %d\n",epoch_num); + printf("Got new Leader! : %d\n",epoch_num); pthread_mutex_lock(&recovery_mutex); currentEpoch = epoch_num; okCommit = TRANS_BEFORE; @@ -825,11 +825,13 @@ int readClientReq(trans_commit_data_t *transinfo, int acceptfd) { #endif /* Read fixed_data_t data structure */ - size = sizeof(fixed) - 1; + size = sizeof(fixed_data_t) - 1; ptr = (char *)&fixed; fixed.control = TRANS_REQUEST; timeout = recv_data((int)acceptfd, ptr+1, size); +// printf("%s -> Received transid = %u\n",__func__,fixed.transid); + /* Read list of mids */ int mcount = fixed.mcount; size = mcount * sizeof(unsigned int); @@ -964,24 +966,24 @@ int processClientReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, commitObjects(tNode->decision,fixed,transinfo,modptr,oidmod,acceptfd); tNode->status = TRANS_AFTER; } - if(okCommit == TRANS_AFTER) { -// printf("%s -> 11 \ttransID : %u decision : %d status : %d \n",__func__,tNode->transid,tNode->decision,tNode->status); -// sleep(3); + else { + tNode->decision = TRANS_ABORT; + tNode->status = TRANS_INPROGRESS; + thashInsert(fixed->transid,tNode->decision); + commitObjects(tNode->decision,fixed,transinfo,modptr,oidmod,acceptfd); + tNode->status = TRANS_AFTER; } } else { tNode->status = TRANS_WAIT; - printf("%s -> Waiting!! \ttransID : %u decision : %d status : %d \n",__func__,tNode->transid,tNode->decision,tNode->status); +// printf("%s -> Waiting!! \ttransID : %u decision : %d status : %d \n",__func__,tNode->transid,tNode->decision,tNode->status); +// sleep(3); randomdelay(); } }while(tNode->status != TRANS_AFTER); - if(okCommit == TRANS_AFTER) - { -// printf("%s -> TRANS_AFTER!! \ttransID : %u decision : %d status : %d \n",__func__,tNode->transid,tNode->decision,tNode->status); - } - +// printf("%s -> trans ID : %u is cleared\n",__func__,tNode->transid); pthread_mutex_lock(&translist_mutex); transList = tlistRemove(transList,fixed->transid); @@ -1865,7 +1867,7 @@ int stopTransactions(int TRANS_FLAG,unsigned int epoch_num) // printf("%s -> Higher Epoch is seen, walker->epoch = %u currentEpoch = %u\n",__func__,epoch_num,currentEpoch); return -1; } - sleep(3); +// sleep(5); } walker = walker->next; } @@ -1883,7 +1885,7 @@ int stopTransactions(int TRANS_FLAG,unsigned int epoch_num) pthread_mutex_lock(&translist_mutex); size = transList->size; // printf("%s -> size = %d\n",__func__,size); -// printf("%s -> okCommit = %d\n",__func__,okCommit); +// printf("%s -> okCommit = %d\n",__func__,okCommit); walker = transList->head; while(walker){ // 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); @@ -1896,7 +1898,8 @@ int stopTransactions(int TRANS_FLAG,unsigned int epoch_num) return -1; } - sleep(3); +// sleep(5); + randomdelay(); }while(size != 0); } @@ -1926,8 +1929,8 @@ void sendTransList(int acceptfd) tlist_node_t* transArray = tlistToArray(transList,&size); pthread_mutex_unlock(&translist_mutex); - if(transList->size != 0) - tlistPrint(transList); +// if(transList->size != 0) +// tlistPrint(transList); // printf("%s -> transList->size : %d size = %d\n",__func__,transList->size,size); diff --git a/Robust/src/Runtime/DSTM/interface_recovery/trans.c b/Robust/src/Runtime/DSTM/interface_recovery/trans.c index d82e2a95..1c8cfb7e 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/trans.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/trans.c @@ -89,6 +89,7 @@ int getResponse = 0; #ifdef RECOVERY + #define INCREASE_EPOCH(x,y,z) ((x/y+1)*y + z) /*********************************** * Global variables for Duplication @@ -1250,11 +1251,6 @@ int transCommit() { do { treplyretry = 0; - pthread_mutex_lock(&translist_mutex); - transList = tlistInsertNode(transList,transID,-3,TRYING_TO_COMMIT,epoch_num); - tNode = tlistSearch(transList,transID); - pthread_mutex_unlock(&translist_mutex); - /* Look through all the objects in the transaction record and make piles * for each machine involved in the transaction*/ if (firsttime) { @@ -1391,10 +1387,10 @@ int transCommit() { if(sd != 0) { char control; int timeout; // a variable to check if the connection is still alive. if it is -1, then need to transcommit again - printf("%s -> Waiting for mid : %s transID = %u\n",__func__,midtoIPString(midlist[i]),transID); +// printf("%s -> Waiting for mid : %s transID = %u\n",__func__,midtoIPString(midlist[i]),transID); timeout = recv_data(sd, &control, sizeof(char)); - printf("%s -> Received mid : %s control %d timeout = %d\n",__func__,midtoIPString(midlist[i]),control,timeout); +// printf("%s -> Received mid : %s control %d timeout = %d\n",__func__,midtoIPString(midlist[i]),control,timeout); //Update common data structure with new ctrl msg getReplyCtrl[i] = control; /* Recv Objects if participant sends TRANS_DISAGREE */ @@ -1458,6 +1454,10 @@ int transCommit() { } #endif // printf("%s -> transID = %u Passed this point\n",__func__,transID); + pthread_mutex_lock(&translist_mutex); + transList = tlistInsertNode(transList,transID,-3,TRYING_TO_COMMIT,epoch_num); + tNode = tlistSearch(transList,transID); + pthread_mutex_unlock(&translist_mutex); #ifdef CACHE if (finalResponse == TRANS_COMMIT) { @@ -1519,13 +1519,6 @@ int transCommit() { } } while (treplyretry && deadmid != -1); -#ifdef RECOVERY - - - - -#endif - if(finalResponse == TRANS_ABORT) { #ifdef TRANSSTATS numTransAbort++; @@ -1885,7 +1878,7 @@ void restoreDuplicationState(unsigned int deadHost,unsigned int epoch_num) if((flag = pingMachines(epoch_num,sdlist,&tList)) < 0) break; pthread_mutex_lock(&translist_mutex); - tlistPrint(tList); +// tlistPrint(tList); pthread_mutex_unlock(&translist_mutex); // getchar(); printf("%s -> I'm currently leader num : %d releaseing new lists\n\n",__func__,epoch_num); @@ -1913,7 +1906,7 @@ void restoreDuplicationState(unsigned int deadHost,unsigned int epoch_num) if(flag < 0) { printf("%s -> higher epoch\n",__func__); while(okCommit != TRANS_OK) { - //printf("%s -> Waiting\n",__func__); +// sleep(3); randomdelay(); }