DbtcMain.cpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:428k
- lqhKeyReq->variableData[nextPos + 1] = sig1;
- lqhKeyReq->variableData[nextPos + 2] = sig2;
- lqhKeyReq->variableData[nextPos + 3] = sig3;
- if (Tkeylen < 4) {
- nextPos += Tkeylen;
- } else {
- nextPos += 4;
- }//if
- sig0 = regCachePtr->attrinfo0;
- sig1 = regCachePtr->attrinfo15[0];
- sig2 = regCachePtr->attrinfo15[1];
- sig3 = regCachePtr->attrinfo15[2];
- sig4 = regCachePtr->attrinfo15[3];
- UintR TlenAi = regCachePtr->lenAiInTckeyreq;
- lqhKeyReq->variableData[nextPos + 0] = sig0;
- lqhKeyReq->variableData[nextPos + 1] = sig1;
- lqhKeyReq->variableData[nextPos + 2] = sig2;
- lqhKeyReq->variableData[nextPos + 3] = sig3;
- lqhKeyReq->variableData[nextPos + 4] = sig4;
- nextPos += TlenAi;
- // Reset trigger count
- regTcPtr->accumulatingTriggerData.i = RNIL;
- regTcPtr->accumulatingTriggerData.p = NULL;
- regTcPtr->noFiredTriggers = 0;
- regTcPtr->triggerExecutionCount = 0;
- sendSignal(TBRef, GSN_LQHKEYREQ, signal,
- nextPos + LqhKeyReq::FixedSignalLength, JBB);
- }//Dbtc::sendlqhkeyreq()
- void Dbtc::packLqhkeyreq040Lab(Signal* signal,
- UintR anAttrBufIndex,
- BlockReference TBRef)
- {
- TcConnectRecord * const regTcPtr = tcConnectptr.p;
- CacheRecord * const regCachePtr = cachePtr.p;
- #ifdef ERROR_INSERT
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- if (ERROR_INSERTED(8009)) {
- if (regApiPtr->apiConnectstate == CS_STARTED) {
- attrbufptr.i = RNIL;
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- }//if
- if (ERROR_INSERTED(8010)) {
- if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
- attrbufptr.i = RNIL;
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- }//if
- #endif
- UintR TattrbufFilesize = cattrbufFilesize;
- AttrbufRecord *localAttrbufRecord = attrbufRecord;
- while (1) {
- if (anAttrBufIndex == RNIL) {
- UintR TtcTimer = ctcTimer;
- UintR Tread = (regTcPtr->operation == ZREAD);
- UintR Tsimple = (regCachePtr->opSimple == ZTRUE);
- UintR Tboth = Tread & Tsimple;
- setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
- jam();
- /*--------------------------------------------------------------------
- * WE HAVE SENT ALL THE SIGNALS OF THIS OPERATION. SET STATE AND EXIT.
- *---------------------------------------------------------------------*/
- releaseAttrinfo();
- if (Tboth) {
- jam();
- releaseSimpleRead(signal, apiConnectptr, tcConnectptr.p);
- return;
- }//if
- regTcPtr->tcConnectstate = OS_OPERATING;
- return;
- }//if
- if (anAttrBufIndex < TattrbufFilesize) {
- AttrbufRecord * const regAttrPtr = &localAttrbufRecord[anAttrBufIndex];
- anAttrBufIndex = regAttrPtr->attrbuf[ZINBUF_NEXT];
- sendAttrinfo(signal,
- tcConnectptr.i,
- regAttrPtr,
- TBRef);
- } else {
- TCKEY_abort(signal, 17);
- return;
- }//if
- }//while
- }//Dbtc::packLqhkeyreq040Lab()
- /* ========================================================================= */
- /* ------- RELEASE ALL ATTRINFO RECORDS IN AN OPERATION RECORD ------- */
- /* ========================================================================= */
- void Dbtc::releaseAttrinfo()
- {
- UintR Tmp;
- AttrbufRecordPtr Tattrbufptr;
- CacheRecord * const regCachePtr = cachePtr.p;
- UintR TattrbufFilesize = cattrbufFilesize;
- UintR TfirstfreeAttrbuf = cfirstfreeAttrbuf;
- Tattrbufptr.i = regCachePtr->firstAttrbuf;
- AttrbufRecord *localAttrbufRecord = attrbufRecord;
- while (Tattrbufptr.i < TattrbufFilesize) {
- Tattrbufptr.p = &localAttrbufRecord[Tattrbufptr.i];
- Tmp = Tattrbufptr.p->attrbuf[ZINBUF_NEXT];
- Tattrbufptr.p->attrbuf[ZINBUF_NEXT] = TfirstfreeAttrbuf;
- TfirstfreeAttrbuf = Tattrbufptr.i;
- Tattrbufptr.i = Tmp;
- jam();
- }//while
- if (Tattrbufptr.i == RNIL) {
- //---------------------------------------------------
- // Now we will release the cache record at the same
- // time as releasing the attrinfo records.
- //---------------------------------------------------
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- UintR TfirstfreeCacheRec = cfirstfreeCacheRec;
- UintR TCacheIndex = cachePtr.i;
- cfirstfreeAttrbuf = TfirstfreeAttrbuf;
- regCachePtr->nextCacheRec = TfirstfreeCacheRec;
- cfirstfreeCacheRec = TCacheIndex;
- regApiPtr->cachePtr = RNIL;
- return;
- }//if
- systemErrorLab(0);
- return;
- }//Dbtc::releaseAttrinfo()
- /* ========================================================================= */
- /* ------- RELEASE ALL RECORDS CONNECTED TO A SIMPLE OPERATION ------- */
- /* ========================================================================= */
- void Dbtc::releaseSimpleRead(Signal* signal,
- ApiConnectRecordPtr regApiPtr,
- TcConnectRecord* regTcPtr)
- {
- Uint32 Ttckeyrec = regApiPtr.p->tckeyrec;
- Uint32 TclientData = regTcPtr->clientData;
- Uint32 Tnode = regTcPtr->tcNodedata[0];
- Uint32 Tlqhkeyreqrec = regApiPtr.p->lqhkeyreqrec;
- Uint32 TsimpleReadCount = c_counters.csimpleReadCount;
- ConnectionState state = regApiPtr.p->apiConnectstate;
-
- regApiPtr.p->tcSendArray[Ttckeyrec] = TclientData;
- regApiPtr.p->tcSendArray[Ttckeyrec + 1] = TcKeyConf::SimpleReadBit | Tnode;
- regApiPtr.p->tckeyrec = Ttckeyrec + 2;
-
- unlinkReadyTcCon(signal);
- releaseTcCon();
- /**
- * No LQHKEYCONF in Simple/Dirty read
- * Therefore decrese no LQHKEYCONF(REF) we are waiting for
- */
- c_counters.csimpleReadCount = TsimpleReadCount + 1;
- regApiPtr.p->lqhkeyreqrec = --Tlqhkeyreqrec;
-
- if(Tlqhkeyreqrec == 0)
- {
- /**
- * Special case of lqhKeyConf_checkTransactionState:
- * - commit with zero operations: handle only for simple read
- */
- sendtckeyconf(signal, state == CS_START_COMMITTING);
- regApiPtr.p->apiConnectstate =
- (state == CS_START_COMMITTING ? CS_CONNECTED : state);
- setApiConTimer(regApiPtr.i, 0, __LINE__);
- return;
- }
-
- /**
- * Emulate LQHKEYCONF
- */
- lqhKeyConf_checkTransactionState(signal, regApiPtr.p);
- }//Dbtc::releaseSimpleRead()
- /* ------------------------------------------------------------------------- */
- /* ------- CHECK IF ALL TC CONNECTIONS ARE COMPLETED ------- */
- /* ------------------------------------------------------------------------- */
- void Dbtc::unlinkReadyTcCon(Signal* signal)
- {
- TcConnectRecordPtr urtTcConnectptr;
- TcConnectRecord * const regTcPtr = tcConnectptr.p;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- if (regTcPtr->prevTcConnect != RNIL) {
- jam();
- urtTcConnectptr.i = regTcPtr->prevTcConnect;
- ptrCheckGuard(urtTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
- urtTcConnectptr.p->nextTcConnect = regTcPtr->nextTcConnect;
- } else {
- jam();
- regApiPtr->firstTcConnect = regTcPtr->nextTcConnect;
- }//if
- if (regTcPtr->nextTcConnect != RNIL) {
- jam();
- urtTcConnectptr.i = regTcPtr->nextTcConnect;
- ptrCheckGuard(urtTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
- urtTcConnectptr.p->prevTcConnect = regTcPtr->prevTcConnect;
- } else {
- jam();
- regApiPtr->lastTcConnect = tcConnectptr.p->prevTcConnect;
- }//if
- }//Dbtc::unlinkReadyTcCon()
- void Dbtc::releaseTcCon()
- {
- TcConnectRecord * const regTcPtr = tcConnectptr.p;
- UintR TfirstfreeTcConnect = cfirstfreeTcConnect;
- UintR TconcurrentOp = c_counters.cconcurrentOp;
- UintR TtcConnectptrIndex = tcConnectptr.i;
- regTcPtr->tcConnectstate = OS_CONNECTED;
- regTcPtr->nextTcConnect = TfirstfreeTcConnect;
- regTcPtr->apiConnect = RNIL;
- regTcPtr->isIndexOp = false;
- regTcPtr->indexOp = RNIL;
- cfirstfreeTcConnect = TtcConnectptrIndex;
- c_counters.cconcurrentOp = TconcurrentOp - 1;
- }//Dbtc::releaseTcCon()
- void Dbtc::execPACKED_SIGNAL(Signal* signal)
- {
- LqhKeyConf * const lqhKeyConf = (LqhKeyConf *)signal->getDataPtr();
- UintR Ti;
- UintR Tstep = 0;
- UintR Tlength;
- UintR TpackedData[28];
- UintR Tdata1, Tdata2, Tdata3, Tdata4;
- jamEntry();
- Tlength = signal->length();
- if (Tlength > 25) {
- jam();
- systemErrorLab(signal);
- return;
- }//if
- Uint32* TpackDataPtr;
- for (Ti = 0; Ti < Tlength; Ti += 4) {
- Uint32* TsigDataPtr = &signal->theData[Ti];
- Tdata1 = TsigDataPtr[0];
- Tdata2 = TsigDataPtr[1];
- Tdata3 = TsigDataPtr[2];
- Tdata4 = TsigDataPtr[3];
- TpackDataPtr = &TpackedData[Ti];
- TpackDataPtr[0] = Tdata1;
- TpackDataPtr[1] = Tdata2;
- TpackDataPtr[2] = Tdata3;
- TpackDataPtr[3] = Tdata4;
- }//for
- while (Tlength > Tstep) {
- TpackDataPtr = &TpackedData[Tstep];
- Tdata1 = TpackDataPtr[0];
- Tdata2 = TpackDataPtr[1];
- Tdata3 = TpackDataPtr[2];
- lqhKeyConf->connectPtr = Tdata1 & 0x0FFFFFFF;
- lqhKeyConf->opPtr = Tdata2;
- lqhKeyConf->userRef = Tdata3;
- switch (Tdata1 >> 28) {
- case ZCOMMITTED:
- signal->header.theLength = 3;
- execCOMMITTED(signal);
- Tstep += 3;
- break;
- case ZCOMPLETED:
- signal->header.theLength = 3;
- execCOMPLETED(signal);
- Tstep += 3;
- break;
- case ZLQHKEYCONF:
- jam();
- Tdata1 = TpackDataPtr[3];
- Tdata2 = TpackDataPtr[4];
- Tdata3 = TpackDataPtr[5];
- Tdata4 = TpackDataPtr[6];
- lqhKeyConf->readLen = Tdata1;
- lqhKeyConf->transId1 = Tdata2;
- lqhKeyConf->transId2 = Tdata3;
- lqhKeyConf->noFiredTriggers = Tdata4;
- signal->header.theLength = LqhKeyConf::SignalLength;
- execLQHKEYCONF(signal);
- Tstep += LqhKeyConf::SignalLength;
- break;
- default:
- systemErrorLab(signal);
- return;
- }//switch
- }//while
- return;
- }//Dbtc::execPACKED_SIGNAL()
- void Dbtc::execLQHKEYCONF(Signal* signal)
- {
- const LqhKeyConf * const lqhKeyConf = (LqhKeyConf *)signal->getDataPtr();
- UintR compare_transid1, compare_transid2;
- BlockReference tlastLqhBlockref;
- UintR tlastLqhConnect;
- UintR treadlenAi;
- UintR TtcConnectptrIndex;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- tlastLqhConnect = lqhKeyConf->connectPtr;
- TtcConnectptrIndex = lqhKeyConf->opPtr;
- tlastLqhBlockref = lqhKeyConf->userRef;
- treadlenAi = lqhKeyConf->readLen;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- /*------------------------------------------------------------------------
- * NUMBER OF EXTERNAL TRIGGERS FIRED IN DATA[6]
- * OPERATION IS NOW COMPLETED. CHECK FOR CORRECT OPERATION POINTER
- * TO ENSURE NO CRASHES BECAUSE OF ERRONEUS NODES. CHECK STATE OF
- * OPERATION. THEN SET OPERATION STATE AND RETRIEVE ALL POINTERS
- * OF THIS OPERATION. PUT COMPLETED OPERATION IN LIST OF COMPLETED
- * OPERATIONS ON THE LQH CONNECT RECORD.
- *------------------------------------------------------------------------
- * THIS SIGNAL ALWAYS ARRIVE BEFORE THE ABORTED SIGNAL ARRIVES SINCE IT USES
- * THE SAME PATH BACK TO TC AS THE ABORTED SIGNAL DO. WE DO HOWEVER HAVE A
- * PROBLEM WHEN WE ENCOUNTER A TIME-OUT WAITING FOR THE ABORTED SIGNAL.
- * THEN THIS SIGNAL MIGHT ARRIVE WHEN THE TC CONNECT RECORD HAVE BEEN REUSED
- * BY OTHER TRANSACTION THUS WE CHECK THE TRANSACTION ID OF THE SIGNAL
- * BEFORE ACCEPTING THIS SIGNAL.
- * Due to packing of LQHKEYCONF the ABORTED signal can now arrive before
- * this.
- * This is more reason to ignore the signal if not all states are correct.
- *------------------------------------------------------------------------*/
- if (TtcConnectptrIndex >= TtcConnectFilesize) {
- TCKEY_abort(signal, 25);
- return;
- }//if
- TcConnectRecord* const regTcPtr = &localTcConnectRecord[TtcConnectptrIndex];
- OperationState TtcConnectstate = regTcPtr->tcConnectstate;
- tcConnectptr.i = TtcConnectptrIndex;
- tcConnectptr.p = regTcPtr;
- if (TtcConnectstate != OS_OPERATING) {
- warningReport(signal, 23);
- return;
- }//if
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- UintR TapiConnectptrIndex = regTcPtr->apiConnect;
- UintR TapiConnectFilesize = capiConnectFilesize;
- UintR Ttrans1 = lqhKeyConf->transId1;
- UintR Ttrans2 = lqhKeyConf->transId2;
- Uint32 noFired = lqhKeyConf->noFiredTriggers;
- if (TapiConnectptrIndex >= TapiConnectFilesize) {
- TCKEY_abort(signal, 29);
- return;
- }//if
- ApiConnectRecord * const regApiPtr =
- &localApiConnectRecord[TapiConnectptrIndex];
- apiConnectptr.i = TapiConnectptrIndex;
- apiConnectptr.p = regApiPtr;
- compare_transid1 = regApiPtr->transid[0] ^ Ttrans1;
- compare_transid2 = regApiPtr->transid[1] ^ Ttrans2;
- compare_transid1 = compare_transid1 | compare_transid2;
- if (compare_transid1 != 0) {
- warningReport(signal, 24);
- return;
- }//if
- #ifdef ERROR_INSERT
- if (ERROR_INSERTED(8029)) {
- systemErrorLab(signal);
- }//if
- if (ERROR_INSERTED(8003)) {
- if (regApiPtr->apiConnectstate == CS_STARTED) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- }//if
- if (ERROR_INSERTED(8004)) {
- if (regApiPtr->apiConnectstate == CS_RECEIVING) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- }//if
- if (ERROR_INSERTED(8005)) {
- if (regApiPtr->apiConnectstate == CS_REC_COMMITTING) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- }//if
- if (ERROR_INSERTED(8006)) {
- if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- }//if
- if (ERROR_INSERTED(8023)) {
- SET_ERROR_INSERT_VALUE(8024);
- return;
- }//if
- #endif
- UintR TtcTimer = ctcTimer;
- regTcPtr->lastLqhCon = tlastLqhConnect;
- regTcPtr->lastLqhNodeId = refToNode(tlastLqhBlockref);
- regTcPtr->noFiredTriggers = noFired;
- UintR Ttckeyrec = (UintR)regApiPtr->tckeyrec;
- UintR TclientData = regTcPtr->clientData;
- UintR TdirtyOp = regTcPtr->dirtyOp;
- ConnectionState TapiConnectstate = regApiPtr->apiConnectstate;
- if (Ttckeyrec > (ZTCOPCONF_SIZE - 2)) {
- TCKEY_abort(signal, 30);
- return;
- }
- if (TapiConnectstate == CS_ABORTING) {
- warningReport(signal, 27);
- return;
- }//if
- setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
- if (regTcPtr->isIndexOp) {
- jam();
- // This was an internal TCKEYREQ
- // will be returned unpacked
- regTcPtr->attrInfoLen = treadlenAi;
- } else {
- if (noFired == 0 && regTcPtr->triggeringOperation == RNIL) {
- jam();
- /*
- * Skip counting triggering operations the first round
- * since they will enter execLQHKEYCONF a second time
- * Skip counting internally generated TcKeyReq
- */
- regApiPtr->tcSendArray[Ttckeyrec] = TclientData;
- regApiPtr->tcSendArray[Ttckeyrec + 1] = treadlenAi;
- regApiPtr->tckeyrec = Ttckeyrec + 2;
- }//if
- }//if
- if (TdirtyOp == ZTRUE) {
- UintR Tlqhkeyreqrec = regApiPtr->lqhkeyreqrec;
- jam();
- releaseDirtyWrite(signal);
- regApiPtr->lqhkeyreqrec = Tlqhkeyreqrec - 1;
- } else {
- jam();
- if (noFired == 0) {
- jam();
- // No triggers to execute
- UintR Tlqhkeyconfrec = regApiPtr->lqhkeyconfrec;
- regApiPtr->lqhkeyconfrec = Tlqhkeyconfrec + 1;
- regTcPtr->tcConnectstate = OS_PREPARED;
- }
- }//if
- /**
- * And now decide what to do next
- */
- if (regTcPtr->triggeringOperation != RNIL) {
- jam();
- // This operation was created by a trigger execting operation
- // Restart it if we have executed all it's triggers
- TcConnectRecordPtr opPtr;
- opPtr.i = regTcPtr->triggeringOperation;
- ptrCheckGuard(opPtr, ctcConnectFilesize, localTcConnectRecord);
- opPtr.p->triggerExecutionCount--;
- if (opPtr.p->triggerExecutionCount == 0) {
- /*
- We have completed current trigger execution
- Continue triggering operation
- */
- jam();
- continueTriggeringOp(signal, opPtr.p);
- }
- } else if (noFired == 0) {
- // This operation did not fire any triggers, finish operation
- jam();
- if (regTcPtr->isIndexOp) {
- jam();
- setupIndexOpReturn(regApiPtr, regTcPtr);
- }
- lqhKeyConf_checkTransactionState(signal, regApiPtr);
- } else {
- // We have fired triggers
- jam();
- saveTriggeringOpState(signal, regTcPtr);
- if (regTcPtr->noReceivedTriggers == noFired) {
- ApiConnectRecordPtr transPtr;
-
- // We have received all data
- jam();
- transPtr.i = TapiConnectptrIndex;
- transPtr.p = regApiPtr;
- executeTriggers(signal, &transPtr);
- }
- // else wait for more trigger data
- }
- }//Dbtc::execLQHKEYCONF()
-
- void Dbtc::setupIndexOpReturn(ApiConnectRecord* regApiPtr,
- TcConnectRecord* regTcPtr)
- {
- regApiPtr->indexOpReturn = true;
- regApiPtr->indexOp = regTcPtr->indexOp;
- regApiPtr->clientData = regTcPtr->clientData;
- regApiPtr->attrInfoLen = regTcPtr->attrInfoLen;
- }
- /**
- * lqhKeyConf_checkTransactionState
- *
- * This functions checks state variables, and
- * decides if it should wait for more LQHKEYCONF signals
- * or if it should start commiting
- */
- void
- Dbtc::lqhKeyConf_checkTransactionState(Signal * signal,
- ApiConnectRecord * const apiConnectPtrP)
- {
- /*---------------------------------------------------------------*/
- /* IF THE COMMIT FLAG IS SET IN SIGNAL TCKEYREQ THEN DBTC HAS TO */
- /* SEND TCKEYCONF FOR ALL OPERATIONS EXCEPT THE LAST ONE. WHEN */
- /* THE TRANSACTION THEN IS COMMITTED TCKEYCONF IS SENT FOR THE */
- /* WHOLE TRANSACTION */
- /* IF THE COMMIT FLAG IS NOT RECECIVED DBTC WILL SEND TCKEYCONF */
- /* FOR ALL OPERATIONS, AND THEN WAIT FOR THE API TO CONCLUDE THE */
- /* TRANSACTION */
- /*---------------------------------------------------------------*/
- ConnectionState TapiConnectstate = apiConnectPtrP->apiConnectstate;
- UintR Tlqhkeyconfrec = apiConnectPtrP->lqhkeyconfrec;
- UintR Tlqhkeyreqrec = apiConnectPtrP->lqhkeyreqrec;
- int TnoOfOutStanding = Tlqhkeyreqrec - Tlqhkeyconfrec;
- switch (TapiConnectstate) {
- case CS_START_COMMITTING:
- if (TnoOfOutStanding == 0) {
- jam();
- diverify010Lab(signal);
- return;
- } else if (TnoOfOutStanding > 0) {
- if (apiConnectPtrP->tckeyrec == ZTCOPCONF_SIZE) {
- jam();
- sendtckeyconf(signal, 0);
- return;
- } else if (apiConnectPtrP->indexOpReturn) {
- jam();
- sendtckeyconf(signal, 0);
- return;
- }//if
- jam();
- return;
- } else {
- TCKEY_abort(signal, 44);
- return;
- }//if
- return;
- case CS_STARTED:
- case CS_RECEIVING:
- if (TnoOfOutStanding == 0) {
- jam();
- sendtckeyconf(signal, 2);
- return;
- } else {
- if (apiConnectPtrP->tckeyrec == ZTCOPCONF_SIZE) {
- jam();
- sendtckeyconf(signal, 0);
- return;
- } else if (apiConnectPtrP->indexOpReturn) {
- jam();
- sendtckeyconf(signal, 0);
- return;
- }//if
- jam();
- }//if
- return;
- case CS_REC_COMMITTING:
- if (TnoOfOutStanding > 0) {
- if (apiConnectPtrP->tckeyrec == ZTCOPCONF_SIZE) {
- jam();
- sendtckeyconf(signal, 0);
- return;
- } else if (apiConnectPtrP->indexOpReturn) {
- jam();
- sendtckeyconf(signal, 0);
- return;
- }//if
- jam();
- return;
- }//if
- TCKEY_abort(signal, 45);
- return;
- case CS_CONNECTED:
- jam();
- /*---------------------------------------------------------------*/
- /* WE HAVE CONCLUDED THE TRANSACTION SINCE IT WAS ONLY */
- /* CONSISTING OF DIRTY WRITES AND ALL OF THOSE WERE */
- /* COMPLETED. ENSURE TCKEYREC IS ZERO TO PREVENT ERRORS. */
- /*---------------------------------------------------------------*/
- apiConnectPtrP->tckeyrec = 0;
- return;
- default:
- TCKEY_abort(signal, 46);
- return;
- }//switch
- }//Dbtc::lqhKeyConf_checkTransactionState()
- void Dbtc::sendtckeyconf(Signal* signal, UintR TcommitFlag)
- {
- if(ERROR_INSERTED(8049)){
- CLEAR_ERROR_INSERT_VALUE;
- signal->theData[0] = TcContinueB::DelayTCKEYCONF;
- signal->theData[1] = apiConnectptr.i;
- signal->theData[2] = TcommitFlag;
- sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 3000, 3);
- return;
- }
-
- HostRecordPtr localHostptr;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- const UintR TopWords = (UintR)regApiPtr->tckeyrec;
- localHostptr.i = refToNode(regApiPtr->ndbapiBlockref);
- const Uint32 type = getNodeInfo(localHostptr.i).m_type;
- const bool is_api = (type >= NodeInfo::API && type <= NodeInfo::REP);
- const BlockNumber TblockNum = refToBlock(regApiPtr->ndbapiBlockref);
- const Uint32 Tmarker = (regApiPtr->commitAckMarker == RNIL) ? 0 : 1;
- ptrAss(localHostptr, hostRecord);
- UintR TcurrLen = localHostptr.p->noOfWordsTCKEYCONF;
- UintR confInfo = 0;
- TcKeyConf::setCommitFlag(confInfo, TcommitFlag == 1);
- TcKeyConf::setMarkerFlag(confInfo, Tmarker);
- const UintR TpacketLen = 6 + TopWords;
- regApiPtr->tckeyrec = 0;
- if (regApiPtr->indexOpReturn) {
- jam();
- // Return internally generated TCKEY
- TcKeyConf * const tcKeyConf = (TcKeyConf *)signal->getDataPtrSend();
- TcKeyConf::setNoOfOperations(confInfo, 1);
- tcKeyConf->apiConnectPtr = regApiPtr->indexOp;
- tcKeyConf->gci = regApiPtr->globalcheckpointid;
- tcKeyConf->confInfo = confInfo;
- tcKeyConf->transId1 = regApiPtr->transid[0];
- tcKeyConf->transId2 = regApiPtr->transid[1];
- tcKeyConf->operations[0].apiOperationPtr = regApiPtr->clientData;
- tcKeyConf->operations[0].attrInfoLen = regApiPtr->attrInfoLen;
- Uint32 sigLen = TcKeyConf::StaticLength + TcKeyConf::OperationLength;
- EXECUTE_DIRECT(DBTC, GSN_TCKEYCONF, signal, sigLen);
- regApiPtr->indexOpReturn = false;
- if (TopWords == 0) {
- jam();
- return; // No queued TcKeyConf
- }//if
- }//if
- if(TcommitFlag){
- jam();
- regApiPtr->m_exec_flag = 0;
- }
- TcKeyConf::setNoOfOperations(confInfo, (TopWords >> 1));
- if ((TpacketLen > 25) || !is_api){
- TcKeyConf * const tcKeyConf = (TcKeyConf *)signal->getDataPtrSend();
-
- jam();
- tcKeyConf->apiConnectPtr = regApiPtr->ndbapiConnect;
- tcKeyConf->gci = regApiPtr->globalcheckpointid;;
- tcKeyConf->confInfo = confInfo;
- tcKeyConf->transId1 = regApiPtr->transid[0];
- tcKeyConf->transId2 = regApiPtr->transid[1];
- copyFromToLen(®ApiPtr->tcSendArray[0],
- (UintR*)&tcKeyConf->operations,
- (UintR)ZTCOPCONF_SIZE);
- sendSignal(regApiPtr->ndbapiBlockref,
- GSN_TCKEYCONF, signal, (TpacketLen - 1), JBB);
- return;
- } else if (((TcurrLen + TpacketLen) > 25) && (TcurrLen > 0)) {
- jam();
- sendPackedTCKEYCONF(signal, localHostptr.p, localHostptr.i);
- TcurrLen = 0;
- } else {
- jam();
- updatePackedList(signal, localHostptr.p, localHostptr.i);
- }//if
- // -------------------------------------------------------------------------
- // The header contains the block reference of receiver plus the real signal
- // length - 3, since we have the real signal length plus one additional word
- // for the header we have to do - 4.
- // -------------------------------------------------------------------------
- UintR Tpack0 = (TblockNum << 16) + (TpacketLen - 4);
- UintR Tpack1 = regApiPtr->ndbapiConnect;
- UintR Tpack2 = regApiPtr->globalcheckpointid;
- UintR Tpack3 = confInfo;
- UintR Tpack4 = regApiPtr->transid[0];
- UintR Tpack5 = regApiPtr->transid[1];
-
- localHostptr.p->noOfWordsTCKEYCONF = TcurrLen + TpacketLen;
-
- localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 0] = Tpack0;
- localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 1] = Tpack1;
- localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 2] = Tpack2;
- localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 3] = Tpack3;
- localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 4] = Tpack4;
- localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 5] = Tpack5;
-
- UintR Ti;
- for (Ti = 6; Ti < TpacketLen; Ti++) {
- localHostptr.p->packedWordsTCKEYCONF[TcurrLen + Ti] =
- regApiPtr->tcSendArray[Ti - 6];
- }//for
- }//Dbtc::sendtckeyconf()
- void Dbtc::copyFromToLen(UintR* sourceBuffer, UintR* destBuffer, UintR Tlen)
- {
- UintR Tindex = 0;
- UintR Ti;
- while (Tlen >= 4) {
- UintR Tdata0 = sourceBuffer[Tindex + 0];
- UintR Tdata1 = sourceBuffer[Tindex + 1];
- UintR Tdata2 = sourceBuffer[Tindex + 2];
- UintR Tdata3 = sourceBuffer[Tindex + 3];
- Tlen -= 4;
- destBuffer[Tindex + 0] = Tdata0;
- destBuffer[Tindex + 1] = Tdata1;
- destBuffer[Tindex + 2] = Tdata2;
- destBuffer[Tindex + 3] = Tdata3;
- Tindex += 4;
- }//while
- for (Ti = 0; Ti < Tlen; Ti++, Tindex++) {
- destBuffer[Tindex] = sourceBuffer[Tindex];
- }//for
- }//Dbtc::copyFromToLen()
- void Dbtc::execSEND_PACKED(Signal* signal)
- {
- HostRecordPtr Thostptr;
- HostRecord *localHostRecord = hostRecord;
- UintR i;
- UintR TpackedListIndex = cpackedListIndex;
- jamEntry();
- for (i = 0; i < TpackedListIndex; i++) {
- Thostptr.i = cpackedList[i];
- ptrAss(Thostptr, localHostRecord);
- arrGuard(Thostptr.i - 1, MAX_NODES - 1);
- UintR TnoOfPackedWordsLqh = Thostptr.p->noOfPackedWordsLqh;
- UintR TnoOfWordsTCKEYCONF = Thostptr.p->noOfWordsTCKEYCONF;
- UintR TnoOfWordsTCINDXCONF = Thostptr.p->noOfWordsTCINDXCONF;
- jam();
- if (TnoOfPackedWordsLqh > 0) {
- jam();
- sendPackedSignalLqh(signal, Thostptr.p);
- }//if
- if (TnoOfWordsTCKEYCONF > 0) {
- jam();
- sendPackedTCKEYCONF(signal, Thostptr.p, (Uint32)Thostptr.i);
- }//if
- if (TnoOfWordsTCINDXCONF > 0) {
- jam();
- sendPackedTCINDXCONF(signal, Thostptr.p, (Uint32)Thostptr.i);
- }//if
- Thostptr.p->inPackedList = false;
- }//for
- cpackedListIndex = 0;
- return;
- }//Dbtc::execSEND_PACKED()
- void
- Dbtc::updatePackedList(Signal* signal, HostRecord* ahostptr, Uint16 ahostIndex)
- {
- if (ahostptr->inPackedList == false) {
- UintR TpackedListIndex = cpackedListIndex;
- jam();
- ahostptr->inPackedList = true;
- cpackedList[TpackedListIndex] = ahostIndex;
- cpackedListIndex = TpackedListIndex + 1;
- }//if
- }//Dbtc::updatePackedList()
- void Dbtc::sendPackedSignalLqh(Signal* signal, HostRecord * ahostptr)
- {
- UintR Tj;
- UintR TnoOfWords = ahostptr->noOfPackedWordsLqh;
- for (Tj = 0; Tj < TnoOfWords; Tj += 4) {
- UintR sig0 = ahostptr->packedWordsLqh[Tj + 0];
- UintR sig1 = ahostptr->packedWordsLqh[Tj + 1];
- UintR sig2 = ahostptr->packedWordsLqh[Tj + 2];
- UintR sig3 = ahostptr->packedWordsLqh[Tj + 3];
- signal->theData[Tj + 0] = sig0;
- signal->theData[Tj + 1] = sig1;
- signal->theData[Tj + 2] = sig2;
- signal->theData[Tj + 3] = sig3;
- }//for
- ahostptr->noOfPackedWordsLqh = 0;
- sendSignal(ahostptr->hostLqhBlockRef,
- GSN_PACKED_SIGNAL,
- signal,
- TnoOfWords,
- JBB);
- }//Dbtc::sendPackedSignalLqh()
- void Dbtc::sendPackedTCKEYCONF(Signal* signal,
- HostRecord * ahostptr,
- UintR hostId)
- {
- UintR Tj;
- UintR TnoOfWords = ahostptr->noOfWordsTCKEYCONF;
- BlockReference TBref = numberToRef(API_PACKED, hostId);
- for (Tj = 0; Tj < ahostptr->noOfWordsTCKEYCONF; Tj += 4) {
- UintR sig0 = ahostptr->packedWordsTCKEYCONF[Tj + 0];
- UintR sig1 = ahostptr->packedWordsTCKEYCONF[Tj + 1];
- UintR sig2 = ahostptr->packedWordsTCKEYCONF[Tj + 2];
- UintR sig3 = ahostptr->packedWordsTCKEYCONF[Tj + 3];
- signal->theData[Tj + 0] = sig0;
- signal->theData[Tj + 1] = sig1;
- signal->theData[Tj + 2] = sig2;
- signal->theData[Tj + 3] = sig3;
- }//for
- ahostptr->noOfWordsTCKEYCONF = 0;
- sendSignal(TBref, GSN_TCKEYCONF, signal, TnoOfWords, JBB);
- }//Dbtc::sendPackedTCKEYCONF()
- void Dbtc::sendPackedTCINDXCONF(Signal* signal,
- HostRecord * ahostptr,
- UintR hostId)
- {
- UintR Tj;
- UintR TnoOfWords = ahostptr->noOfWordsTCINDXCONF;
- BlockReference TBref = numberToRef(API_PACKED, hostId);
- for (Tj = 0; Tj < ahostptr->noOfWordsTCINDXCONF; Tj += 4) {
- UintR sig0 = ahostptr->packedWordsTCINDXCONF[Tj + 0];
- UintR sig1 = ahostptr->packedWordsTCINDXCONF[Tj + 1];
- UintR sig2 = ahostptr->packedWordsTCINDXCONF[Tj + 2];
- UintR sig3 = ahostptr->packedWordsTCINDXCONF[Tj + 3];
- signal->theData[Tj + 0] = sig0;
- signal->theData[Tj + 1] = sig1;
- signal->theData[Tj + 2] = sig2;
- signal->theData[Tj + 3] = sig3;
- }//for
- ahostptr->noOfWordsTCINDXCONF = 0;
- sendSignal(TBref, GSN_TCINDXCONF, signal, TnoOfWords, JBB);
- }//Dbtc::sendPackedTCINDXCONF()
- /*
- 4.3.11 DIVERIFY
- ---------------
- */
- /*****************************************************************************/
- /* D I V E R I F Y */
- /* */
- /*****************************************************************************/
- void Dbtc::diverify010Lab(Signal* signal)
- {
- UintR TfirstfreeApiConnectCopy = cfirstfreeApiConnectCopy;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- signal->theData[0] = apiConnectptr.i;
- if (ERROR_INSERTED(8022)) {
- jam();
- systemErrorLab(signal);
- }//if
- if (TfirstfreeApiConnectCopy != RNIL) {
- seizeApiConnectCopy(signal);
- regApiPtr->apiConnectstate = CS_PREPARE_TO_COMMIT;
- /*-----------------------------------------------------------------------
- * WE COME HERE ONLY IF THE TRANSACTION IS PREPARED ON ALL TC CONNECTIONS.
- * THUS WE CAN START THE COMMIT PHASE BY SENDING DIVERIFY ON ALL TC
- * CONNECTIONS AND THEN WHEN ALL DIVERIFYCONF HAVE BEEN RECEIVED THE
- * COMMIT MESSAGE CAN BE SENT TO ALL INVOLVED PARTS.
- *-----------------------------------------------------------------------*/
- EXECUTE_DIRECT(DBDIH, GSN_DIVERIFYREQ, signal, 1);
- if (signal->theData[2] == 0) {
- execDIVERIFYCONF(signal);
- }
- return;
- } else {
- /*-----------------------------------------------------------------------
- * There were no free copy connections available. We must abort the
- * transaction since otherwise we will have a problem with the report
- * to the application.
- * This should more or less not happen but if it happens we do not want to
- * crash and we do not want to create code to handle it properly since
- * it is difficult to test it and will be complex to handle a problem
- * more or less not occurring.
- *-----------------------------------------------------------------------*/
- terrorCode = ZSEIZE_API_COPY_ERROR;
- abortErrorLab(signal);
- return;
- }//if
- }//Dbtc::diverify010Lab()
- /* ------------------------------------------------------------------------- */
- /* ------- SEIZE_API_CONNECT ------- */
- /* SEIZE CONNECT RECORD FOR A REQUEST */
- /* ------------------------------------------------------------------------- */
- void Dbtc::seizeApiConnectCopy(Signal* signal)
- {
- ApiConnectRecordPtr locApiConnectptr;
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- UintR TapiConnectFilesize = capiConnectFilesize;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- locApiConnectptr.i = cfirstfreeApiConnectCopy;
- ptrCheckGuard(locApiConnectptr, TapiConnectFilesize, localApiConnectRecord);
- cfirstfreeApiConnectCopy = locApiConnectptr.p->nextApiConnect;
- locApiConnectptr.p->nextApiConnect = RNIL;
- regApiPtr->apiCopyRecord = locApiConnectptr.i;
- regApiPtr->triggerPending = false;
- regApiPtr->isIndexOp = false;
- }//Dbtc::seizeApiConnectCopy()
- void Dbtc::execDIVERIFYCONF(Signal* signal)
- {
- UintR TapiConnectptrIndex = signal->theData[0];
- UintR TapiConnectFilesize = capiConnectFilesize;
- UintR Tgci = signal->theData[1];
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- jamEntry();
- if (ERROR_INSERTED(8017)) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- if (TapiConnectptrIndex >= TapiConnectFilesize) {
- TCKEY_abort(signal, 31);
- return;
- }//if
- ApiConnectRecord * const regApiPtr =
- &localApiConnectRecord[TapiConnectptrIndex];
- ConnectionState TapiConnectstate = regApiPtr->apiConnectstate;
- UintR TApifailureNr = regApiPtr->failureNr;
- UintR Tfailure_nr = cfailure_nr;
- apiConnectptr.i = TapiConnectptrIndex;
- apiConnectptr.p = regApiPtr;
- if (TapiConnectstate != CS_PREPARE_TO_COMMIT) {
- TCKEY_abort(signal, 32);
- return;
- }//if
- /*--------------------------------------------------------------------------
- * THIS IS THE COMMIT POINT. IF WE ARRIVE HERE THE TRANSACTION IS COMMITTED
- * UNLESS EVERYTHING CRASHES BEFORE WE HAVE BEEN ABLE TO REPORT THE COMMIT
- * DECISION. THERE IS NO TURNING BACK FROM THIS DECISION FROM HERE ON.
- * WE WILL INSERT THE TRANSACTION INTO ITS PROPER QUEUE OF
- * TRANSACTIONS FOR ITS GLOBAL CHECKPOINT.
- *-------------------------------------------------------------------------*/
- if (TApifailureNr != Tfailure_nr) {
- DIVER_node_fail_handling(signal, Tgci);
- return;
- }//if
- commitGciHandling(signal, Tgci);
- /**************************************************************************
- * C O M M I T
- * THE TRANSACTION HAVE NOW BEEN VERIFIED AND NOW THE COMMIT PHASE CAN START
- **************************************************************************/
- UintR TtcConnectptrIndex = regApiPtr->firstTcConnect;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- regApiPtr->counter = regApiPtr->lqhkeyconfrec;
- regApiPtr->apiConnectstate = CS_COMMITTING;
- if (TtcConnectptrIndex >= TtcConnectFilesize) {
- TCKEY_abort(signal, 33);
- return;
- }//if
- TcConnectRecord* const regTcPtr = &localTcConnectRecord[TtcConnectptrIndex];
- tcConnectptr.i = TtcConnectptrIndex;
- tcConnectptr.p = regTcPtr;
- commit020Lab(signal);
- }//Dbtc::execDIVERIFYCONF()
- /*--------------------------------------------------------------------------*/
- /* COMMIT_GCI_HANDLING */
- /* SET UP GLOBAL CHECKPOINT DATA STRUCTURE AT THE COMMIT POINT. */
- /*--------------------------------------------------------------------------*/
- void Dbtc::commitGciHandling(Signal* signal, UintR Tgci)
- {
- GcpRecordPtr localGcpPointer;
- UintR TgcpFilesize = cgcpFilesize;
- UintR Tfirstgcp = cfirstgcp;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- GcpRecord *localGcpRecord = gcpRecord;
- regApiPtr->globalcheckpointid = Tgci;
- if (Tfirstgcp != RNIL) {
- /* IF THIS GLOBAL CHECKPOINT ALREADY EXISTS */
- localGcpPointer.i = Tfirstgcp;
- ptrCheckGuard(localGcpPointer, TgcpFilesize, localGcpRecord);
- do {
- if (regApiPtr->globalcheckpointid == localGcpPointer.p->gcpId) {
- jam();
- gcpPtr.i = localGcpPointer.i;
- gcpPtr.p = localGcpPointer.p;
- linkApiToGcp(signal);
- return;
- } else {
- localGcpPointer.i = localGcpPointer.p->nextGcp;
- jam();
- if (localGcpPointer.i != RNIL) {
- jam();
- ptrCheckGuard(localGcpPointer, TgcpFilesize, localGcpRecord);
- continue;
- }//if
- }//if
- seizeGcp(signal);
- linkApiToGcp(signal);
- return;
- } while (1);
- } else {
- jam();
- seizeGcp(signal);
- linkApiToGcp(signal);
- }//if
- }//Dbtc::commitGciHandling()
- /* --------------------------------------------------------------------------*/
- /* -LINK AN API CONNECT RECORD IN STATE PREPARED INTO THE LIST WITH GLOBAL - */
- /* CHECKPOINTS. WHEN THE TRANSACTION I COMPLETED THE API CONNECT RECORD IS */
- /* LINKED OUT OF THE LIST. */
- /*---------------------------------------------------------------------------*/
- void Dbtc::linkApiToGcp(Signal* signal)
- {
- ApiConnectRecordPtr localApiConnectptr;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- GcpRecord * const regGcpPtr = gcpPtr.p;
- UintR TapiConnectptrIndex = apiConnectptr.i;
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- regApiPtr->nextGcpConnect = RNIL;
- if (regGcpPtr->firstApiConnect == RNIL) {
- regGcpPtr->firstApiConnect = TapiConnectptrIndex;
- jam();
- } else {
- UintR TapiConnectFilesize = capiConnectFilesize;
- localApiConnectptr.i = regGcpPtr->lastApiConnect;
- jam();
- ptrCheckGuard(localApiConnectptr,
- TapiConnectFilesize, localApiConnectRecord);
- localApiConnectptr.p->nextGcpConnect = TapiConnectptrIndex;
- }//if
- UintR TlastApiConnect = regGcpPtr->lastApiConnect;
- regApiPtr->gcpPointer = gcpPtr.i;
- regApiPtr->prevGcpConnect = TlastApiConnect;
- regGcpPtr->lastApiConnect = TapiConnectptrIndex;
- }//Dbtc::linkApiToGcp()
- void Dbtc::seizeGcp(Signal* signal)
- {
- GcpRecordPtr tmpGcpPointer;
- GcpRecordPtr localGcpPointer;
- UintR Tfirstgcp = cfirstgcp;
- UintR Tglobalcheckpointid = apiConnectptr.p->globalcheckpointid;
- UintR TgcpFilesize = cgcpFilesize;
- GcpRecord *localGcpRecord = gcpRecord;
- localGcpPointer.i = cfirstfreeGcp;
- ptrCheckGuard(localGcpPointer, TgcpFilesize, localGcpRecord);
- UintR TfirstfreeGcp = localGcpPointer.p->nextGcp;
- localGcpPointer.p->gcpId = Tglobalcheckpointid;
- localGcpPointer.p->nextGcp = RNIL;
- localGcpPointer.p->firstApiConnect = RNIL;
- localGcpPointer.p->lastApiConnect = RNIL;
- localGcpPointer.p->gcpNomoretransRec = ZFALSE;
- cfirstfreeGcp = TfirstfreeGcp;
- if (Tfirstgcp == RNIL) {
- jam();
- cfirstgcp = localGcpPointer.i;
- } else {
- tmpGcpPointer.i = clastgcp;
- jam();
- ptrCheckGuard(tmpGcpPointer, TgcpFilesize, localGcpRecord);
- tmpGcpPointer.p->nextGcp = localGcpPointer.i;
- }//if
- clastgcp = localGcpPointer.i;
- gcpPtr = localGcpPointer;
- }//Dbtc::seizeGcp()
- /*---------------------------------------------------------------------------*/
- // Send COMMIT messages to all LQH operations involved in the transaction.
- /*---------------------------------------------------------------------------*/
- void Dbtc::commit020Lab(Signal* signal)
- {
- TcConnectRecordPtr localTcConnectptr;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- localTcConnectptr.p = tcConnectptr.p;
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- UintR Tcount = 0;
- do {
- /*-----------------------------------------------------------------------
- * WE ARE NOW READY TO RELEASE ALL OPERATIONS ON THE LQH
- *-----------------------------------------------------------------------*/
- /* *********< */
- /* COMMIT < */
- /* *********< */
- localTcConnectptr.i = localTcConnectptr.p->nextTcConnect;
- localTcConnectptr.p->tcConnectstate = OS_COMMITTING;
- sendCommitLqh(signal, localTcConnectptr.p);
- if (localTcConnectptr.i != RNIL) {
- Tcount = Tcount + 1;
- if (Tcount < 16) {
- ptrCheckGuard(localTcConnectptr,
- TtcConnectFilesize, localTcConnectRecord);
- jam();
- continue;
- } else {
- jam();
- if (ERROR_INSERTED(8014)) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- signal->theData[0] = TcContinueB::ZSEND_COMMIT_LOOP;
- signal->theData[1] = apiConnectptr.i;
- signal->theData[2] = localTcConnectptr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
- return;
- }//if
- } else {
- jam();
- regApiPtr->apiConnectstate = CS_COMMIT_SENT;
- return;
- }//if
- } while (1);
- }//Dbtc::commit020Lab()
- void Dbtc::sendCommitLqh(Signal* signal,
- TcConnectRecord * const regTcPtr)
- {
- HostRecordPtr Thostptr;
- UintR ThostFilesize = chostFilesize;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- Thostptr.i = regTcPtr->lastLqhNodeId;
- ptrCheckGuard(Thostptr, ThostFilesize, hostRecord);
- if (Thostptr.p->noOfPackedWordsLqh > 21) {
- jam();
- sendPackedSignalLqh(signal, Thostptr.p);
- } else {
- jam();
- updatePackedList(signal, Thostptr.p, Thostptr.i);
- }//if
- UintR Tindex = Thostptr.p->noOfPackedWordsLqh;
- UintR* TDataPtr = &Thostptr.p->packedWordsLqh[Tindex];
- UintR Tdata1 = regTcPtr->lastLqhCon;
- UintR Tdata2 = regApiPtr->globalcheckpointid;
- UintR Tdata3 = regApiPtr->transid[0];
- UintR Tdata4 = regApiPtr->transid[1];
- TDataPtr[0] = Tdata1 | (ZCOMMIT << 28);
- TDataPtr[1] = Tdata2;
- TDataPtr[2] = Tdata3;
- TDataPtr[3] = Tdata4;
- Thostptr.p->noOfPackedWordsLqh = Tindex + 4;
- }//Dbtc::sendCommitLqh()
- void
- Dbtc::DIVER_node_fail_handling(Signal* signal, UintR Tgci)
- {
- /*------------------------------------------------------------------------
- * AT LEAST ONE NODE HAS FAILED DURING THE TRANSACTION. WE NEED TO CHECK IF
- * THIS IS SO SERIOUS THAT WE NEED TO ABORT THE TRANSACTION. IN BOTH THE
- * ABORT AND THE COMMIT CASES WE NEED TO SET-UP THE DATA FOR THE
- * ABORT/COMMIT/COMPLETE HANDLING AS ALSO USED BY TAKE OVER FUNCTIONALITY.
- *------------------------------------------------------------------------*/
- tabortInd = ZFALSE;
- setupFailData(signal);
- if (false && tabortInd == ZFALSE) {
- jam();
- commitGciHandling(signal, Tgci);
- toCommitHandlingLab(signal);
- } else {
- jam();
- apiConnectptr.p->returnsignal = RS_TCROLLBACKREP;
- apiConnectptr.p->returncode = ZNODEFAIL_BEFORE_COMMIT;
- toAbortHandlingLab(signal);
- }//if
- return;
- }//Dbtc::DIVER_node_fail_handling()
- /* ------------------------------------------------------------------------- */
- /* ------- ENTER COMMITTED ------- */
- /* */
- /* ------------------------------------------------------------------------- */
- void Dbtc::execCOMMITTED(Signal* signal)
- {
- TcConnectRecordPtr localTcConnectptr;
- ApiConnectRecordPtr localApiConnectptr;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- UintR TapiConnectFilesize = capiConnectFilesize;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- #ifdef ERROR_INSERT
- if (ERROR_INSERTED(8018)) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- if (ERROR_INSERTED(8030)) {
- systemErrorLab(signal);
- }//if
- if (ERROR_INSERTED(8025)) {
- SET_ERROR_INSERT_VALUE(8026);
- return;
- }//if
- if (ERROR_INSERTED(8041)) {
- CLEAR_ERROR_INSERT_VALUE;
- sendSignalWithDelay(cownref, GSN_COMMITTED, signal, 2000, 3);
- return;
- }//if
- if (ERROR_INSERTED(8042)) {
- SET_ERROR_INSERT_VALUE(8046);
- sendSignalWithDelay(cownref, GSN_COMMITTED, signal, 2000, 4);
- return;
- }//if
- #endif
- localTcConnectptr.i = signal->theData[0];
- jamEntry();
- ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
- localApiConnectptr.i = localTcConnectptr.p->apiConnect;
- if (localTcConnectptr.p->tcConnectstate != OS_COMMITTING) {
- warningReport(signal, 4);
- return;
- }//if
- ptrCheckGuard(localApiConnectptr, TapiConnectFilesize,
- localApiConnectRecord);
- UintR Tcounter = localApiConnectptr.p->counter - 1;
- ConnectionState TapiConnectstate = localApiConnectptr.p->apiConnectstate;
- UintR Tdata1 = localApiConnectptr.p->transid[0] - signal->theData[1];
- UintR Tdata2 = localApiConnectptr.p->transid[1] - signal->theData[2];
- Tdata1 = Tdata1 | Tdata2;
- bool TcheckCondition =
- (TapiConnectstate != CS_COMMIT_SENT) || (Tcounter != 0);
- setApiConTimer(localApiConnectptr.i, ctcTimer, __LINE__);
- localApiConnectptr.p->counter = Tcounter;
- localTcConnectptr.p->tcConnectstate = OS_COMMITTED;
- if (Tdata1 != 0) {
- warningReport(signal, 5);
- return;
- }//if
- if (TcheckCondition) {
- jam();
- /*-------------------------------------------------------*/
- // We have not sent all COMMIT requests yet. We could be
- // in the state that all sent are COMMITTED but we are
- // still waiting for a CONTINUEB to send the rest of the
- // COMMIT requests.
- /*-------------------------------------------------------*/
- return;
- }//if
- if (ERROR_INSERTED(8020)) {
- jam();
- systemErrorLab(signal);
- }//if
- /*-------------------------------------------------------*/
- /* THE ENTIRE TRANSACTION IS NOW COMMITED */
- /* NOW WE NEED TO SEND THE RESPONSE TO THE APPLICATION. */
- /* THE APPLICATION CAN THEN REUSE THE API CONNECTION AND */
- /* THEREFORE WE NEED TO MOVE THE API CONNECTION TO A */
- /* NEW API CONNECT RECORD. */
- /*-------------------------------------------------------*/
- apiConnectptr = localApiConnectptr;
- sendApiCommit(signal);
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- localTcConnectptr.i = regApiPtr->firstTcConnect;
- UintR Tlqhkeyconfrec = regApiPtr->lqhkeyconfrec;
- ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
- regApiPtr->counter = Tlqhkeyconfrec;
- tcConnectptr = localTcConnectptr;
- complete010Lab(signal);
- return;
- }//Dbtc::execCOMMITTED()
- /*-------------------------------------------------------*/
- /* SEND_API_COMMIT */
- /* SEND COMMIT DECISION TO THE API. */
- /*-------------------------------------------------------*/
- void Dbtc::sendApiCommit(Signal* signal)
- {
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- if (regApiPtr->returnsignal == RS_TCKEYCONF) {
- sendtckeyconf(signal, 1);
- } else if (regApiPtr->returnsignal == RS_TC_COMMITCONF) {
- jam();
- TcCommitConf * const commitConf = (TcCommitConf *)&signal->theData[0];
- if(regApiPtr->commitAckMarker == RNIL){
- jam();
- commitConf->apiConnectPtr = regApiPtr->ndbapiConnect;
- } else {
- jam();
- commitConf->apiConnectPtr = regApiPtr->ndbapiConnect | 1;
- }
- commitConf->transId1 = regApiPtr->transid[0];
- commitConf->transId2 = regApiPtr->transid[1];
-
- sendSignal(regApiPtr->ndbapiBlockref, GSN_TC_COMMITCONF, signal, 3, JBB);
- } else if (regApiPtr->returnsignal == RS_NO_RETURN) {
- jam();
- } else {
- TCKEY_abort(signal, 37);
- return;
- }//if
- UintR TapiConnectFilesize = capiConnectFilesize;
- UintR TcommitCount = c_counters.ccommitCount;
- UintR TapiIndex = apiConnectptr.i;
- UintR TnewApiIndex = regApiPtr->apiCopyRecord;
- UintR TapiFailState = regApiPtr->apiFailState;
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- tmpApiConnectptr.p = apiConnectptr.p;
- tmpApiConnectptr.i = TapiIndex;
- c_counters.ccommitCount = TcommitCount + 1;
- apiConnectptr.i = TnewApiIndex;
- ptrCheckGuard(apiConnectptr, TapiConnectFilesize, localApiConnectRecord);
- copyApi(signal);
- if (TapiFailState != ZTRUE) {
- return;
- } else {
- jam();
- handleApiFailState(signal, tmpApiConnectptr.i);
- return;
- }//if
- }//Dbtc::sendApiCommit()
- /* ========================================================================= */
- /* ======= COPY_API ======= */
- /* COPY API RECORD ALSO RESET THE OLD API RECORD SO THAT IT */
- /* IS PREPARED TO RECEIVE A NEW TRANSACTION. */
- /*===========================================================================*/
- void Dbtc::copyApi(Signal* signal)
- {
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- ApiConnectRecord * const regTmpApiPtr = tmpApiConnectptr.p;
- UintR TndbapiConnect = regTmpApiPtr->ndbapiConnect;
- UintR TfirstTcConnect = regTmpApiPtr->firstTcConnect;
- UintR Ttransid1 = regTmpApiPtr->transid[0];
- UintR Ttransid2 = regTmpApiPtr->transid[1];
- UintR Tlqhkeyconfrec = regTmpApiPtr->lqhkeyconfrec;
- UintR TgcpPointer = regTmpApiPtr->gcpPointer;
- UintR TgcpFilesize = cgcpFilesize;
- UintR TcommitAckMarker = regTmpApiPtr->commitAckMarker;
- GcpRecord *localGcpRecord = gcpRecord;
- regApiPtr->ndbapiBlockref = regTmpApiPtr->ndbapiBlockref;
- regApiPtr->ndbapiConnect = TndbapiConnect;
- regApiPtr->firstTcConnect = TfirstTcConnect;
- regApiPtr->apiConnectstate = CS_COMPLETING;
- regApiPtr->transid[0] = Ttransid1;
- regApiPtr->transid[1] = Ttransid2;
- regApiPtr->lqhkeyconfrec = Tlqhkeyconfrec;
- regApiPtr->commitAckMarker = TcommitAckMarker;
- gcpPtr.i = TgcpPointer;
- ptrCheckGuard(gcpPtr, TgcpFilesize, localGcpRecord);
- unlinkApiConnect(signal);
- linkApiToGcp(signal);
- setApiConTimer(tmpApiConnectptr.i, 0, __LINE__);
- regTmpApiPtr->apiConnectstate = CS_CONNECTED;
- regTmpApiPtr->commitAckMarker = RNIL;
- regTmpApiPtr->firstTcConnect = RNIL;
- regTmpApiPtr->lastTcConnect = RNIL;
- releaseAllSeizedIndexOperations(regTmpApiPtr);
- }//Dbtc::copyApi()
- void Dbtc::unlinkApiConnect(Signal* signal)
- {
- ApiConnectRecordPtr localApiConnectptr;
- ApiConnectRecord * const regTmpApiPtr = tmpApiConnectptr.p;
- UintR TapiConnectFilesize = capiConnectFilesize;
- UintR TprevGcpConnect = regTmpApiPtr->prevGcpConnect;
- UintR TnextGcpConnect = regTmpApiPtr->nextGcpConnect;
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- if (TprevGcpConnect == RNIL) {
- gcpPtr.p->firstApiConnect = TnextGcpConnect;
- jam();
- } else {
- localApiConnectptr.i = TprevGcpConnect;
- jam();
- ptrCheckGuard(localApiConnectptr,
- TapiConnectFilesize, localApiConnectRecord);
- localApiConnectptr.p->nextGcpConnect = TnextGcpConnect;
- }//if
- if (TnextGcpConnect == RNIL) {
- gcpPtr.p->lastApiConnect = TprevGcpConnect;
- jam();
- } else {
- localApiConnectptr.i = TnextGcpConnect;
- jam();
- ptrCheckGuard(localApiConnectptr,
- TapiConnectFilesize, localApiConnectRecord);
- localApiConnectptr.p->prevGcpConnect = TprevGcpConnect;
- }//if
- }//Dbtc::unlinkApiConnect()
- void Dbtc::complete010Lab(Signal* signal)
- {
- TcConnectRecordPtr localTcConnectptr;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- localTcConnectptr.p = tcConnectptr.p;
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- UintR TapiConnectptrIndex = apiConnectptr.i;
- UintR Tcount = 0;
- do {
- localTcConnectptr.p->apiConnect = TapiConnectptrIndex;
- localTcConnectptr.p->tcConnectstate = OS_COMPLETING;
- /* ************ */
- /* COMPLETE < */
- /* ************ */
- const Uint32 nextTcConnect = localTcConnectptr.p->nextTcConnect;
- sendCompleteLqh(signal, localTcConnectptr.p);
- localTcConnectptr.i = nextTcConnect;
- if (localTcConnectptr.i != RNIL) {
- Tcount++;
- if (Tcount < 16) {
- ptrCheckGuard(localTcConnectptr,
- TtcConnectFilesize, localTcConnectRecord);
- jam();
- continue;
- } else {
- jam();
- if (ERROR_INSERTED(8013)) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- signal->theData[0] = TcContinueB::ZSEND_COMPLETE_LOOP;
- signal->theData[1] = apiConnectptr.i;
- signal->theData[2] = localTcConnectptr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
- return;
- }//if
- } else {
- jam();
- regApiPtr->apiConnectstate = CS_COMPLETE_SENT;
- return;
- }//if
- } while (1);
- }//Dbtc::complete010Lab()
- void Dbtc::sendCompleteLqh(Signal* signal,
- TcConnectRecord * const regTcPtr)
- {
- HostRecordPtr Thostptr;
- UintR ThostFilesize = chostFilesize;
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- Thostptr.i = regTcPtr->lastLqhNodeId;
- ptrCheckGuard(Thostptr, ThostFilesize, hostRecord);
- if (Thostptr.p->noOfPackedWordsLqh > 22) {
- jam();
- sendPackedSignalLqh(signal, Thostptr.p);
- } else {
- jam();
- updatePackedList(signal, Thostptr.p, Thostptr.i);
- }//if
- UintR Tindex = Thostptr.p->noOfPackedWordsLqh;
- UintR* TDataPtr = &Thostptr.p->packedWordsLqh[Tindex];
- UintR Tdata1 = regTcPtr->lastLqhCon | (ZCOMPLETE << 28);
- UintR Tdata2 = regApiPtr->transid[0];
- UintR Tdata3 = regApiPtr->transid[1];
-
- TDataPtr[0] = Tdata1;
- TDataPtr[1] = Tdata2;
- TDataPtr[2] = Tdata3;
- Thostptr.p->noOfPackedWordsLqh = Tindex + 3;
- }//Dbtc::sendCompleteLqh()
- void
- Dbtc::execTC_COMMIT_ACK(Signal* signal){
- jamEntry();
- CommitAckMarker key;
- key.transid1 = signal->theData[0];
- key.transid2 = signal->theData[1];
- CommitAckMarkerPtr removedMarker;
- m_commitAckMarkerHash.release(removedMarker, key);
- if (removedMarker.i == RNIL) {
- jam();
- warningHandlerLab(signal);
- return;
- }//if
- sendRemoveMarkers(signal, removedMarker.p);
- }
- void
- Dbtc::sendRemoveMarkers(Signal* signal, const CommitAckMarker * marker){
- jam();
- const Uint32 noOfLqhs = marker->noOfLqhs;
- const Uint32 transId1 = marker->transid1;
- const Uint32 transId2 = marker->transid2;
-
- for(Uint32 i = 0; i<noOfLqhs; i++){
- jam();
- const NodeId nodeId = marker->lqhNodeId[i];
- sendRemoveMarker(signal, nodeId, transId1, transId2);
- }
- }
- void
- Dbtc::sendRemoveMarker(Signal* signal,
- NodeId nodeId,
- Uint32 transid1,
- Uint32 transid2){
- /**
- * Seize host ptr
- */
- HostRecordPtr hostPtr;
- const UintR ThostFilesize = chostFilesize;
- hostPtr.i = nodeId;
- ptrCheckGuard(hostPtr, ThostFilesize, hostRecord);
- if (hostPtr.p->noOfPackedWordsLqh > (25 - 3)){
- jam();
- sendPackedSignalLqh(signal, hostPtr.p);
- } else {
- jam();
- updatePackedList(signal, hostPtr.p, hostPtr.i);
- }//if
-
- UintR numWord = hostPtr.p->noOfPackedWordsLqh;
- UintR* dataPtr = &hostPtr.p->packedWordsLqh[numWord];
- dataPtr[0] = (ZREMOVE_MARKER << 28);
- dataPtr[1] = transid1;
- dataPtr[2] = transid2;
- hostPtr.p->noOfPackedWordsLqh = numWord + 3;
- }
- void Dbtc::execCOMPLETED(Signal* signal)
- {
- TcConnectRecordPtr localTcConnectptr;
- ApiConnectRecordPtr localApiConnectptr;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- UintR TapiConnectFilesize = capiConnectFilesize;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
- #ifdef ERROR_INSERT
- if (ERROR_INSERTED(8031)) {
- systemErrorLab(signal);
- }//if
- if (ERROR_INSERTED(8019)) {
- CLEAR_ERROR_INSERT_VALUE;
- return;
- }//if
- if (ERROR_INSERTED(8027)) {
- SET_ERROR_INSERT_VALUE(8028);
- return;
- }//if
- if (ERROR_INSERTED(8043)) {
- CLEAR_ERROR_INSERT_VALUE;
- sendSignalWithDelay(cownref, GSN_COMPLETED, signal, 2000, 3);
- return;
- }//if
- if (ERROR_INSERTED(8044)) {
- SET_ERROR_INSERT_VALUE(8047);
- sendSignalWithDelay(cownref, GSN_COMPLETED, signal, 2000, 3);
- return;
- }//if
- #endif
- localTcConnectptr.i = signal->theData[0];
- jamEntry();
- ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
- bool Tcond1 = (localTcConnectptr.p->tcConnectstate != OS_COMPLETING);
- localApiConnectptr.i = localTcConnectptr.p->apiConnect;
- if (Tcond1) {
- warningReport(signal, 6);
- return;
- }//if
- ptrCheckGuard(localApiConnectptr, TapiConnectFilesize,
- localApiConnectRecord);
- UintR Tdata1 = localApiConnectptr.p->transid[0] - signal->theData[1];
- UintR Tdata2 = localApiConnectptr.p->transid[1] - signal->theData[2];
- UintR Tcounter = localApiConnectptr.p->counter - 1;
- ConnectionState TapiConnectstate = localApiConnectptr.p->apiConnectstate;
- Tdata1 = Tdata1 | Tdata2;
- bool TcheckCondition =
- (TapiConnectstate != CS_COMPLETE_SENT) || (Tcounter != 0);
- if (Tdata1 != 0) {
- warningReport(signal, 7);
- return;
- }//if
- setApiConTimer(localApiConnectptr.i, ctcTimer, __LINE__);
- localApiConnectptr.p->counter = Tcounter;
- localTcConnectptr.p->tcConnectstate = OS_COMPLETED;
- localTcConnectptr.p->noOfNodes = 0; // == releaseNodes(signal)
- if (TcheckCondition) {
- jam();
- /*-------------------------------------------------------*/
- // We have not sent all COMPLETE requests yet. We could be
- // in the state that all sent are COMPLETED but we are
- // still waiting for a CONTINUEB to send the rest of the
- // COMPLETE requests.
- /*-------------------------------------------------------*/
- return;
- }//if
- if (ERROR_INSERTED(8021)) {
- jam();
- systemErrorLab(signal);
- }//if
- apiConnectptr = localApiConnectptr;
- releaseTransResources(signal);
- }//Dbtc::execCOMPLETED()
- /*---------------------------------------------------------------------------*/
- /* RELEASE_TRANS_RESOURCES */
- /* RELEASE ALL RESOURCES THAT ARE CONNECTED TO THIS TRANSACTION. */
- /*---------------------------------------------------------------------------*/
- void Dbtc::releaseTransResources(Signal* signal)
- {
- TcConnectRecordPtr localTcConnectptr;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
- localTcConnectptr.i = apiConnectptr.p->firstTcConnect;
- do {
- jam();
- ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
- UintR rtrTcConnectptrIndex = localTcConnectptr.p->nextTcConnect;
- tcConnectptr.i = localTcConnectptr.i;
- tcConnectptr.p = localTcConnectptr.p;
- localTcConnectptr.i = rtrTcConnectptrIndex;
- releaseTcCon();
- } while (localTcConnectptr.i != RNIL);
- handleGcp(signal);
- releaseFiredTriggerData(&apiConnectptr.p->theFiredTriggers);
- releaseAllSeizedIndexOperations(apiConnectptr.p);
- releaseApiConCopy(signal);
- }//Dbtc::releaseTransResources()
- /* *********************************************************************>> */
- /* MODULE: HANDLE_GCP */
- /* DESCRIPTION: HANDLES GLOBAL CHECKPOINT HANDLING AT THE COMPLETION */
- /* OF THE COMMIT PHASE AND THE ABORT PHASE. WE MUST ENSURE THAT TC */
- /* SENDS GCP_TCFINISHED WHEN ALL TRANSACTIONS BELONGING TO A CERTAIN */
- /* GLOBAL CHECKPOINT HAVE COMPLETED. */
- /* *********************************************************************>> */
- void Dbtc::handleGcp(Signal* signal)
- {
- GcpRecord *localGcpRecord = gcpRecord;
- GcpRecordPtr localGcpPtr;
- UintR TapiConnectptrIndex = apiConnectptr.i;
- UintR TgcpFilesize = cgcpFilesize;
- localGcpPtr.i = apiConnectptr.p->gcpPointer;
- tmpApiConnectptr.i = TapiConnectptrIndex;
- tmpApiConnectptr.p = apiConnectptr.p;
- ptrCheckGuard(localGcpPtr, TgcpFilesize, localGcpRecord);
- gcpPtr.i = localGcpPtr.i;
- gcpPtr.p = localGcpPtr.p;
- unlinkApiConnect(signal);
- if (localGcpPtr.p->firstApiConnect == RNIL) {
- if (localGcpPtr.p->gcpNomoretransRec == ZTRUE) {
- jam();
- tcheckGcpId = localGcpPtr.p->gcpId;
- gcpTcfinished(signal);
- unlinkGcp(signal);
- }//if
- }//if
- }//Dbtc::handleGcp()
- void Dbtc::releaseApiConCopy(Signal* signal)
- {
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- UintR TfirstfreeApiConnectCopyOld = cfirstfreeApiConnectCopy;
- cfirstfreeApiConnectCopy = apiConnectptr.i;
- regApiPtr->nextApiConnect = TfirstfreeApiConnectCopyOld;
- setApiConTimer(apiConnectptr.i, 0, __LINE__);
- regApiPtr->apiConnectstate = CS_RESTART;
- }//Dbtc::releaseApiConCopy()
- /* ========================================================================= */
- /* ------- RELEASE ALL RECORDS CONNECTED TO A DIRTY WRITE OPERATION ------- */
- /* ========================================================================= */
- void Dbtc::releaseDirtyWrite(Signal* signal)
- {
- unlinkReadyTcCon(signal);
- releaseTcCon();
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
- if (regApiPtr->firstTcConnect == RNIL) {
- jam();
- regApiPtr->apiConnectstate = CS_CONNECTED;
- setApiConTimer(apiConnectptr.i, 0, __LINE__);
- sendtckeyconf(signal, 1);
- }//if
- }//if
- }//Dbtc::releaseDirtyWrite()
- /*****************************************************************************
- * L Q H K E Y R E F
- * WHEN LQHKEYREF IS RECEIVED DBTC WILL CHECK IF COMMIT FLAG WAS SENT FROM THE
- * APPLICATION. IF SO, THE WHOLE TRANSACTION WILL BE ROLLED BACK AND SIGNAL
- * TCROLLBACKREP WILL BE SENT TO THE API.
- *
- * OTHERWISE TC WILL CHECK THE ERRORCODE. IF THE ERRORCODE IS INDICATING THAT
- * THE "ROW IS NOT FOUND" FOR UPDATE/READ/DELETE OPERATIONS AND "ROW ALREADY
- * EXISTS" FOR INSERT OPERATIONS, DBTC WILL RELEASE THE OPERATION AND THEN
- * SEND RETURN SIGNAL TCKEYREF TO THE USER. THE USER THEN HAVE TO SEND
- * SIGNAL TC_COMMITREQ OR TC_ROLLBACKREQ TO CONCLUDE THE TRANSACTION.
- * IF ANY TCKEYREQ WITH COMMIT IS RECEIVED AND API_CONNECTSTATE EQUALS
- * "REC_LQHREFUSE",
- * THE OPERATION WILL BE TREATED AS AN OPERATION WITHOUT COMMIT. WHEN ANY
- * OTHER FAULTCODE IS RECEIVED THE WHOLE TRANSACTION MUST BE ROLLED BACK
- *****************************************************************************/
- void Dbtc::execLQHKEYREF(Signal* signal)
- {
- const LqhKeyRef * const lqhKeyRef = (LqhKeyRef *)signal->getDataPtr();
- jamEntry();
-
- UintR compare_transid1, compare_transid2;
- UintR TtcConnectFilesize = ctcConnectFilesize;
- /*-------------------------------------------------------------------------
- *
- * RELEASE NODE BUFFER(S) TO INDICATE THAT THIS OPERATION HAVE NO
- * TRANSACTION PARTS ACTIVE ANYMORE.
- * LQHKEYREF HAVE CLEARED ALL PARTS ON ITS PATH BACK TO TC.
- *-------------------------------------------------------------------------*/
- if (lqhKeyRef->connectPtr < TtcConnectFilesize) {
- /*-----------------------------------------------------------------------
- * WE HAVE TO CHECK THAT THE TRANSACTION IS STILL VALID. FIRST WE CHECK
- * THAT THE LQH IS STILL CONNECTED TO A TC, IF THIS HOLDS TRUE THEN THE
- * TC MUST BE CONNECTED TO AN API CONNECT RECORD.
- * WE MUST ENSURE THAT THE TRANSACTION ID OF THIS API CONNECT
- * RECORD IS STILL THE SAME AS THE ONE LQHKEYREF REFERS TO.
- * IF NOT SIMPLY EXIT AND FORGET THE SIGNAL SINCE THE TRANSACTION IS
- * ALREADY COMPLETED (ABORTED).
- *-----------------------------------------------------------------------*/
- tcConnectptr.i = lqhKeyRef->connectPtr;
- Uint32 errCode = terrorCode = lqhKeyRef->errorCode;
- ptrAss(tcConnectptr, tcConnectRecord);
- TcConnectRecord * const regTcPtr = tcConnectptr.p;
- if (regTcPtr->tcConnectstate == OS_OPERATING) {
- apiConnectptr.i = regTcPtr->apiConnect;
- ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- compare_transid1 = regApiPtr->transid[0] ^ lqhKeyRef->transId1;
- compare_transid2 = regApiPtr->transid[1] ^ lqhKeyRef->transId2;
- compare_transid1 = compare_transid1 | compare_transid2;
- if (compare_transid1 != 0) {
- warningReport(signal, 25);
- return;
- }//if
- const ConnectionState state = regApiPtr->apiConnectstate;
- const Uint32 triggeringOp = regTcPtr->triggeringOperation;
- if (triggeringOp != RNIL) {
- jam();
- // This operation was created by a trigger execting operation
- TcConnectRecordPtr opPtr;
- TcConnectRecord *localTcConnectRecord = tcConnectRecord;
-
- const Uint32 currentIndexId = regTcPtr->currentIndexId;
- ndbassert(currentIndexId != 0); // Only index triggers so far
-
- opPtr.i = triggeringOp;
- ptrCheckGuard(opPtr, ctcConnectFilesize, localTcConnectRecord);
-
- // The operation executed an index trigger
- const Uint32 opType = regTcPtr->operation;
- if (errCode == ZALREADYEXIST)
- errCode = terrorCode = ZNOTUNIQUE;
- else if (!(opType == ZDELETE && errCode == ZNOT_FOUND)) {
- jam();
- /**
- * "Normal path"
- */
- // fall-through
- } else {
- jam();
- /** ZDELETE && NOT_FOUND */
- TcIndexData* indexData = c_theIndexes.getPtr(currentIndexId);
- if(indexData->indexState == IS_BUILDING && state != CS_ABORTING){
- jam();
- /**
- * Ignore error
- */
- regApiPtr->lqhkeyconfrec++;
-
- unlinkReadyTcCon(signal);
- releaseTcCon();
-
- opPtr.p->triggerExecutionCount--;
- if (opPtr.p->triggerExecutionCount == 0) {
- /**
- * We have completed current trigger execution
- * Continue triggering operation
- */
- jam();
- continueTriggeringOp(signal, opPtr.p);
- }
- return;
- }
- }
- }
-
- Uint32 marker = regTcPtr->commitAckMarker;
- markOperationAborted(regApiPtr, regTcPtr);
-
- if(regApiPtr->apiConnectstate == CS_ABORTING){
- /**
- * We're already aborting' so don't send an "extra" TCKEYREF
- */
- jam();
- return;
- }
-
- const Uint32 abort = regTcPtr->m_execAbortOption;
- if (abort == TcKeyReq::AbortOnError || triggeringOp != RNIL) {
- /**
- * No error is allowed on this operation
- */
- TCKEY_abort(signal, 49);
- return;
- }//if
- if (marker != RNIL){
- /**
- * This was an insert/update/delete/write which failed
- * that contained the marker
- * Currently unsupported to place new marker
- */
- TCKEY_abort(signal, 49);
- return;
- }
-
- /* *************** */
- /* TCKEYREF < */
- /* *************** */
- TcKeyRef * const tcKeyRef = (TcKeyRef *) signal->getDataPtrSend();
- tcKeyRef->transId[0] = regApiPtr->transid[0];
- tcKeyRef->transId[1] = regApiPtr->transid[1];
- tcKeyRef->errorCode = terrorCode;
- bool isIndexOp = regTcPtr->isIndexOp;
- Uint32 indexOp = tcConnectptr.p->indexOp;
- Uint32 clientData = regTcPtr->clientData;
- unlinkReadyTcCon(signal); /* LINK TC CONNECT RECORD OUT OF */
- releaseTcCon(); /* RELEASE THE TC CONNECT RECORD */
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- if (isIndexOp) {
- jam();
- regApiPtr->lqhkeyreqrec--; // Compensate for extra during read
- tcKeyRef->connectPtr = indexOp;
- EXECUTE_DIRECT(DBTC, GSN_TCKEYREF, signal, TcKeyRef::SignalLength);
- apiConnectptr.i = regTcPtr->apiConnect;
- apiConnectptr.p = regApiPtr;
- } else {
- jam();
- tcKeyRef->connectPtr = clientData;
- sendSignal(regApiPtr->ndbapiBlockref,
- GSN_TCKEYREF, signal, TcKeyRef::SignalLength, JBB);
- }//if
-
- /*---------------------------------------------------------------------
- * SINCE WE ARE NOT ABORTING WE NEED TO UPDATE THE COUNT OF HOW MANY
- * LQHKEYREQ THAT HAVE RETURNED.
- * IF NO MORE OUTSTANDING LQHKEYREQ'S THEN WE NEED TO
- * TCKEYCONF (IF THERE IS ANYTHING TO SEND).
- *---------------------------------------------------------------------*/
- regApiPtr->lqhkeyreqrec--;
- if (regApiPtr->lqhkeyconfrec == regApiPtr->lqhkeyreqrec) {
- if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
- if(regApiPtr->lqhkeyconfrec) {
- jam();
- diverify010Lab(signal);
- } else {
- jam();
- sendtckeyconf(signal, 1);
- regApiPtr->apiConnectstate = CS_CONNECTED;
- }
- return;
- } else if (regApiPtr->tckeyrec > 0 || regApiPtr->m_exec_flag) {
- jam();
- sendtckeyconf(signal, 2);
- return;
- }
- }//if
- return;
-
- } else {
- warningReport(signal, 26);
- }//if
- } else {
- errorReport(signal, 6);
- }//if
- return;
- }//Dbtc::execLQHKEYREF()
- void Dbtc::clearCommitAckMarker(ApiConnectRecord * const regApiPtr,
- TcConnectRecord * const regTcPtr)
- {
- const Uint32 commitAckMarker = regTcPtr->commitAckMarker;
- if (regApiPtr->commitAckMarker == RNIL)
- ndbassert(commitAckMarker == RNIL);
- if (commitAckMarker != RNIL)
- ndbassert(regApiPtr->commitAckMarker != RNIL);
- if(commitAckMarker != RNIL){
- jam();
- m_commitAckMarkerHash.release(commitAckMarker);
- regTcPtr->commitAckMarker = RNIL;
- regApiPtr->commitAckMarker = RNIL;
- }
- }
- void Dbtc::markOperationAborted(ApiConnectRecord * const regApiPtr,
- TcConnectRecord * const regTcPtr)
- {
- /*------------------------------------------------------------------------
- * RELEASE NODES TO INDICATE THAT THE OPERATION IS ALREADY ABORTED IN THE
- * LQH'S ALSO SET STATE TO ABORTING TO INDICATE THE ABORT IS
- * ALREADY COMPLETED.
- *------------------------------------------------------------------------*/
- regTcPtr->noOfNodes = 0; // == releaseNodes(signal)
- regTcPtr->tcConnectstate = OS_ABORTING;
- clearCommitAckMarker(regApiPtr, regTcPtr);
- }
- /*--------------------------------------*/
- /* EXIT AND WAIT FOR SIGNAL TCOMMITREQ */
- /* OR TCROLLBACKREQ FROM THE USER TO */
- /* CONTINUE THE TRANSACTION */
- /*--------------------------------------*/
- void Dbtc::execTC_COMMITREQ(Signal* signal)
- {
- UintR compare_transid1, compare_transid2;
- jamEntry();
- apiConnectptr.i = signal->theData[0];
- if (apiConnectptr.i < capiConnectFilesize) {
- ptrAss(apiConnectptr, apiConnectRecord);
- compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[1];
- compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[2];
- compare_transid1 = compare_transid1 | compare_transid2;
- if (compare_transid1 != 0) {
- jam();
- return;
- }//if
-
- ApiConnectRecord * const regApiPtr = apiConnectptr.p;
- const Uint32 apiConnectPtr = regApiPtr->ndbapiConnect;
- const Uint32 apiBlockRef = regApiPtr->ndbapiBlockref;
- const Uint32 transId1 = regApiPtr->transid[0];
- const Uint32 transId2 = regApiPtr->transid[1];
- Uint32 errorCode = 0;
- regApiPtr->m_exec_flag = 1;
- switch (regApiPtr->apiConnectstate) {
- case CS_STARTED:
- tcConnectptr.i = regApiPtr->firstTcConnect;
- if (tcConnectptr.i != RNIL) {
- ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
- if (regApiPtr->lqhkeyconfrec == regApiPtr->lqhkeyreqrec) {
- jam();
- /*******************************************************************/
- // The proper case where the application is waiting for commit or
- // abort order.
- // Start the commit order.
- /*******************************************************************/
- regApiPtr->returnsignal = RS_TC_COMMITCONF;
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- diverify010Lab(signal);
- return;
- } else {
- jam();
- /*******************************************************************/
- // The transaction is started but not all operations are completed.
- // It is not possible to commit the transaction in this state.
- // We will abort it instead.
- /*******************************************************************/
- regApiPtr->returnsignal = RS_NO_RETURN;
- errorCode = ZTRANS_STATUS_ERROR;
- abort010Lab(signal);
- }//if
- } else {
- jam();
- /**
- * No operations, accept commit
- */
- TcCommitConf * const commitConf = (TcCommitConf *)&signal->theData[0];
- commitConf->apiConnectPtr = apiConnectPtr;
- commitConf->transId1 = transId1;
- commitConf->transId2 = transId2;
-
- sendSignal(apiBlockRef, GSN_TC_COMMITCONF, signal, 3, JBB);
-
- regApiPtr->returnsignal = RS_NO_RETURN;
- releaseAbortResources(signal);
- return;
- }//if
- break;
- case CS_RECEIVING:
- jam();
- /***********************************************************************/
- // A transaction is still receiving data. We cannot commit an unfinished
- // transaction. We will abort it instead.
- /***********************************************************************/
- regApiPtr->returnsignal = RS_NO_RETURN;
- errorCode = ZPREPAREINPROGRESS;
- abort010Lab(signal);
- break;
-
- case CS_START_COMMITTING:
- case CS_COMMITTING:
- case CS_COMMIT_SENT:
- case CS_COMPLETING:
- case CS_COMPLETE_SENT:
- case CS_REC_COMMITTING:
- case CS_PREPARE_TO_COMMIT:
- jam();
- /***********************************************************************/
- // The transaction is already performing a commit but it is not concluded
- // yet.
- /***********************************************************************/
- errorCode = ZCOMMITINPROGRESS;
- break;
- case CS_ABORTING:
- jam();
- errorCode = ZABORTINPROGRESS;
- break;
- case CS_START_SCAN:
- jam();
- /***********************************************************************/
- // The transaction is a scan. Scans cannot commit
- /***********************************************************************/
- errorCode = ZSCANINPROGRESS;
- break;
- case CS_PREPARED:
- jam();
- return;
- case CS_START_PREPARING:
- jam();
- return;
- case CS_REC_PREPARING:
- jam();
- return;
- break;
- default:
- warningHandlerLab(signal);
- return;
- }//switch
- TcCommitRef * const commitRef = (TcCommitRef*)&signal->theData[0];
- commitRef->apiConnectPtr = apiConnectPtr;
- commitRef->transId1 = transId1;
- commitRef->transId2 = transId2;
- commitRef->errorCode = errorCode;
- sendSignal(apiBlockRef, GSN_TC_COMMITREF, signal,
- TcCommitRef::SignalLength, JBB);
- return;
- } else /** apiConnectptr.i < capiConnectFilesize */ {
- jam();
- warningHandlerLab(signal);
- return;
- }
- }//Dbtc::execTC_COMMITREQ()
- void Dbtc::execTCROLLBACKREQ(Signal* signal)
- {
- UintR compare_transid1, compare_transid2;
- jamEntry();
- apiConnectptr.i = signal->theData[0];
- if (apiConnectptr.i >= capiConnectFilesize) {
- goto TC_ROLL_warning;
- }//if
- ptrAss(apiConnectptr, apiConnectRecord);
- compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[1];
- compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[2];
- compare_transid1 = compare_transid1 | compare_transid2;
- if (compare_transid1 != 0) {
- jam();
- return;
- }//if
- apiConnectptr.p->m_exec_flag = 1;
- switch (apiConnectptr.p->apiConnectstate) {
- case CS_STARTED:
- case CS_RECEIVING:
- jam();
- apiConnectptr.p->returnsignal = RS_TCROLLBACKCONF;
- abort010Lab(signal);
- return;
- case CS_CONNECTED:
- jam();
- signal->theData[0] = apiConnectptr.p->ndbapiConnect;
- signal->theData[1] = apiConnectptr.p->transid[0];
- signal->theData[2] = apiConnectptr.p->transid[1];
- sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKCONF,
- signal, 3, JBB);
- break;
- case CS_START_SCAN:
- case CS_PREPARE_TO_COMMIT:
- case CS_COMMITTING:
- case CS_COMMIT_SENT:
- case CS_COMPLETING:
- case CS_COMPLETE_SENT:
- case CS_WAIT_COMMIT_CONF:
- case CS_WAIT_COMPLETE_CONF:
- case CS_RESTART:
- case CS_DISCONNECTED:
- case CS_START_COMMITTING:
- case CS_REC_COMMITTING:
- jam();
- /* ***************< */
- /* TC_ROLLBACKREF < */
- /* ***************< */
- signal->theData[0] = apiConnectptr.p->ndbapiConnect;
- signal->theData[1] = apiConnectptr.p->transid[0];
- signal->theData[2] = apiConnectptr.p->transid[1];
- signal->theData[3] = ZROLLBACKNOTALLOWED;
- signal->theData[4] = apiConnectptr.p->apiConnectstate;
- sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKREF,
- signal, 5, JBB);
- break;
- /* SEND A REFUSAL SIGNAL*/
- case CS_ABORTING:
- jam();
- if (apiConnectptr.p->abortState == AS_IDLE) {
- jam();
- signal->theData[0] = apiConnectptr.p->ndbapiConnect;
- signal->theData[1] = apiConnectptr.p->transid[0];
- signal->theData[2] = apiConnectptr.p->transid[1];
- sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKCONF,
- signal, 3, JBB);
- } else {
- jam();
- apiConnectptr.p->returnsignal = RS_TCROLLBACKCONF;
- }//if
- break;
- case CS_WAIT_ABORT_CONF:
- jam();
- apiConnectptr.p->returnsignal = RS_TCROLLBACKCONF;
- break;
- case CS_START_PREPARING:
- jam();
- case CS_PREPARED:
- jam();
- case CS_REC_PREPARING:
- jam();
- default:
- goto TC_ROLL_system_error;
- break;
- }//switch
- return;
- TC_ROLL_warning:
- jam();
- warningHandlerLab(signal);
- return;
- TC_ROLL_system_error:
- jam();
- systemErrorLab(signal);
- return;
- }//Dbtc::execTCROLLBACKREQ()
- void Dbtc::execTC_HBREP(Signal* signal)
- {
- const TcHbRep * const tcHbRep =
- (TcHbRep *)signal->getDataPtr();
- jamEntry();
- apiConnectptr.i = tcHbRep->apiConnectPtr;
- ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
- if (apiConnectptr.p->transid[0] == tcHbRep->transId1 &&
- apiConnectptr.p->transid[1] == tcHbRep->transId2){
- if (getApiConTimer(apiConnectptr.i) != 0){
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- } else {
- DEBUG("TCHBREP received when timer was off apiConnectptr.i="
- << apiConnectptr.i);
- }
- }
- }//Dbtc::execTCHBREP()
- /*
- 4.3.15 ABORT
- -----------
- */
- /*****************************************************************************/
- /* A B O R T */
- /* */
- /*****************************************************************************/
- void Dbtc::warningReport(Signal* signal, int place)
- {
- switch (place) {
- case 0:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "ABORTED to not active TC record" << endl;
- #endif
- break;
- case 1:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "ABORTED to TC record active with new transaction" << endl;
- #endif
- break;
- case 2:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "ABORTED to active TC record not expecting ABORTED" << endl;
- #endif
- break;
- case 3:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "ABORTED to TC rec active with trans but wrong node" << endl;
- ndbout << "This is ok when aborting in node failure situations" << endl;
- #endif
- break;
- case 4:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMMITTED in wrong state in Dbtc" << endl;
- #endif
- break;
- case 5:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMMITTED with wrong transid in Dbtc" << endl;
- #endif
- break;
- case 6:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMPLETED in wrong state in Dbtc" << endl;
- #endif
- break;
- case 7:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMPLETED with wrong transid in Dbtc" << endl;
- #endif
- break;
- case 8:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMMITCONF with tc-rec in wrong state in Dbtc" << endl;
- #endif
- break;
- case 9:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMMITCONF with api-rec in wrong state in Dbtc" <<endl;
- #endif
- break;
- case 10:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMMITCONF with wrong transid in Dbtc" << endl;
- #endif
- break;
- case 11:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMMITCONF from wrong nodeid in Dbtc" << endl;
- #endif
- break;
- case 12:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMPLETECONF, tc-rec in wrong state in Dbtc" << endl;
- #endif
- break;
- case 13:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMPLETECONF, api-rec in wrong state in Dbtc" << endl;
- #endif
- break;
- case 14:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMPLETECONF with wrong transid in Dbtc" << endl;
- #endif
- break;
- case 15:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received COMPLETECONF from wrong nodeid in Dbtc" << endl;
- #endif
- break;
- case 16:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received ABORTCONF, tc-rec in wrong state in Dbtc" << endl;
- #endif
- break;
- case 17:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received ABORTCONF, api-rec in wrong state in Dbtc" << endl;
- #endif
- break;
- case 18:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received ABORTCONF with wrong transid in Dbtc" << endl;
- #endif
- break;
- case 19:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received ABORTCONF from wrong nodeid in Dbtc" << endl;
- #endif
- break;
- case 20:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Time-out waiting for ABORTCONF in Dbtc" << endl;
- #endif
- break;
- case 21:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Time-out waiting for COMMITCONF in Dbtc" << endl;
- #endif
- break;
- case 22:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Time-out waiting for COMPLETECONF in Dbtc" << endl;
- #endif
- break;
- case 23:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received LQHKEYCONF in wrong tc-state in Dbtc" << endl;
- #endif
- break;
- case 24:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received LQHKEYREF to wrong transid in Dbtc" << endl;
- #endif
- break;
- case 25:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received LQHKEYREF in wrong state in Dbtc" << endl;
- #endif
- break;
- case 26:
- jam();
- #ifdef ABORT_TRACE
- ndbout << "Received LQHKEYCONF to wrong transid in Dbtc" << endl;
- #endif
- break;
- case 27:
- jam();
- // printState(signal, 27);
- #ifdef ABORT_TRACE
- ndbout << "Received LQHKEYCONF in wrong api-state in Dbtc" << endl;
- #endif
- break;
- default:
- jam();
- break;
- }//switch
- return;
- }//Dbtc::warningReport()
- void Dbtc::errorReport(Signal* signal, int place)
- {
- switch (place) {
- case 0:
- jam();
- break;
- case 1:
- jam();
- break;
- case 2:
- jam();
- break;
- case 3:
- jam();
- break;
- case 4:
- jam();
- break;
- case 5:
- jam();
- break;
- case 6:
- jam();
- break;
- default:
- jam();
- break;
- }//switch
- systemErrorLab(signal);
- return;
- }//Dbtc::errorReport()
- /* ------------------------------------------------------------------------- */
- /* ------- ENTER ABORTED ------- */
- /* */
- /*-------------------------------------------------------------------------- */
- void Dbtc::execABORTED(Signal* signal)
- {
- UintR compare_transid1, compare_transid2;
- jamEntry();
- tcConnectptr.i = signal->theData[0];
- UintR Tnodeid = signal->theData[3];
- UintR TlastLqhInd = signal->theData[4];
- if (ERROR_INSERTED(8040)) {
- CLEAR_ERROR_INSERT_VALUE;
- sendSignalWithDelay(cownref, GSN_ABORTED, signal, 2000, 5);
- return;
- }//if
- /*------------------------------------------------------------------------
- * ONE PARTICIPANT IN THE TRANSACTION HAS REPORTED THAT IT IS ABORTED.
- *------------------------------------------------------------------------*/
- if (tcConnectptr.i >= ctcConnectFilesize) {
- errorReport(signal, 0);
- return;
- }//if
- /*-------------------------------------------------------------------------
- * WE HAVE TO CHECK THAT THIS IS NOT AN OLD SIGNAL BELONGING TO A
- * TRANSACTION ALREADY ABORTED. THIS CAN HAPPEN WHEN TIME-OUT OCCURS
- * IN TC WAITING FOR ABORTED.
- *-------------------------------------------------------------------------*/
- ptrAss(tcConnectptr, tcConnectRecord);
- if (tcConnectptr.p->tcConnectstate != OS_ABORT_SENT) {
- warningReport(signal, 2);
- return;
- /*-----------------------------------------------------------------------*/
- // ABORTED reported on an operation not expecting ABORT.
- /*-----------------------------------------------------------------------*/
- }//if
- apiConnectptr.i = tcConnectptr.p->apiConnect;
- if (apiConnectptr.i >= capiConnectFilesize) {
- warningReport(signal, 0);
- return;
- }//if
- ptrAss(apiConnectptr, apiConnectRecord);
- compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[1];
- compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[2];
- compare_transid1 = compare_transid1 | compare_transid2;
- if (compare_transid1 != 0) {
- warningReport(signal, 1);
- return;
- }//if
- if (ERROR_INSERTED(8024)) {
- jam();
- systemErrorLab(signal);
- }//if
- /**
- * Release marker
- */
- clearCommitAckMarker(apiConnectptr.p, tcConnectptr.p);
- Uint32 i;
- Uint32 Tfound = 0;
- for (i = 0; i < tcConnectptr.p->noOfNodes; i++) {
- jam();
- if (tcConnectptr.p->tcNodedata[i] == Tnodeid) {
- /*---------------------------------------------------------------------
- * We have received ABORTED from one of the participants in this
- * operation in this aborted transaction.
- * Record all nodes that have completed abort.
- * If last indicator is set it means that no more replica has
- * heard of the operation and are thus also aborted.
- *---------------------------------------------------------------------*/
- jam();
- Tfound = 1;
- clearTcNodeData(signal, TlastLqhInd, i);
- }//if
- }//for
- if (Tfound == 0) {
- warningReport(signal, 3);
- return;
- }
- for (i = 0; i < tcConnectptr.p->noOfNodes; i++) {
- if (tcConnectptr.p->tcNodedata[i] != 0) {
- /*--------------------------------------------------------------------
- * There are still outstanding ABORTED's to wait for.
- *--------------------------------------------------------------------*/
- jam();
- return;
- }//if
- }//for
- tcConnectptr.p->noOfNodes = 0;
- tcConnectptr.p->tcConnectstate = OS_ABORTING;
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- apiConnectptr.p->counter--;
- if (apiConnectptr.p->counter > 0) {
- jam();
- /*----------------------------------------------------------------------
- * WE ARE STILL WAITING FOR MORE PARTICIPANTS TO SEND ABORTED.
- *----------------------------------------------------------------------*/
- return;
- }//if
- /*------------------------------------------------------------------------*/
- /* */
- /* WE HAVE NOW COMPLETED THE ABORT PROCESS. WE HAVE RECEIVED ABORTED */
- /* FROM ALL PARTICIPANTS IN THE TRANSACTION. WE CAN NOW RELEASE ALL */
- /* RESOURCES CONNECTED TO THE TRANSACTION AND SEND THE ABORT RESPONSE */
- /*------------------------------------------------------------------------*/
- releaseAbortResources(signal);
- }//Dbtc::execABORTED()
- void Dbtc::clearTcNodeData(Signal* signal,
- UintR TLastLqhIndicator,
- UintR Tstart)
- {
- UintR Ti;
- if (TLastLqhIndicator == ZTRUE) {
- for (Ti = Tstart ; Ti < tcConnectptr.p->noOfNodes; Ti++) {
- jam();
- tcConnectptr.p->tcNodedata[Ti] = 0;
- }//for
- } else {
- jam();
- tcConnectptr.p->tcNodedata[Tstart] = 0;
- }//for
- }//clearTcNodeData()
- void Dbtc::abortErrorLab(Signal* signal)
- {
- ptrGuard(apiConnectptr);
- ApiConnectRecord * transP = apiConnectptr.p;
- if (transP->apiConnectstate == CS_ABORTING && transP->abortState != AS_IDLE){
- jam();
- return;
- }
- transP->returnsignal = RS_TCROLLBACKREP;
- if(transP->returncode == 0){
- jam();
- transP->returncode = terrorCode;
- }
- abort010Lab(signal);
- }//Dbtc::abortErrorLab()
- void Dbtc::abort010Lab(Signal* signal)
- {
- ApiConnectRecord * transP = apiConnectptr.p;
- if (transP->apiConnectstate == CS_ABORTING && transP->abortState != AS_IDLE){
- jam();
- return;
- }
- transP->apiConnectstate = CS_ABORTING;
- /*------------------------------------------------------------------------*/
- /* AN ABORT DECISION HAS BEEN TAKEN FOR SOME REASON. WE NEED TO ABORT */
- /* ALL PARTICIPANTS IN THE TRANSACTION. */
- /*------------------------------------------------------------------------*/
- transP->abortState = AS_ACTIVE;
- transP->counter = 0;
- if (transP->firstTcConnect == RNIL) {
- jam();
- /*-----------------------------------------------------------------------*/
- /* WE HAVE NO PARTICIPANTS IN THE TRANSACTION. */
- /*-----------------------------------------------------------------------*/
- releaseAbortResources(signal);
- return;
- }//if
- tcConnectptr.i = transP->firstTcConnect;
- abort015Lab(signal);
- }//Dbtc::abort010Lab()
- /*--------------------------------------------------------------------------*/
- /* */
- /* WE WILL ABORT ONE NODE PER OPERATION AT A TIME. THIS IS TO KEEP */
- /* ERROR HANDLING OF THIS PROCESS FAIRLY SIMPLE AND TRACTABLE. */
- /* EVEN IF NO NODE OF THIS PARTICULAR NODE NUMBER NEEDS ABORTION WE */
- /* MUST ENSURE THAT ALL NODES ARE CHECKED. THUS A FAULTY NODE DOES */
- /* NOT MEAN THAT ALL NODES IN AN OPERATION IS ABORTED. FOR THIS REASON*/
- /* WE SET THE TCONTINUE_ABORT TO TRUE WHEN A FAULTY NODE IS DETECTED. */
- /*--------------------------------------------------------------------------*/
- void Dbtc::abort015Lab(Signal* signal)
- {
- Uint32 TloopCount = 0;
- ABORT020:
- jam();
- TloopCount++;
- ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
- switch (tcConnectptr.p->tcConnectstate) {
- case OS_WAIT_DIH:
- case OS_WAIT_KEYINFO:
- case OS_WAIT_ATTR:
- jam();
- /*----------------------------------------------------------------------*/
- /* WE ARE STILL WAITING FOR MORE KEYINFO/ATTRINFO. WE HAVE NOT CONTACTED*/
- /* ANY LQH YET AND SO WE CAN SIMPLY SET STATE TO ABORTING. */
- /*----------------------------------------------------------------------*/
- tcConnectptr.p->noOfNodes = 0; // == releaseAbort(signal)
- tcConnectptr.p->tcConnectstate = OS_ABORTING;
- break;
- case OS_CONNECTED:
- jam();
- /*-----------------------------------------------------------------------
- * WE ARE STILL IN THE INITIAL PHASE OF THIS OPERATION.
- * NEED NOT BOTHER ABOUT ANY LQH ABORTS.
- *-----------------------------------------------------------------------*/
- tcConnectptr.p->noOfNodes = 0; // == releaseAbort(signal)
- tcConnectptr.p->tcConnectstate = OS_ABORTING;
- break;
- case OS_PREPARED:
- jam();
- case OS_OPERATING:
- jam();
- /*----------------------------------------------------------------------
- * WE HAVE SENT LQHKEYREQ AND ARE IN SOME STATE OF EITHER STILL
- * SENDING THE OPERATION, WAITING FOR REPLIES, WAITING FOR MORE
- * ATTRINFO OR OPERATION IS PREPARED. WE NEED TO ABORT ALL LQH'S.
- *----------------------------------------------------------------------*/
- releaseAndAbort(signal);
- tcConnectptr.p->tcConnectstate = OS_ABORT_SENT;
- TloopCount += 127;
- break;
- case OS_ABORTING:
- jam();
- break;
- case OS_ABORT_SENT:
- jam();
- DEBUG("ABORT_SENT state in abort015Lab(), not expected");
- systemErrorLab(signal);
- return;
- default:
- jam();
- DEBUG("tcConnectstate = " << tcConnectptr.p->tcConnectstate);
- systemErrorLab(signal);
- return;
- }//switch
- if (tcConnectptr.p->nextTcConnect != RNIL) {
- jam();
- tcConnectptr.i = tcConnectptr.p->nextTcConnect;
- if (TloopCount < 1024) {
- goto ABORT020;
- } else {
- jam();
- /*---------------------------------------------------------------------
- * Reset timer to avoid time-out in real-time break.
- * Increase counter to ensure that we don't think that all ABORTED have
- * been received before all have been sent.
- *---------------------------------------------------------------------*/
- apiConnectptr.p->counter++;
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- signal->theData[0] = TcContinueB::ZABORT_BREAK;
- signal->theData[1] = tcConnectptr.i;
- signal->theData[2] = apiConnectptr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
- return;
- }//if
- }//if
- if (apiConnectptr.p->counter > 0) {
- jam();
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- return;
- }//if
- /*-----------------------------------------------------------------------
- * WE HAVE NOW COMPLETED THE ABORT PROCESS. WE HAVE RECEIVED ABORTED
- * FROM ALL PARTICIPANTS IN THE TRANSACTION. WE CAN NOW RELEASE ALL
- * RESOURCES CONNECTED TO THE TRANSACTION AND SEND THE ABORT RESPONSE
- *------------------------------------------------------------------------*/
- releaseAbortResources(signal);
- }//Dbtc::abort015Lab()
- /*--------------------------------------------------------------------------*/
- /* RELEASE KEY AND ATTRINFO OBJECTS AND SEND ABORT TO THE LQH BLOCK. */
- /*--------------------------------------------------------------------------*/
- int Dbtc::releaseAndAbort(Signal* signal)
- {
- HostRecordPtr localHostptr;
- UintR TnoLoops = tcConnectptr.p->noOfNodes;
-
- apiConnectptr.p->counter++;
- bool prevAlive = false;
- for (Uint32 Ti = 0; Ti < TnoLoops ; Ti++) {
- localHostptr.i = tcConnectptr.p->tcNodedata[Ti];
- ptrCheckGuard(localHostptr, chostFilesize, hostRecord);
- if (localHostptr.p->hostStatus == HS_ALIVE) {
- jam();
- if (prevAlive) {
- // if previous is alive, its LQH forwards abort to this node
- jam();
- continue;
- }
- /* ************< */
- /* ABORT < */
- /* ************< */
- tblockref = calcLqhBlockRef(localHostptr.i);
- signal->theData[0] = tcConnectptr.i;
- signal->theData[1] = cownref;
- signal->theData[2] = apiConnectptr.p->transid[0];
- signal->theData[3] = apiConnectptr.p->transid[1];
- sendSignal(tblockref, GSN_ABORT, signal, 4, JBB);
- prevAlive = true;
- } else {
- jam();
- signal->theData[0] = tcConnectptr.i;
- signal->theData[1] = apiConnectptr.p->transid[0];
- signal->theData[2] = apiConnectptr.p->transid[1];
- signal->theData[3] = localHostptr.i;
- signal->theData[4] = ZFALSE;
- sendSignal(cownref, GSN_ABORTED, signal, 5, JBB);
- prevAlive = false;
- }//if
- }//for
- return 1;
- }//Dbtc::releaseAndAbort()
- /* ------------------------------------------------------------------------- */
- /* ------- ENTER TIME_SIGNAL ------- */
- /* */
- /* ------------------------------------------------------------------------- */
- void Dbtc::execTIME_SIGNAL(Signal* signal)
- {
-
- jamEntry();
- ctcTimer++;
- if (csystemStart != SSS_TRUE) {
- jam();
- return;
- }//if
- checkStartTimeout(signal);
- checkStartFragTimeout(signal);
- }//Dbtc::execTIME_SIGNAL()
- /*------------------------------------------------*/
- /* Start timeout handling if not already going on */
- /*------------------------------------------------*/
- void Dbtc::checkStartTimeout(Signal* signal)
- {
- ctimeOutCheckCounter++;
- if (ctimeOutCheckActive == TOCS_TRUE) {
- jam();
- // Check heartbeat of timeout loop
- if(ctimeOutCheckHeartbeat > ctimeOutCheckLastHeartbeat){
- jam();
- ctimeOutMissedHeartbeats = 0;
- }else{
- jam();
- ctimeOutMissedHeartbeats++;
- if (ctimeOutMissedHeartbeats > 100){
- jam();
- systemErrorLab(signal);
- }
- }
- ctimeOutCheckLastHeartbeat = ctimeOutCheckHeartbeat;
- return;
- }//if
- if (ctimeOutCheckCounter < ctimeOutCheckDelay) {
- jam();
- /*------------------------------------------------------------------*/
- /* */
- /* NO TIME-OUT CHECKED THIS TIME. WAIT MORE. */
- /*------------------------------------------------------------------*/
- return;
- }//if
- ctimeOutCheckActive = TOCS_TRUE;
- ctimeOutCheckCounter = 0;
- timeOutLoopStartLab(signal, 0); // 0 is first api connect record
- return;
- }//Dbtc::execTIME_SIGNAL()
- /*----------------------------------------------------------------*/
- /* Start fragment (scan) timeout handling if not already going on */
- /*----------------------------------------------------------------*/
- void Dbtc::checkStartFragTimeout(Signal* signal)
- {
- ctimeOutCheckFragCounter++;
- if (ctimeOutCheckFragActive == TOCS_TRUE) {
- jam();
- return;
- }//if
- if (ctimeOutCheckFragCounter < ctimeOutCheckDelay) {
- jam();
- /*------------------------------------------------------------------*/
- /* NO TIME-OUT CHECKED THIS TIME. WAIT MORE. */
- /*------------------------------------------------------------------*/
- return;
- }//if
- // Go through the fragment records and look for timeout in a scan.
- ctimeOutCheckFragActive = TOCS_TRUE;
- ctimeOutCheckFragCounter = 0;
- timeOutLoopStartFragLab(signal, 0); // 0 means first scan record
- }//checkStartFragTimeout()
- /*------------------------------------------------------------------*/
- /* IT IS NOW TIME TO CHECK WHETHER ANY TRANSACTIONS HAVE */
- /* BEEN DELAYED FOR SO LONG THAT WE ARE FORCED TO PERFORM */
- /* SOME ACTION, EITHER ABORT OR RESEND OR REMOVE A NODE FROM */
- /* THE WAITING PART OF A PROTOCOL. */
- /*
- The algorithm used here is to check 1024 transactions at a time before
- doing a real-time break.
- To avoid aborting both transactions in a deadlock detected by time-out
- we insert a random extra time-out of upto 630 ms by using the lowest
- six bits of the api connect reference.
- We spread it out from 0 to 630 ms if base time-out is larger than 3 sec,
- we spread it out from 0 to 70 ms if base time-out is smaller than 300 msec,
- and otherwise we spread it out 310 ms.
- */
- /*------------------------------------------------------------------*/
- void Dbtc::timeOutLoopStartLab(Signal* signal, Uint32 api_con_ptr)
- {
- Uint32 end_ptr, time_passed, time_out_value, mask_value;
- const Uint32 api_con_sz= capiConnectFilesize;
- const Uint32 tc_timer= ctcTimer;
- const Uint32 time_out_param= ctimeOutValue;
- ctimeOutCheckHeartbeat = tc_timer;
- if (api_con_ptr + 1024 < api_con_sz) {
- jam();
- end_ptr= api_con_ptr + 1024;
- } else {
- jam();
- end_ptr= api_con_sz;
- }
- if (time_out_param > 300) {
- jam();
- mask_value= 63;
- } else if (time_out_param < 30) {
- jam();
- mask_value= 7;
- } else {
- jam();
- mask_value= 31;
- }
- for ( ; api_con_ptr < end_ptr; api_con_ptr++) {
- Uint32 api_timer= getApiConTimer(api_con_ptr);
- jam();
- if (api_timer != 0) {
- time_out_value= time_out_param + (api_con_ptr & mask_value);
- time_passed= tc_timer - api_timer;
- if (time_passed > time_out_value) {
- jam();
- timeOutFoundLab(signal, api_con_ptr);
- return;
- }
- }
- }
- if (api_con_ptr == api_con_sz) {
- jam();
- /*------------------------------------------------------------------*/
- /* */
- /* WE HAVE NOW CHECKED ALL TRANSACTIONS FOR TIME-OUT AND ALSO */
- /* STARTED TIME-OUT HANDLING OF THOSE WE FOUND. WE ARE NOW */
- /* READY AND CAN WAIT FOR THE NEXT TIME-OUT CHECK. */
- /*------------------------------------------------------------------*/
- ctimeOutCheckActive = TOCS_FALSE;
- } else {
- jam();
- sendContinueTimeOutControl(signal, api_con_ptr);
- }
- return;
- }//Dbtc::timeOutLoopStartLab()
- void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr)
- {
- sendContinueTimeOutControl(signal, TapiConPtr + 1);
-
- apiConnectptr.i = TapiConPtr;
- ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
- /*------------------------------------------------------------------*/
- /* */
- /* THIS TRANSACTION HAVE EXPERIENCED A TIME-OUT AND WE NEED TO*/
- /* FIND OUT WHAT WE NEED TO DO BASED ON THE STATE INFORMATION.*/
- /*------------------------------------------------------------------*/
- DEBUG("[ H'" << hex << apiConnectptr.p->transid[0]
- << " H'" << apiConnectptr.p->transid[1] << "] " << dec
- << "Time-out in state = " << apiConnectptr.p->apiConnectstate
- << " apiConnectptr.i = " << apiConnectptr.i
- << " - exec: " << apiConnectptr.p->m_exec_flag
- << " - place: " << c_apiConTimer_line[apiConnectptr.i]);
- switch (apiConnectptr.p->apiConnectstate) {
- case CS_STARTED:
- ndbrequire(c_apiConTimer_line[apiConnectptr.i] != 3615);
- if(apiConnectptr.p->lqhkeyreqrec == apiConnectptr.p->lqhkeyconfrec){
- jam();
- /*
- We are waiting for application to continue the transaction. In this
- particular state we will use the application timeout parameter rather
- than the shorter Deadlock detection timeout.
- */
- if (c_appl_timeout_value == 0 ||
- (ctcTimer - getApiConTimer(apiConnectptr.i)) <= c_appl_timeout_value) {
- jam();
- return;
- }//if
- }
- apiConnectptr.p->returnsignal = RS_TCROLLBACKREP;
- apiConnectptr.p->returncode = ZTIME_OUT_ERROR;
- abort010Lab(signal);
- return;
- case CS_RECEIVING:
- case CS_REC_COMMITTING:
- case CS_START_COMMITTING:
- jam();
- /*------------------------------------------------------------------*/
- /* WE ARE STILL IN THE PREPARE PHASE AND THE TRANSACTION HAS */
- /* NOT YET REACHED ITS COMMIT POINT. THUS IT IS NOW OK TO */
- /* START ABORTING THE TRANSACTION. ALSO START CHECKING THE */
- /* REMAINING TRANSACTIONS. */
- /*------------------------------------------------------------------*/
- terrorCode = ZTIME_OUT_ERROR;
- abortErrorLab(signal);
- return;
- case CS_COMMITTING:
- jam();
- /*------------------------------------------------------------------*/
- // We are simply waiting for a signal in the job buffer. Only extreme
- // conditions should get us here. We ignore it.
- /*------------------------------------------------------------------*/
- case CS_COMPLETING:
- jam();
- /*------------------------------------------------------------------*/
- // We are simply waiting for a signal in the job buffer. Only extreme
- // conditions should get us here. We ignore it.
- /*------------------------------------------------------------------*/
- case CS_PREPARE_TO_COMMIT:
- jam();
- /*------------------------------------------------------------------*/
- /* WE ARE WAITING FOR DIH TO COMMIT THE TRANSACTION. WE SIMPLY*/
- /* KEEP WAITING SINCE THERE IS NO BETTER IDEA ON WHAT TO DO. */
- /* IF IT IS BLOCKED THEN NO TRANSACTION WILL PASS THIS GATE. */
- // To ensure against strange bugs we crash the system if we have passed
- // time-out period by a factor of 10 and it is also at least 5 seconds.
- /*------------------------------------------------------------------*/
- if (((ctcTimer - getApiConTimer(apiConnectptr.i)) > (10 * ctimeOutValue)) &&
- ((ctcTimer - getApiConTimer(apiConnectptr.i)) > 500)) {
- jam();
- systemErrorLab(signal);
- }//if
- break;
- case CS_COMMIT_SENT:
- jam();
- /*------------------------------------------------------------------*/
- /* WE HAVE SENT COMMIT TO A NUMBER OF NODES. WE ARE CURRENTLY */
- /* WAITING FOR THEIR REPLY. WITH NODE RECOVERY SUPPORTED WE */
- /* WILL CHECK FOR CRASHED NODES AND RESEND THE COMMIT SIGNAL */
- /* TO THOSE NODES THAT HAVE MISSED THE COMMIT SIGNAL DUE TO */
- /* A NODE FAILURE. */
- /*------------------------------------------------------------------*/
- tabortInd = ZCOMMIT_SETUP;
- setupFailData(signal);
- toCommitHandlingLab(signal);
- return;
- case CS_COMPLETE_SENT:
- jam();
- /*--------------------------------------------------------------------*/
- /* WE HAVE SENT COMPLETE TO A NUMBER OF NODES. WE ARE CURRENTLY */
- /* WAITING FOR THEIR REPLY. WITH NODE RECOVERY SUPPORTED WE */
- /* WILL CHECK FOR CRASHED NODES AND RESEND THE COMPLETE SIGNAL */
- /* TO THOSE NODES THAT HAVE MISSED THE COMPLETE SIGNAL DUE TO */
- /* A NODE FAILURE. */
- /*--------------------------------------------------------------------*/
- tabortInd = ZCOMMIT_SETUP;
- setupFailData(signal);
- toCompleteHandlingLab(signal);
- return;
- case CS_ABORTING:
- jam();
- /*------------------------------------------------------------------*/
- /* TIME-OUT DURING ABORT. WE NEED TO SEND ABORTED FOR ALL */
- /* NODES THAT HAVE FAILED BEFORE SENDING ABORTED. */
- /*------------------------------------------------------------------*/
- tcConnectptr.i = apiConnectptr.p->firstTcConnect;
- sendAbortedAfterTimeout(signal, 0);
- break;
- case CS_START_SCAN:{
- jam();
- ScanRecordPtr scanPtr;
- scanPtr.i = apiConnectptr.p->apiScanRec;
- ptrCheckGuard(scanPtr, cscanrecFileSize, scanRecord);
- scanError(signal, scanPtr, ZSCANTIME_OUT_ERROR);
- break;
- }
- case CS_WAIT_ABORT_CONF:
- jam();
- tcConnectptr.i = apiConnectptr.p->currentTcConnect;
- ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
- arrGuard(apiConnectptr.p->currentReplicaNo, 4);
- hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo];
- ptrCheckGuard(hostptr, chostFilesize, hostRecord);
- if (hostptr.p->hostStatus == HS_ALIVE) {
- /*------------------------------------------------------------------*/
- // Time-out waiting for ABORTCONF. We will resend the ABORTREQ just in
- // case.
- /*------------------------------------------------------------------*/
- warningReport(signal, 20);
- apiConnectptr.p->timeOutCounter++;
- if (apiConnectptr.p->timeOutCounter > 3) {
- /*------------------------------------------------------------------*/
- // 100 time-outs are not acceptable. We will shoot down the node
- // not responding.
- /*------------------------------------------------------------------*/
- reportNodeFailed(signal, hostptr.i);
- }//if
- apiConnectptr.p->currentReplicaNo++;
- }//if
- tcurrentReplicaNo = (Uint8)Z8NIL;
- toAbortHandlingLab(signal);
- return;
- case CS_WAIT_COMMIT_CONF:
- jam();
- tcConnectptr.i = apiConnectptr.p->currentTcConnect;
- ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
- arrGuard(apiConnectptr.p->currentReplicaNo, 4);
- hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo];
- ptrCheckGuard(hostptr, chostFilesize, hostRecord);
- if (hostptr.p->hostStatus == HS_ALIVE) {
- /*------------------------------------------------------------------*/
- // Time-out waiting for COMMITCONF. We will resend the COMMITREQ just in
- // case.
- /*------------------------------------------------------------------*/
- warningReport(signal, 21);
- apiConnectptr.p->timeOutCounter++;
- if (apiConnectptr.p->timeOutCounter > 3) {
- /*------------------------------------------------------------------*/
- // 100 time-outs are not acceptable. We will shoot down the node
- // not responding.
- /*------------------------------------------------------------------*/
- reportNodeFailed(signal, hostptr.i);
- }//if
- apiConnectptr.p->currentReplicaNo++;
- }//if
- tcurrentReplicaNo = (Uint8)Z8NIL;
- toCommitHandlingLab(signal);
- return;
- case CS_WAIT_COMPLETE_CONF:
- jam();
- tcConnectptr.i = apiConnectptr.p->currentTcConnect;
- ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
- arrGuard(apiConnectptr.p->currentReplicaNo, 4);
- hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo];
- ptrCheckGuard(hostptr, chostFilesize, hostRecord);
- if (hostptr.p->hostStatus == HS_ALIVE) {
- /*------------------------------------------------------------------*/
- // Time-out waiting for COMPLETECONF. We will resend the COMPLETEREQ
- // just in case.
- /*------------------------------------------------------------------*/
- warningReport(signal, 22);
- apiConnectptr.p->timeOutCounter++;
- if (apiConnectptr.p->timeOutCounter > 100) {
- /*------------------------------------------------------------------*/
- // 100 time-outs are not acceptable. We will shoot down the node
- // not responding.
- /*------------------------------------------------------------------*/
- reportNodeFailed(signal, hostptr.i);
- }//if
- apiConnectptr.p->currentReplicaNo++;
- }//if
- tcurrentReplicaNo = (Uint8)Z8NIL;
- toCompleteHandlingLab(signal);
- return;
- case CS_FAIL_PREPARED:
- jam();
- case CS_FAIL_COMMITTING:
- jam();
- case CS_FAIL_COMMITTED:
- jam();
- case CS_REC_PREPARING:
- jam();
- case CS_START_PREPARING:
- jam();
- case CS_PREPARED:
- jam();
- case CS_RESTART:
- jam();
- case CS_FAIL_ABORTED:
- jam();
- case CS_DISCONNECTED:
- jam();
- default:
- jam();
- /*------------------------------------------------------------------*/
- /* AN IMPOSSIBLE STATE IS SET. CRASH THE SYSTEM. */
- /*------------------------------------------------------------------*/
- DEBUG("State = " << apiConnectptr.p->apiConnectstate);
- systemErrorLab(signal);
- return;
- }//switch
- return;
- }//Dbtc::timeOutFoundLab()
- void Dbtc::sendAbortedAfterTimeout(Signal* signal, int Tcheck)
- {
- ApiConnectRecord * transP = apiConnectptr.p;
- if(transP->abortState == AS_IDLE){
- jam();
- warningEvent("TC: %d: %d state=%d abort==IDLE place: %d fop=%d t: %d",
- __LINE__,
- apiConnectptr.i,
- transP->apiConnectstate,
- c_apiConTimer_line[apiConnectptr.i],
- transP->firstTcConnect,
- c_apiConTimer[apiConnectptr.i]
- );
- ndbout_c("TC: %d: %d state=%d abort==IDLE place: %d fop=%d t: %d",
- __LINE__,
- apiConnectptr.i,
- transP->apiConnectstate,
- c_apiConTimer_line[apiConnectptr.i],
- transP->firstTcConnect,
- c_apiConTimer[apiConnectptr.i]
- );
- ndbrequire(false);
- setApiConTimer(apiConnectptr.i, 0, __LINE__);
- return;
- }
-
- OperationState tmp[16];
-
- Uint32 TloopCount = 0;
- do {
- jam();
- if (tcConnectptr.i == RNIL) {
- jam();
- if (Tcheck == 0) {
- jam();
- /*------------------------------------------------------------------
- * All nodes had already reported ABORTED for all tcConnect records.
- * Crash since it is an error situation that we then received a
- * time-out.
- *------------------------------------------------------------------*/
- char buf[96]; buf[0] = 0;
- char buf2[96];
- BaseString::snprintf(buf, sizeof(buf), "TC %d: %d ops:",
- __LINE__, apiConnectptr.i);
- for(Uint32 i = 0; i<TloopCount; i++){
- BaseString::snprintf(buf2, sizeof(buf2), "%s %d", buf, tmp[i]);
- BaseString::snprintf(buf, sizeof(buf), buf2);
- }
- warningEvent(buf);
- ndbout_c(buf);
- ndbrequire(false);
- }
- releaseAbortResources(signal);
- return;
- }//if
- TloopCount++;
- if (TloopCount >= 1024) {
- jam();
- /*------------------------------------------------------------------*/
- // Insert a real-time break for large transactions to avoid blowing
- // away the job buffer.
- /*------------------------------------------------------------------*/
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- apiConnectptr.p->counter++;
- signal->theData[0] = TcContinueB::ZABORT_TIMEOUT_BREAK;
- signal->theData[1] = tcConnectptr.i;
- signal->theData[2] = apiConnectptr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
- return;
- }//if
- ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
- if(TloopCount < 16){
- jam();
- tmp[TloopCount-1] = tcConnectptr.p->tcConnectstate;
- }
- if (tcConnectptr.p->tcConnectstate == OS_ABORT_SENT) {
- jam();
- /*------------------------------------------------------------------*/
- // We have sent an ABORT signal to this node but not yet received any
- // reply. We have to send an ABORTED signal on our own in some cases.
- // If the node is declared as up and running and still do not respond
- // in time to the ABORT signal we will declare it as dead.
- /*------------------------------------------------------------------*/
- UintR Ti = 0;
- arrGuard(tcConnectptr.p->noOfNodes, 4);
- for (Ti = 0; Ti < tcConnectptr.p->noOfNodes; Ti++) {
- jam();
- if (tcConnectptr.p->tcNodedata[Ti] != 0) {
- TloopCount += 31;
- Tcheck = 1;
- hostptr.i = tcConnectptr.p->tcNodedata[Ti];
- ptrCheckGuard(hostptr, chostFilesize, hostRecord);
- if (hostptr.p->hostStatus == HS_ALIVE) {
- jam();
- /*---------------------------------------------------------------
- * A backup replica has not sent ABORTED.
- * Could be that a node before him has crashed.
- * Send an ABORT signal specifically to this node.
- * We will not send to any more nodes after this
- * to avoid race problems.
- * To also ensure that we use this message also as a heartbeat
- * we will move this node to the primary replica seat.
- * The primary replica and any failed node after it will
- * be removed from the node list. Update also number of nodes.
- * Finally break the loop to ensure we don't mess
- * things up by executing another loop.
- * We also update the timer to ensure we don't get time-out
- * too early.
- *--------------------------------------------------------------*/
- BlockReference TBRef = calcLqhBlockRef(hostptr.i);
- signal->theData[0] = tcConnectptr.i;
- signal->theData[1] = cownref;
- signal->theData[2] = apiConnectptr.p->transid[0];
- signal->theData[3] = apiConnectptr.p->transid[1];
- sendSignal(TBRef, GSN_ABORT, signal, 4, JBB);
- setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
- break;
- } else {
- jam();
- /*--------------------------------------------------------------
- * The node we are waiting for is dead. We will send ABORTED to