DblqhMain.cpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:703k
- if (logPartPtr.p->logPartState != LogPartRecord::SR_FOURTH_PHASE_STARTED) {
- jam();
- systemErrorLab(signal);
- return;
- } else {
- jam();
- /* ------------------------------------------------------------------
- * THIS LOG PART WAS NOT COMPLETED YET.
- * EXIT AND WAIT FOR IT TO COMPLETE
- * ----------------------------------------------------------------- */
- return;
- }//if
- }//if
- }//for
- /* ------------------------------------------------------------------------
- * ALL LOG PARTS HAVE COMPLETED PHASE FOUR OF THE SYSTEM RESTART.
- * WE CAN NOW SEND START_RECCONF TO THE MASTER DIH IF IT WAS A
- * SYSTEM RESTART. OTHERWISE WE WILL CONTINUE WITH AN INITIAL START.
- * SET LOG PART STATE TO IDLE TO
- * INDICATE THAT NOTHING IS GOING ON IN THE LOG PART.
- * ----------------------------------------------------------------------- */
- for (logPartPtr.i = 0; logPartPtr.i <= 3; logPartPtr.i++) {
- ptrAss(logPartPtr, logPartRecord);
- logPartPtr.p->logPartState = LogPartRecord::IDLE;
- }//for
- if ((cstartType == NodeState::ST_INITIAL_START) ||
- (cstartType == NodeState::ST_INITIAL_NODE_RESTART)) {
- jam();
-
- ndbrequire(cinitialStartOngoing == ZTRUE);
- cinitialStartOngoing = ZFALSE;
- checkStartCompletedLab(signal);
- return;
- } else if ((cstartType == NodeState::ST_NODE_RESTART) ||
- (cstartType == NodeState::ST_SYSTEM_RESTART)) {
- jam();
- StartRecConf * conf = (StartRecConf*)signal->getDataPtrSend();
- conf->startingNodeId = getOwnNodeId();
- sendSignal(cmasterDihBlockref, GSN_START_RECCONF, signal,
- StartRecConf::SignalLength, JBB);
- if(cstartType == NodeState::ST_SYSTEM_RESTART){
- fragptr.i = c_redo_log_complete_frags;
- while(fragptr.i != RNIL){
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- signal->theData[0] = fragptr.p->tabRef;
- signal->theData[1] = fragptr.p->fragId;
- sendSignal(DBACC_REF, GSN_EXPANDCHECK2, signal, 2, JBB);
- fragptr.i = fragptr.p->nextFrag;
- }
- }
- } else {
- ndbrequire(false);
- }//if
- return;
- }//Dblqh::srFourthComp()
- /* ######################################################################### */
- /* ####### ERROR MODULE ####### */
- /* */
- /* ######################################################################### */
- void Dblqh::warningHandlerLab(Signal* signal)
- {
- systemErrorLab(signal);
- return;
- }//Dblqh::warningHandlerLab()
- /*---------------------------------------------------------------------------*/
- /* AN ERROR OCCURRED THAT WE WILL NOT TREAT AS SYSTEM ERROR. MOST OFTEN THIS */
- /* WAS CAUSED BY AN ERRONEUS SIGNAL SENT BY ANOTHER NODE. WE DO NOT WISH TO */
- /* CRASH BECAUSE OF FAULTS IN OTHER NODES. THUS WE ONLY REPORT A WARNING. */
- /* THIS IS CURRENTLY NOT IMPLEMENTED AND FOR THE MOMENT WE GENERATE A SYSTEM */
- /* ERROR SINCE WE WANT TO FIND FAULTS AS QUICKLY AS POSSIBLE IN A TEST PHASE.*/
- /* IN A LATER PHASE WE WILL CHANGE THIS TO BE A WARNING MESSAGE INSTEAD. */
- /*---------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------*/
- /* THIS TYPE OF ERROR SHOULD NOT GENERATE A SYSTEM ERROR IN A PRODUCT */
- /* RELEASE. THIS IS A TEMPORARY SOLUTION DURING TEST PHASE TO QUICKLY */
- /* FIND ERRORS. NORMALLY THIS SHOULD GENERATE A WARNING MESSAGE ONTO */
- /* SOME ERROR LOGGER. THIS WILL LATER BE IMPLEMENTED BY SOME SIGNAL. */
- /*---------------------------------------------------------------------------*/
- /* ------ SYSTEM ERROR SITUATIONS ------- */
- /* IN SITUATIONS WHERE THE STATE IS ERRONEOUS OR IF THE ERROR OCCURS IN */
- /* THE COMMIT, COMPLETE OR ABORT PHASE, WE PERFORM A CRASH OF THE AXE VM*/
- /*---------------------------------------------------------------------------*/
- void Dblqh::systemErrorLab(Signal* signal)
- {
- progError(0, 0);
- /*************************************************************************>*/
- /* WE WANT TO INVOKE AN IMMEDIATE ERROR HERE SO WE GET THAT BY */
- /* INSERTING A CERTAIN POINTER OUT OF RANGE. */
- /*************************************************************************>*/
- }//Dblqh::systemErrorLab()
- /* ------- ERROR SITUATIONS ------- */
- void Dblqh::aiStateErrorCheckLab(Signal* signal, Uint32* dataPtr, Uint32 length)
- {
- ndbrequire(tcConnectptr.p->abortState != TcConnectionrec::ABORT_IDLE);
- if (tcConnectptr.p->transactionState != TcConnectionrec::IDLE) {
- jam();
- /*************************************************************************>*/
- /* TRANSACTION ABORT IS ONGOING. IT CAN STILL BE A PART OF AN */
- /* OPERATION THAT SHOULD CONTINUE SINCE THE TUPLE HAS NOT ARRIVED */
- /* YET. THIS IS POSSIBLE IF ACTIVE CREATION OF THE FRAGMENT IS */
- /* ONGOING. */
- /*************************************************************************>*/
- if (tcConnectptr.p->activeCreat == ZTRUE) {
- jam();
- /*************************************************************************>*/
- /* ONGOING ABORTS DURING ACTIVE CREATION MUST SAVE THE ATTRIBUTE INFO*/
- /* SO THAT IT CAN BE SENT TO THE NEXT NODE IN THE COMMIT CHAIN. THIS */
- /* IS NEEDED SINCE ALL ABORTS DURING CREATION OF A FRAGMENT ARE NOT */
- /* REALLY ERRORS. A MISSING TUPLE TO BE UPDATED SIMPLY MEANS THAT */
- /* IT HASN'T BEEN TRANSFERRED TO THE NEW REPLICA YET. */
- /*************************************************************************>*/
- /*************************************************************************>*/
- /* AFTER THIS ERROR THE ABORT MUST BE COMPLETED. TO ENSURE THIS SET */
- /* ACTIVE CREATION TO FALSE. THIS WILL ENSURE THAT THE ABORT IS */
- /* COMPLETED. */
- /*************************************************************************>*/
- if (saveTupattrbuf(signal, dataPtr, length) == ZOK) {
- jam();
- if (tcConnectptr.p->transactionState ==
- TcConnectionrec::WAIT_AI_AFTER_ABORT) {
- if (tcConnectptr.p->currTupAiLen == tcConnectptr.p->totReclenAi) {
- jam();
- /*************************************************************************>*/
- /* WE WERE WAITING FOR MORE ATTRIBUTE INFO AFTER A SUCCESSFUL ABORT */
- /* IN ACTIVE CREATION STATE. THE TRANSACTION SHOULD CONTINUE AS IF */
- /* IT WAS COMMITTED. NOW ALL INFO HAS ARRIVED AND WE CAN CONTINUE */
- /* WITH NORMAL PROCESSING AS IF THE TRANSACTION WAS PREPARED. */
- /* SINCE THE FRAGMENT IS UNDER CREATION WE KNOW THAT LOGGING IS */
- /* DISABLED. WE STILL HAVE TO CATER FOR DIRTY OPERATION OR NOT. */
- /*************************************************************************>*/
- tcConnectptr.p->abortState = TcConnectionrec::ABORT_IDLE;
- rwConcludedAiLab(signal);
- return;
- } else {
- ndbrequire(tcConnectptr.p->currTupAiLen < tcConnectptr.p->totReclenAi);
- jam();
- return; /* STILL WAITING FOR MORE ATTRIBUTE INFO */
- }//if
- }//if
- } else {
- jam();
- /*************************************************************************>*/
- /* AFTER THIS ERROR THE ABORT MUST BE COMPLETED. TO ENSURE THIS SET */
- /* ACTIVE CREATION TO ABORT. THIS WILL ENSURE THAT THE ABORT IS */
- /* COMPLETED AND THAT THE ERROR CODE IS PROPERLY SET */
- /*************************************************************************>*/
- tcConnectptr.p->errorCode = terrorCode;
- tcConnectptr.p->activeCreat = ZFALSE;
- if (tcConnectptr.p->transactionState ==
- TcConnectionrec::WAIT_AI_AFTER_ABORT) {
- jam();
- /*************************************************************************>*/
- /* ABORT IS ALREADY COMPLETED. WE NEED TO RESTART IT FROM WHERE IT */
- /* WAS INTERRUPTED. */
- /*************************************************************************>*/
- continueAbortLab(signal);
- return;
- } else {
- jam();
- return;
- /*************************************************************************>*/
- // Abort is ongoing. It will complete since we set the activeCreat = ZFALSE
- /*************************************************************************>*/
- }//if
- }//if
- }//if
- }//if
- /*************************************************************************>*/
- /* TRANSACTION HAVE BEEN ABORTED. THUS IGNORE ALL SIGNALS BELONGING TO IT. */
- /*************************************************************************>*/
- return;
- }//Dblqh::aiStateErrorCheckLab()
- void Dblqh::takeOverErrorLab(Signal* signal)
- {
- terrorCode = ZTAKE_OVER_ERROR;
- abortErrorLab(signal);
- return;
- }//Dblqh::takeOverErrorLab()
- /* ##########################################################################
- * TEST MODULE
- * ######################################################################### */
- #ifdef VM_TRACE
- void Dblqh::execTESTSIG(Signal* signal)
- {
- jamEntry();
- Uint32 userpointer = signal->theData[0];
- BlockReference userblockref = signal->theData[1];
- Uint32 testcase = signal->theData[2];
- signal->theData[0] = userpointer;
- signal->theData[1] = cownref;
- signal->theData[2] = testcase;
- sendSignal(userblockref, GSN_TESTSIG, signal, 25, JBB);
- return;
- }//Dblqh::execTESTSIG()
- /* *************** */
- /* MEMCHECKREQ > */
- /* *************** */
- /* ************************************************************************>>
- * THIS SIGNAL IS PURELY FOR TESTING PURPOSES. IT CHECKS THE FREE LIST
- * AND REPORTS THE NUMBER OF FREE RECORDS.
- * THIS CAN BE DONE TO ENSURE THAT NO RECORDS HAS BEEN LOST
- * ************************************************************************> */
- void Dblqh::execMEMCHECKREQ(Signal* signal)
- {
- Uint32* dataPtr = &signal->theData[0];
- jamEntry();
- BlockReference userblockref = signal->theData[0];
- Uint32 index = 0;
- for (Uint32 i = 0; i < 7; i++)
- dataPtr[i] = 0;
- addfragptr.i = cfirstfreeAddfragrec;
- while (addfragptr.i != RNIL) {
- ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
- addfragptr.i = addfragptr.p->nextAddfragrec;
- dataPtr[index]++;
- }//while
- index++;
- attrinbufptr.i = cfirstfreeAttrinbuf;
- while (attrinbufptr.i != RNIL) {
- ptrCheckGuard(attrinbufptr, cattrinbufFileSize, attrbuf);
- attrinbufptr.i = attrinbufptr.p->attrbuf[ZINBUF_NEXT];
- dataPtr[index]++;
- }//while
- index++;
- databufptr.i = cfirstfreeDatabuf;
- while (databufptr.i != RNIL) {
- ptrCheckGuard(databufptr, cdatabufFileSize, databuf);
- databufptr.i = databufptr.p->nextDatabuf;
- dataPtr[index]++;
- }//while
- index++;
- fragptr.i = cfirstfreeFragrec;
- while (fragptr.i != RNIL) {
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- fragptr.i = fragptr.p->nextFrag;
- dataPtr[index]++;
- }//while
- index++;
- for (tabptr.i = 0;
- tabptr.i < ctabrecFileSize;
- tabptr.i++) {
- ptrAss(tabptr, tablerec);
- if (tabptr.p->tableStatus == Tablerec::NOT_DEFINED) {
- dataPtr[index]++;
- }//if
- }//for
- index++;
- tcConnectptr.i = cfirstfreeTcConrec;
- while (tcConnectptr.i != RNIL) {
- ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- tcConnectptr.i = tcConnectptr.p->nextTcConnectrec;
- dataPtr[index]++;
- }//while
- sendSignal(userblockref, GSN_MEMCHECKCONF, signal, 10, JBB);
- return;
- }//Dblqh::execMEMCHECKREQ()
- #endif
- /* ************************************************************************* */
- /* ************************* STATEMENT BLOCKS ****************************** */
- /* ************************************************************************* */
- /* ========================================================================= */
- /* ====== BUILD LINKED LIST OF LOG PAGES AFTER RECEIVING FSREADCONF ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::buildLinkedLogPageList(Signal* signal)
- {
- LogPageRecordPtr bllLogPagePtr;
- arrGuard(lfoPtr.p->noPagesRw - 1, 16);
- arrGuard(lfoPtr.p->noPagesRw, 16);
- for (UintR tbllIndex = 0; tbllIndex < lfoPtr.p->noPagesRw; tbllIndex++) {
- jam();
- /* ----------------------------------------------------------------------
- * BUILD LINKED LIST BUT ALSO ENSURE THAT PAGE IS NOT SEEN AS DIRTY
- * INITIALLY.
- * --------------------------------------------------------------------- */
- bllLogPagePtr.i = lfoPtr.p->logPageArray[tbllIndex];
- ptrCheckGuard(bllLogPagePtr, clogPageFileSize, logPageRecord);
- // #if VM_TRACE
- // // Check logPage checksum before modifying it
- // Uint32 calcCheckSum = calcPageCheckSum(bllLogPagePtr);
- // Uint32 checkSum = bllLogPagePtr.p->logPageWord[ZPOS_CHECKSUM];
- // if (checkSum != calcCheckSum) {
- // ndbout << "Redolog: Checksum failure." << endl;
- // progError(__LINE__, ERR_NDBREQUIRE, "Redolog: Checksum failure.");
- // }
- // #endif
- bllLogPagePtr.p->logPageWord[ZNEXT_PAGE] =
- lfoPtr.p->logPageArray[tbllIndex + 1];
- bllLogPagePtr.p->logPageWord[ZPOS_DIRTY] = ZNOT_DIRTY;
- }//for
- bllLogPagePtr.i = lfoPtr.p->logPageArray[lfoPtr.p->noPagesRw - 1];
- ptrCheckGuard(bllLogPagePtr, clogPageFileSize, logPageRecord);
- bllLogPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
- }//Dblqh::buildLinkedLogPageList()
- /* =========================================================================
- * ======= CHANGE TO NEXT MBYTE IN LOG =======
- *
- * ========================================================================= */
- void Dblqh::changeMbyte(Signal* signal)
- {
- writeNextLog(signal);
- writeFileDescriptor(signal);
- }//Dblqh::changeMbyte()
- /* ========================================================================= */
- /* ====== CHECK IF THIS COMMIT LOG RECORD IS TO BE EXECUTED ======= */
- /* */
- /* SUBROUTINE SHORT NAME = CEL */
- /* ========================================================================= */
- Uint32 Dblqh::checkIfExecLog(Signal* signal)
- {
- tabptr.i = tcConnectptr.p->tableref;
- ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
- if (getFragmentrec(signal, tcConnectptr.p->fragmentid) &&
- (table_version_major(tabptr.p->schemaVersion) == table_version_major(tcConnectptr.p->schemaVersion))) {
- if (fragptr.p->execSrStatus != Fragrecord::IDLE) {
- if (fragptr.p->execSrNoReplicas > logPartPtr.p->execSrExecuteIndex) {
- ndbrequire((fragptr.p->execSrNoReplicas - 1) < 4);
- for (Uint32 i = logPartPtr.p->execSrExecuteIndex;
- i < fragptr.p->execSrNoReplicas;
- i++) {
- jam();
- if (tcConnectptr.p->gci >= fragptr.p->execSrStartGci[i]) {
- if (tcConnectptr.p->gci <= fragptr.p->execSrLastGci[i]) {
- jam();
- logPartPtr.p->execSrExecuteIndex = i;
- return ZOK;
- }//if
- }//if
- }//for
- }//if
- }//if
- }//if
- return ZNOT_OK;
- }//Dblqh::checkIfExecLog()
- /* ========================================================================= */
- /* == CHECK IF THERE IS LESS THAN 192 KBYTE IN THE BUFFER PLUS INCOMING === */
- /* READS ALREADY STARTED. IF SO IS THE CASE THEN START ANOTHER READ IF */
- /* THERE ARE MORE PAGES IN THIS MBYTE. */
- /* */
- /* ========================================================================= */
- void Dblqh::checkReadExecSr(Signal* signal)
- {
- logPartPtr.p->logExecState = LogPartRecord::LES_EXEC_LOG;
- logPartPtr.p->execSrPagesRead = logPartPtr.p->execSrPagesRead + 8;
- logPartPtr.p->execSrPagesReading = logPartPtr.p->execSrPagesReading - 8;
- if ((logPartPtr.p->execSrPagesRead + logPartPtr.p->execSrPagesReading) <
- ZREAD_AHEAD_SIZE) {
- jam();
- /* ----------------------------------------------------------------------
- * WE HAVE LESS THAN 64 KBYTE OF LOG PAGES REMAINING IN MEMORY OR ON
- * ITS WAY TO MAIN MEMORY. READ IN 8 MORE PAGES.
- * --------------------------------------------------------------------- */
- if ((logPartPtr.p->execSrPagesRead + logPartPtr.p->execSrPagesExecuted) <
- ZPAGES_IN_MBYTE) {
- jam();
- /* --------------------------------------------------------------------
- * THERE ARE MORE PAGES TO READ IN THIS MBYTE. READ THOSE FIRST
- * IF >= ZPAGES_IN_MBYTE THEN THERE ARE NO MORE PAGES TO READ. THUS
- * WE PROCEED WITH EXECUTION OF THE LOG.
- * ------------------------------------------------------------------- */
- readExecSr(signal);
- logPartPtr.p->logExecState = LogPartRecord::LES_WAIT_READ_EXEC_SR;
- }//if
- }//if
- }//Dblqh::checkReadExecSr()
- /* ========================================================================= */
- /* ==== CHECK IF START OF NEW FRAGMENT IS COMPLETED AND WE CAN ======= */
- /* ==== GET THE START GCI ======= */
- /* */
- /* SUBROUTINE SHORT NAME = CTC */
- /* ========================================================================= */
- void Dblqh::checkScanTcCompleted(Signal* signal)
- {
- tcConnectptr.p->logWriteState = TcConnectionrec::NOT_STARTED;
- fragptr.i = tcConnectptr.p->fragmentptr;
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- fragptr.p->activeTcCounter = fragptr.p->activeTcCounter - 1;
- if (fragptr.p->activeTcCounter == 0) {
- jam();
- fragptr.p->startGci = cnewestGci + 1;
- tabptr.i = tcConnectptr.p->tableref;
- ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
- sendCopyActiveConf(signal, tcConnectptr.p->tableref);
- }//if
- }//Dblqh::checkScanTcCompleted()
- /* ==========================================================================
- * === CHECK IF ALL PARTS OF A SYSTEM RESTART ON A FRAGMENT ARE COMPLETED ===
- *
- * SUBROUTINE SHORT NAME = CSC
- * ========================================================================= */
- void Dblqh::checkSrCompleted(Signal* signal)
- {
- LcpLocRecordPtr cscLcpLocptr;
-
- terrorCode = ZOK;
- ptrGuard(lcpPtr);
- cscLcpLocptr.i = lcpPtr.p->firstLcpLocAcc;
- CSC_ACC_DOWHILE:
- ptrCheckGuard(cscLcpLocptr, clcpLocrecFileSize, lcpLocRecord);
- if (cscLcpLocptr.p->lcpLocstate != LcpLocRecord::SR_ACC_COMPLETED) {
- jam();
- if (cscLcpLocptr.p->lcpLocstate != LcpLocRecord::SR_ACC_STARTED) {
- jam();
- systemErrorLab(signal);
- return;
- }//if
- return;
- }//if
- cscLcpLocptr.i = cscLcpLocptr.p->nextLcpLoc;
- if (cscLcpLocptr.i != RNIL) {
- jam();
- goto CSC_ACC_DOWHILE;
- }//if
- cscLcpLocptr.i = lcpPtr.p->firstLcpLocTup;
- CSC_TUP_DOWHILE:
- ptrCheckGuard(cscLcpLocptr, clcpLocrecFileSize, lcpLocRecord);
- if (cscLcpLocptr.p->lcpLocstate != LcpLocRecord::SR_TUP_COMPLETED) {
- jam();
- if (cscLcpLocptr.p->lcpLocstate != LcpLocRecord::SR_TUP_STARTED) {
- jam();
- systemErrorLab(signal);
- return;
- }//if
- return;
- }//if
- cscLcpLocptr.i = cscLcpLocptr.p->nextLcpLoc;
- if (cscLcpLocptr.i != RNIL) {
- jam();
- goto CSC_TUP_DOWHILE;
- }//if
- lcpPtr.p->lcpState = LcpRecord::LCP_SR_COMPLETED;
- }//Dblqh::checkSrCompleted()
- /* ------------------------------------------------------------------------- */
- /* ------ CLOSE A FILE DURING EXECUTION OF FRAGMENT LOG ------- */
- /* */
- /* ------------------------------------------------------------------------- */
- void Dblqh::closeFile(Signal* signal, LogFileRecordPtr clfLogFilePtr)
- {
- signal->theData[0] = clfLogFilePtr.p->fileRef;
- signal->theData[1] = cownref;
- signal->theData[2] = clfLogFilePtr.i;
- signal->theData[3] = ZCLOSE_NO_DELETE;
- sendSignal(NDBFS_REF, GSN_FSCLOSEREQ, signal, 4, JBA);
- }//Dblqh::closeFile()
- /* ---------------------------------------------------------------- */
- /* ---------------- A LOG PAGE HAVE BEEN COMPLETED ---------------- */
- /* */
- /* SUBROUTINE SHORT NAME = CLP */
- // Input Pointers:
- // logFilePtr
- // logPagePtr
- // logPartPtr
- // Defines lfoPtr
- /* ---------------------------------------------------------------- */
- void Dblqh::completedLogPage(Signal* signal, Uint32 clpType, Uint32 place)
- {
- LogPageRecordPtr clpLogPagePtr;
- LogPageRecordPtr wlpLogPagePtr;
- UintR twlpNoPages;
- UintR twlpType;
- if (logFilePtr.p->firstFilledPage == RNIL) {
- jam();
- logFilePtr.p->firstFilledPage = logPagePtr.i;
- } else {
- jam();
- clpLogPagePtr.i = logFilePtr.p->lastFilledPage;
- ptrCheckGuard(clpLogPagePtr, clogPageFileSize, logPageRecord);
- clpLogPagePtr.p->logPageWord[ZNEXT_PAGE] = logPagePtr.i;
- }//if
- logFilePtr.p->lastFilledPage = logPagePtr.i;
- logPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
- logFilePtr.p->noLogpagesInBuffer = logFilePtr.p->noLogpagesInBuffer + 1;
- if (logFilePtr.p->noLogpagesInBuffer != ZMAX_PAGES_WRITTEN) {
- if (clpType != ZLAST_WRITE_IN_FILE) {
- if (clpType != ZENFORCE_WRITE) {
- jam();
- return;
- }//if
- }//if
- }//if
- twlpType = clpType;
- /* ------------------------------------------------------------------------- */
- /* ------ WRITE A SET OF LOG PAGES TO DISK ------- */
- /* */
- /* SUBROUTINE SHORT NAME: WLP */
- /* ------------------------------------------------------------------------- */
- seizeLfo(signal);
- initLfo(signal);
- Uint32* dataPtr = &signal->theData[6];
- twlpNoPages = 0;
- wlpLogPagePtr.i = logFilePtr.p->firstFilledPage;
- do {
- dataPtr[twlpNoPages] = wlpLogPagePtr.i;
- twlpNoPages++;
- ptrCheckGuard(wlpLogPagePtr, clogPageFileSize, logPageRecord);
- writeDbgInfoPageHeader(wlpLogPagePtr, place,
- logFilePtr.p->filePosition + twlpNoPages - 1,
- ZPAGE_SIZE);
- // Calculate checksum for page
- wlpLogPagePtr.p->logPageWord[ZPOS_CHECKSUM] = calcPageCheckSum(wlpLogPagePtr);
- wlpLogPagePtr.i = wlpLogPagePtr.p->logPageWord[ZNEXT_PAGE];
- } while (wlpLogPagePtr.i != RNIL);
- ndbrequire(twlpNoPages < 9);
- dataPtr[twlpNoPages] = logFilePtr.p->filePosition;
- /* -------------------------------------------------- */
- /* SET TIMER ON THIS LOG PART TO SIGNIFY THAT A */
- /* LOG RECORD HAS BEEN SENT AT THIS TIME. */
- /* -------------------------------------------------- */
- logPartPtr.p->logPartTimer = logPartPtr.p->logTimer;
- signal->theData[0] = logFilePtr.p->fileRef;
- signal->theData[1] = cownref;
- signal->theData[2] = lfoPtr.i;
- logFilePtr.p->logFilePagesToDiskWithoutSynch += twlpNoPages;
- if (twlpType == ZLAST_WRITE_IN_FILE) {
- jam();
- logFilePtr.p->logFilePagesToDiskWithoutSynch = 0;
- signal->theData[3] = ZLIST_OF_MEM_PAGES_SYNCH;
- } else if (logFilePtr.p->logFilePagesToDiskWithoutSynch >
- MAX_REDO_PAGES_WITHOUT_SYNCH) {
- jam();
- logFilePtr.p->logFilePagesToDiskWithoutSynch = 0;
- signal->theData[3] = ZLIST_OF_MEM_PAGES_SYNCH;
- } else {
- jam();
- signal->theData[3] = ZLIST_OF_MEM_PAGES;
- }//if
- signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
- signal->theData[5] = twlpNoPages;
- sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 15, JBA);
- if (twlpType == ZNORMAL) {
- jam();
- lfoPtr.p->lfoState = LogFileOperationRecord::ACTIVE_WRITE_LOG;
- } else if (twlpType == ZLAST_WRITE_IN_FILE) {
- jam();
- lfoPtr.p->lfoState = LogFileOperationRecord::LAST_WRITE_IN_FILE;
- } else {
- ndbrequire(twlpType == ZENFORCE_WRITE);
- jam();
- lfoPtr.p->lfoState = LogFileOperationRecord::ACTIVE_WRITE_LOG;
- }//if
- /* ----------------------------------------------------------------------- */
- /* ------ MOVE PAGES FROM LOG FILE TO LFO RECORD ------- */
- /* */
- /* ----------------------------------------------------------------------- */
- /* -------------------------------------------------- */
- /* MOVE PAGES TO LFO RECORD AND REMOVE THEM */
- /* FROM LOG FILE RECORD. */
- /* -------------------------------------------------- */
- lfoPtr.p->firstLfoPage = logFilePtr.p->firstFilledPage;
- logFilePtr.p->firstFilledPage = RNIL;
- logFilePtr.p->lastFilledPage = RNIL;
- logFilePtr.p->noLogpagesInBuffer = 0;
- lfoPtr.p->noPagesRw = twlpNoPages;
- lfoPtr.p->lfoPageNo = logFilePtr.p->filePosition;
- lfoPtr.p->lfoWordWritten = ZPAGE_SIZE - 1;
- logFilePtr.p->filePosition += twlpNoPages;
- }//Dblqh::completedLogPage()
- /* ---------------------------------------------------------------- */
- /* ---------------- DELETE FRAGMENT RECORD ------------------------ */
- /* */
- /* SUBROUTINE SHORT NAME = DFR */
- /* ---------------------------------------------------------------- */
- void Dblqh::deleteFragrec(Uint32 fragId)
- {
- Uint32 indexFound= RNIL;
- fragptr.i = RNIL;
- for (Uint32 i = (MAX_FRAG_PER_NODE - 1); (Uint32)~i; i--) {
- jam();
- if (tabptr.p->fragid[i] == fragId) {
- fragptr.i = tabptr.p->fragrec[i];
- indexFound = i;
- break;
- }//if
- }//for
- if (fragptr.i != RNIL) {
- jam();
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- tabptr.p->fragid[indexFound] = ZNIL;
- tabptr.p->fragrec[indexFound] = RNIL;
- releaseFragrec();
- }//if
- }//Dblqh::deleteFragrec()
- /* ------------------------------------------------------------------------- */
- /* ------- FIND LOG FILE RECORD GIVEN FILE NUMBER ------- */
- /* */
- /* INPUT: TFLF_FILE_NO THE FILE NUMBER */
- /* FLF_LOG_PART_PTR THE LOG PART RECORD */
- /* OUTPUT: FLF_LOG_FILE_PTR THE FOUND LOG FILE RECORD */
- /* SUBROUTINE SHORT NAME = FLF */
- /* ------------------------------------------------------------------------- */
- void Dblqh::findLogfile(Signal* signal,
- Uint32 fileNo,
- LogPartRecordPtr flfLogPartPtr,
- LogFileRecordPtr* parLogFilePtr)
- {
- LogFileRecordPtr locLogFilePtr;
- locLogFilePtr.i = flfLogPartPtr.p->firstLogfile;
- Uint32 loopCount = 0;
- while (true) {
- ptrCheckGuard(locLogFilePtr, clogFileFileSize, logFileRecord);
- if (locLogFilePtr.p->fileNo == fileNo) {
- jam();
- ndbrequire(loopCount == fileNo);
- parLogFilePtr->i = locLogFilePtr.i;
- parLogFilePtr->p = locLogFilePtr.p;
- return;
- }//if
- locLogFilePtr.i = locLogFilePtr.p->nextLogFile;
- loopCount++;
- ndbrequire(loopCount < flfLogPartPtr.p->noLogFiles);
- }//while
- }//Dblqh::findLogfile()
- /* ------------------------------------------------------------------------- */
- /* ------ FIND PAGE REFERENCE IN MEMORY BUFFER AT LOG EXECUTION ------- */
- /* */
- /* ------------------------------------------------------------------------- */
- void Dblqh::findPageRef(Signal* signal, CommitLogRecord* commitLogRecord)
- {
- UintR tfprIndex;
- logPagePtr.i = RNIL;
- if (ERROR_INSERTED(5020)) {
- // Force system to read page from disk
- return;
- }
- pageRefPtr.i = logPartPtr.p->lastPageRef;
- do {
- ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
- if (commitLogRecord->fileNo == pageRefPtr.p->prFileNo) {
- if (commitLogRecord->startPageNo >= pageRefPtr.p->prPageNo) {
- if (commitLogRecord->startPageNo < (Uint16) (pageRefPtr.p->prPageNo + 8)) {
- jam();
- tfprIndex = commitLogRecord->startPageNo - pageRefPtr.p->prPageNo;
- logPagePtr.i = pageRefPtr.p->pageRef[tfprIndex];
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- return;
- }//if
- }//if
- }//if
- pageRefPtr.i = pageRefPtr.p->prPrev;
- } while (pageRefPtr.i != RNIL);
- }//Dblqh::findPageRef()
- /* ------------------------------------------------------------------------- */
- /* ------ GET FIRST OPERATION QUEUED FOR LOGGING ------- */
- /* */
- /* SUBROUTINE SHORT NAME = GFL */
- /* ------------------------------------------------------------------------- */
- void Dblqh::getFirstInLogQueue(Signal* signal)
- {
- TcConnectionrecPtr gflTcConnectptr;
- /* -------------------------------------------------- */
- /* GET THE FIRST FROM THE LOG QUEUE AND REMOVE */
- /* IT FROM THE QUEUE. */
- /* -------------------------------------------------- */
- gflTcConnectptr.i = logPartPtr.p->firstLogQueue;
- ptrCheckGuard(gflTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- logPartPtr.p->firstLogQueue = gflTcConnectptr.p->nextTcLogQueue;
- if (logPartPtr.p->firstLogQueue == RNIL) {
- jam();
- logPartPtr.p->lastLogQueue = RNIL;
- }//if
- }//Dblqh::getFirstInLogQueue()
- /* ---------------------------------------------------------------- */
- /* ---------------- GET FRAGMENT RECORD --------------------------- */
- /* INPUT: TFRAGID FRAGMENT ID LOOKING FOR */
- /* TABPTR TABLE ID */
- /* SUBROUTINE SHORT NAME = GFR */
- /* ---------------------------------------------------------------- */
- bool Dblqh::getFragmentrec(Signal* signal, Uint32 fragId)
- {
- for (Uint32 i = (MAX_FRAG_PER_NODE - 1); (UintR)~i; i--) {
- jam();
- if (tabptr.p->fragid[i] == fragId) {
- fragptr.i = tabptr.p->fragrec[i];
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- return true;
- }//if
- }//for
- return false;
- }//Dblqh::getFragmentrec()
- /* ========================================================================= */
- /* ====== INITIATE FRAGMENT RECORD ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseAddfragrec(Signal* signal)
- {
- if (caddfragrecFileSize != 0) {
- for (addfragptr.i = 0; addfragptr.i < caddfragrecFileSize; addfragptr.i++) {
- ptrAss(addfragptr, addFragRecord);
- addfragptr.p->addfragStatus = AddFragRecord::FREE;
- addfragptr.p->nextAddfragrec = addfragptr.i + 1;
- }//for
- addfragptr.i = caddfragrecFileSize - 1;
- ptrAss(addfragptr, addFragRecord);
- addfragptr.p->nextAddfragrec = RNIL;
- cfirstfreeAddfragrec = 0;
- } else {
- jam();
- cfirstfreeAddfragrec = RNIL;
- }//if
- }//Dblqh::initialiseAddfragrec()
- /* ========================================================================= */
- /* ====== INITIATE ATTRIBUTE IN AND OUT DATA BUFFER ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseAttrbuf(Signal* signal)
- {
- if (cattrinbufFileSize != 0) {
- for (attrinbufptr.i = 0;
- attrinbufptr.i < cattrinbufFileSize;
- attrinbufptr.i++) {
- refresh_watch_dog();
- ptrAss(attrinbufptr, attrbuf);
- attrinbufptr.p->attrbuf[ZINBUF_NEXT] = attrinbufptr.i + 1;
- }//for
- /* NEXT ATTRINBUF */
- attrinbufptr.i = cattrinbufFileSize - 1;
- ptrAss(attrinbufptr, attrbuf);
- attrinbufptr.p->attrbuf[ZINBUF_NEXT] = RNIL; /* NEXT ATTRINBUF */
- cfirstfreeAttrinbuf = 0;
- } else {
- jam();
- cfirstfreeAttrinbuf = RNIL;
- }//if
- }//Dblqh::initialiseAttrbuf()
- /* ========================================================================= */
- /* ====== INITIATE DATA BUFFER ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseDatabuf(Signal* signal)
- {
- if (cdatabufFileSize != 0) {
- for (databufptr.i = 0; databufptr.i < cdatabufFileSize; databufptr.i++) {
- refresh_watch_dog();
- ptrAss(databufptr, databuf);
- databufptr.p->nextDatabuf = databufptr.i + 1;
- }//for
- databufptr.i = cdatabufFileSize - 1;
- ptrAss(databufptr, databuf);
- databufptr.p->nextDatabuf = RNIL;
- cfirstfreeDatabuf = 0;
- } else {
- jam();
- cfirstfreeDatabuf = RNIL;
- }//if
- }//Dblqh::initialiseDatabuf()
- /* ========================================================================= */
- /* ====== INITIATE FRAGMENT RECORD ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseFragrec(Signal* signal)
- {
- if (cfragrecFileSize != 0) {
- for (fragptr.i = 0; fragptr.i < cfragrecFileSize; fragptr.i++) {
- refresh_watch_dog();
- ptrAss(fragptr, fragrecord);
- fragptr.p->fragStatus = Fragrecord::FREE;
- fragptr.p->fragActiveStatus = ZFALSE;
- fragptr.p->execSrStatus = Fragrecord::IDLE;
- fragptr.p->srStatus = Fragrecord::SS_IDLE;
- fragptr.p->nextFrag = fragptr.i + 1;
- }//for
- fragptr.i = cfragrecFileSize - 1;
- ptrAss(fragptr, fragrecord);
- fragptr.p->nextFrag = RNIL;
- cfirstfreeFragrec = 0;
- } else {
- jam();
- cfirstfreeFragrec = RNIL;
- }//if
- }//Dblqh::initialiseFragrec()
- /* ========================================================================= */
- /* ====== INITIATE FRAGMENT RECORD ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseGcprec(Signal* signal)
- {
- UintR tigpIndex;
- if (cgcprecFileSize != 0) {
- for (gcpPtr.i = 0; gcpPtr.i < cgcprecFileSize; gcpPtr.i++) {
- ptrAss(gcpPtr, gcpRecord);
- for (tigpIndex = 0; tigpIndex <= 3; tigpIndex++) {
- gcpPtr.p->gcpLogPartState[tigpIndex] = ZIDLE;
- gcpPtr.p->gcpSyncReady[tigpIndex] = ZFALSE;
- }//for
- }//for
- }//if
- }//Dblqh::initialiseGcprec()
- /* ========================================================================= */
- /* ====== INITIATE LCP RECORD ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseLcpRec(Signal* signal)
- {
- if (clcpFileSize != 0) {
- for (lcpPtr.i = 0; lcpPtr.i < clcpFileSize; lcpPtr.i++) {
- ptrAss(lcpPtr, lcpRecord);
- lcpPtr.p->lcpState = LcpRecord::LCP_IDLE;
- lcpPtr.p->lcpQueued = false;
- lcpPtr.p->firstLcpLocAcc = RNIL;
- lcpPtr.p->firstLcpLocTup = RNIL;
- lcpPtr.p->reportEmpty = false;
- lcpPtr.p->lastFragmentFlag = false;
- }//for
- }//if
- }//Dblqh::initialiseLcpRec()
- /* ========================================================================= */
- /* ====== INITIATE LCP LOCAL RECORD ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseLcpLocrec(Signal* signal)
- {
- if (clcpLocrecFileSize != 0) {
- for (lcpLocptr.i = 0; lcpLocptr.i < clcpLocrecFileSize; lcpLocptr.i++) {
- ptrAss(lcpLocptr, lcpLocRecord);
- lcpLocptr.p->nextLcpLoc = lcpLocptr.i + 1;
- lcpLocptr.p->lcpLocstate = LcpLocRecord::IDLE;
- lcpLocptr.p->masterLcpRec = RNIL;
- lcpLocptr.p->waitingBlock = LcpLocRecord::NONE;
- }//for
- lcpLocptr.i = clcpLocrecFileSize - 1;
- ptrAss(lcpLocptr, lcpLocRecord);
- lcpLocptr.p->nextLcpLoc = RNIL;
- cfirstfreeLcpLoc = 0;
- } else {
- jam();
- cfirstfreeLcpLoc = RNIL;
- }//if
- }//Dblqh::initialiseLcpLocrec()
- /* ========================================================================= */
- /* ====== INITIATE LOG FILE OPERATION RECORD ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseLfo(Signal* signal)
- {
- if (clfoFileSize != 0) {
- for (lfoPtr.i = 0; lfoPtr.i < clfoFileSize; lfoPtr.i++) {
- ptrAss(lfoPtr, logFileOperationRecord);
- lfoPtr.p->lfoState = LogFileOperationRecord::IDLE;
- lfoPtr.p->lfoTimer = 0;
- lfoPtr.p->nextLfo = lfoPtr.i + 1;
- }//for
- lfoPtr.i = clfoFileSize - 1;
- ptrAss(lfoPtr, logFileOperationRecord);
- lfoPtr.p->nextLfo = RNIL;
- cfirstfreeLfo = 0;
- } else {
- jam();
- cfirstfreeLfo = RNIL;
- }//if
- }//Dblqh::initialiseLfo()
- /* ========================================================================= */
- /* ====== INITIATE LOG FILE RECORD ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseLogFile(Signal* signal)
- {
- if (clogFileFileSize != 0) {
- for (logFilePtr.i = 0; logFilePtr.i < clogFileFileSize; logFilePtr.i++) {
- ptrAss(logFilePtr, logFileRecord);
- logFilePtr.p->nextLogFile = logFilePtr.i + 1;
- logFilePtr.p->logFileStatus = LogFileRecord::LFS_IDLE;
- }//for
- logFilePtr.i = clogFileFileSize - 1;
- ptrAss(logFilePtr, logFileRecord);
- logFilePtr.p->nextLogFile = RNIL;
- cfirstfreeLogFile = 0;
- } else {
- jam();
- cfirstfreeLogFile = RNIL;
- }//if
- }//Dblqh::initialiseLogFile()
- /* ========================================================================= */
- /* ====== INITIATE LOG PAGES ======= */
- /* */
- /* ========================================================================= */
- void Dblqh::initialiseLogPage(Signal* signal)
- {
- if (clogPageFileSize != 0) {
- for (logPagePtr.i = 0; logPagePtr.i < clogPageFileSize; logPagePtr.i++) {
- refresh_watch_dog();
- ptrAss(logPagePtr, logPageRecord);
- logPagePtr.p->logPageWord[ZNEXT_PAGE] = logPagePtr.i + 1;
- logPagePtr.p->logPageWord[ZPOS_IN_FREE_LIST]= 1;
- logPagePtr.p->logPageWord[ZPOS_IN_WRITING]= 0;
- }//for
- logPagePtr.i = clogPageFileSize - 1;
- ptrAss(logPagePtr, logPageRecord);
- logPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
- cfirstfreeLogPage = 0;
- } else {
- jam();
- cfirstfreeLogPage = RNIL;
- }//if
- cnoOfLogPages = clogPageFileSize;
- }//Dblqh::initialiseLogPage()
- /* =========================================================================
- * ====== INITIATE LOG PART RECORD =======
- *
- * ========================================================================= */
- void Dblqh::initialiseLogPart(Signal* signal)
- {
- for (logPartPtr.i = 0; logPartPtr.i <= 3; logPartPtr.i++) {
- ptrAss(logPartPtr, logPartRecord);
- logPartPtr.p->waitWriteGciLog = LogPartRecord::WWGL_FALSE;
- logPartPtr.p->LogLqhKeyReqSent = ZFALSE;
- logPartPtr.p->logPartNewestCompletedGCI = (UintR)-1;
- }//for
- }//Dblqh::initialiseLogPart()
- void Dblqh::initialisePageRef(Signal* signal)
- {
- if (cpageRefFileSize != 0) {
- for (pageRefPtr.i = 0;
- pageRefPtr.i < cpageRefFileSize;
- pageRefPtr.i++) {
- ptrAss(pageRefPtr, pageRefRecord);
- pageRefPtr.p->prNext = pageRefPtr.i + 1;
- }//for
- pageRefPtr.i = cpageRefFileSize - 1;
- ptrAss(pageRefPtr, pageRefRecord);
- pageRefPtr.p->prNext = RNIL;
- cfirstfreePageRef = 0;
- } else {
- jam();
- cfirstfreePageRef = RNIL;
- }//if
- }//Dblqh::initialisePageRef()
- /* ==========================================================================
- * ======= INITIATE RECORDS =======
- *
- * TAKES CARE OF INITIATION OF ALL RECORDS IN THIS BLOCK.
- * ========================================================================= */
- void Dblqh::initialiseRecordsLab(Signal* signal, Uint32 data,
- Uint32 retRef, Uint32 retData)
- {
- Uint32 i;
- switch (data) {
- case 0:
- jam();
- for (i = 0; i < MAX_NDB_NODES; i++) {
- cnodeSrState[i] = ZSTART_SR;
- cnodeExecSrState[i] = ZSTART_SR;
- }//for
- for (i = 0; i < 1024; i++) {
- ctransidHash[i] = RNIL;
- }//for
- for (i = 0; i < 4; i++) {
- cactiveCopy[i] = RNIL;
- }//for
- cnoActiveCopy = 0;
- cCounterAccCommitBlocked = 0;
- cCounterTupCommitBlocked = 0;
- caccCommitBlocked = false;
- ctupCommitBlocked = false;
- cCommitBlocked = false;
- ccurrentGcprec = RNIL;
- caddNodeState = ZFALSE;
- cstartRecReq = ZFALSE;
- cnewestGci = (UintR)-1;
- cnewestCompletedGci = (UintR)-1;
- crestartOldestGci = 0;
- crestartNewestGci = 0;
- cfirstWaitFragSr = RNIL;
- cfirstCompletedFragSr = RNIL;
- csrPhaseStarted = ZSR_NO_PHASE_STARTED;
- csrPhasesCompleted = 0;
- cmasterDihBlockref = 0;
- cnoFragmentsExecSr = 0;
- clcpCompletedState = LCP_IDLE;
- csrExecUndoLogState = EULS_IDLE;
- c_lcpId = 0;
- cnoOfFragsCheckpointed = 0;
- break;
- case 1:
- jam();
- initialiseAddfragrec(signal);
- break;
- case 2:
- jam();
- initialiseAttrbuf(signal);
- break;
- case 3:
- jam();
- initialiseDatabuf(signal);
- break;
- case 4:
- jam();
- initialiseFragrec(signal);
- break;
- case 5:
- jam();
- initialiseGcprec(signal);
- initialiseLcpRec(signal);
- initialiseLcpLocrec(signal);
- break;
- case 6:
- jam();
- initialiseLogPage(signal);
- break;
- case 7:
- jam();
- initialiseLfo(signal);
- break;
- case 8:
- jam();
- initialiseLogFile(signal);
- initialiseLogPart(signal);
- break;
- case 9:
- jam();
- initialisePageRef(signal);
- break;
- case 10:
- jam();
- initialiseScanrec(signal);
- break;
- case 11:
- jam();
- initialiseTabrec(signal);
- break;
- case 12:
- jam();
- initialiseTcNodeFailRec(signal);
- initialiseTcrec(signal);
- {
- ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend();
- conf->senderRef = reference();
- conf->senderData = retData;
- sendSignal(retRef, GSN_READ_CONFIG_CONF, signal,
- ReadConfigConf::SignalLength, JBB);
- }
- return;
- break;
- default:
- ndbrequire(false);
- break;
- }//switch
- signal->theData[0] = ZINITIALISE_RECORDS;
- signal->theData[1] = data + 1;
- signal->theData[2] = 0;
- signal->theData[3] = retRef;
- signal->theData[4] = retData;
- sendSignal(DBLQH_REF, GSN_CONTINUEB, signal, 5, JBB);
- return;
- }//Dblqh::initialiseRecordsLab()
- /* ==========================================================================
- * ======= INITIATE TC CONNECTION RECORD =======
- *
- * ========================================================================= */
- void Dblqh::initialiseScanrec(Signal* signal)
- {
- ndbrequire(cscanrecFileSize > 1);
- DLList<ScanRecord> tmp(c_scanRecordPool);
- while (tmp.seize(scanptr)){
- //new (scanptr.p) ScanRecord();
- refresh_watch_dog();
- scanptr.p->scanType = ScanRecord::ST_IDLE;
- scanptr.p->scanState = ScanRecord::SCAN_FREE;
- scanptr.p->scanTcWaiting = ZFALSE;
- scanptr.p->nextHash = RNIL;
- scanptr.p->prevHash = RNIL;
- scanptr.p->scan_acc_index= 0;
- scanptr.p->scan_acc_attr_recs= 0;
- }
- tmp.release();
- }//Dblqh::initialiseScanrec()
- /* ==========================================================================
- * ======= INITIATE TABLE RECORD =======
- *
- * ========================================================================= */
- void Dblqh::initialiseTabrec(Signal* signal)
- {
- if (ctabrecFileSize != 0) {
- for (tabptr.i = 0; tabptr.i < ctabrecFileSize; tabptr.i++) {
- refresh_watch_dog();
- ptrAss(tabptr, tablerec);
- tabptr.p->tableStatus = Tablerec::NOT_DEFINED;
- tabptr.p->usageCount = 0;
- for (Uint32 i = 0; i <= (MAX_FRAG_PER_NODE - 1); i++) {
- tabptr.p->fragid[i] = ZNIL;
- tabptr.p->fragrec[i] = RNIL;
- }//for
- }//for
- }//if
- }//Dblqh::initialiseTabrec()
- /* ==========================================================================
- * ======= INITIATE TC CONNECTION RECORD =======
- *
- * ========================================================================= */
- void Dblqh::initialiseTcrec(Signal* signal)
- {
- if (ctcConnectrecFileSize != 0) {
- for (tcConnectptr.i = 0;
- tcConnectptr.i < ctcConnectrecFileSize;
- tcConnectptr.i++) {
- refresh_watch_dog();
- ptrAss(tcConnectptr, tcConnectionrec);
- tcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED;
- tcConnectptr.p->tcScanRec = RNIL;
- tcConnectptr.p->logWriteState = TcConnectionrec::NOT_STARTED;
- tcConnectptr.p->firstAttrinbuf = RNIL;
- tcConnectptr.p->lastAttrinbuf = RNIL;
- tcConnectptr.p->firstTupkeybuf = RNIL;
- tcConnectptr.p->lastTupkeybuf = RNIL;
- tcConnectptr.p->tcTimer = 0;
- tcConnectptr.p->nextTcConnectrec = tcConnectptr.i + 1;
- }//for
- tcConnectptr.i = ctcConnectrecFileSize - 1;
- ptrAss(tcConnectptr, tcConnectionrec);
- tcConnectptr.p->nextTcConnectrec = RNIL;
- cfirstfreeTcConrec = 0;
- } else {
- jam();
- cfirstfreeTcConrec = RNIL;
- }//if
- }//Dblqh::initialiseTcrec()
- /* ==========================================================================
- * ======= INITIATE TC CONNECTION RECORD =======
- *
- * ========================================================================= */
- void Dblqh::initialiseTcNodeFailRec(Signal* signal)
- {
- if (ctcNodeFailrecFileSize != 0) {
- for (tcNodeFailptr.i = 0;
- tcNodeFailptr.i < ctcNodeFailrecFileSize;
- tcNodeFailptr.i++) {
- ptrAss(tcNodeFailptr, tcNodeFailRecord);
- tcNodeFailptr.p->tcFailStatus = TcNodeFailRecord::TC_STATE_FALSE;
- }//for
- }//if
- }//Dblqh::initialiseTcNodeFailRec()
- /* ==========================================================================
- * ======= INITIATE FRAGMENT RECORD =======
- *
- * SUBROUTINE SHORT NAME = IF
- * ========================================================================= */
- void Dblqh::initFragrec(Signal* signal,
- Uint32 tableId,
- Uint32 fragId,
- Uint32 copyType)
- {
- new (fragptr.p) Fragrecord();
- fragptr.p->m_scanNumberMask.set(); // All is free
- fragptr.p->accBlockref = caccBlockref;
- fragptr.p->accBlockedList = RNIL;
- fragptr.p->activeList = RNIL;
- fragptr.p->firstWaitQueue = RNIL;
- fragptr.p->lastWaitQueue = RNIL;
- fragptr.p->fragStatus = Fragrecord::DEFINED;
- fragptr.p->fragCopy = copyType;
- fragptr.p->tupBlockref = ctupBlockref;
- fragptr.p->tuxBlockref = ctuxBlockref;
- fragptr.p->lcpRef = RNIL;
- fragptr.p->logFlag = Fragrecord::STATE_TRUE;
- fragptr.p->lcpFlag = Fragrecord::LCP_STATE_TRUE;
- for (Uint32 i = 0; i < MAX_LCP_STORED; i++) {
- fragptr.p->lcpId[i] = 0;
- }//for
- fragptr.p->maxGciCompletedInLcp = 0;
- fragptr.p->maxGciInLcp = 0;
- fragptr.p->copyFragState = ZIDLE;
- fragptr.p->nextFrag = RNIL;
- fragptr.p->newestGci = cnewestGci;
- fragptr.p->nextLcp = 0;
- fragptr.p->tabRef = tableId;
- fragptr.p->fragId = fragId;
- fragptr.p->srStatus = Fragrecord::SS_IDLE;
- fragptr.p->execSrStatus = Fragrecord::IDLE;
- fragptr.p->execSrNoReplicas = 0;
- fragptr.p->fragDistributionKey = 0;
- fragptr.p->activeTcCounter = 0;
- fragptr.p->tableFragptr = RNIL;
- }//Dblqh::initFragrec()
- /* ==========================================================================
- * ======= INITIATE FRAGMENT RECORD FOR SYSTEM RESTART =======
- *
- * SUBROUTINE SHORT NAME = IFS
- * ========================================================================= */
- void Dblqh::initFragrecSr(Signal* signal)
- {
- const StartFragReq * const startFragReq = (StartFragReq *)&signal->theData[0];
- Uint32 lcpNo = startFragReq->lcpNo;
- Uint32 noOfLogNodes = startFragReq->noOfLogNodes;
- ndbrequire(noOfLogNodes <= 4);
- fragptr.p->fragStatus = Fragrecord::CRASH_RECOVERING;
- fragptr.p->srBlockref = startFragReq->userRef;
- fragptr.p->srUserptr = startFragReq->userPtr;
- fragptr.p->srChkpnr = lcpNo;
- if (lcpNo == (MAX_LCP_STORED - 1)) {
- jam();
- fragptr.p->lcpId[lcpNo] = startFragReq->lcpId;
- fragptr.p->nextLcp = 0;
- } else if (lcpNo < (MAX_LCP_STORED - 1)) {
- jam();
- fragptr.p->lcpId[lcpNo] = startFragReq->lcpId;
- fragptr.p->nextLcp = lcpNo + 1;
- } else {
- ndbrequire(lcpNo == ZNIL);
- jam();
- fragptr.p->nextLcp = 0;
- }//if
- fragptr.p->srNoLognodes = noOfLogNodes;
- fragptr.p->logFlag = Fragrecord::STATE_FALSE;
- fragptr.p->srStatus = Fragrecord::SS_IDLE;
- if (noOfLogNodes > 0) {
- jam();
- for (Uint32 i = 0; i < noOfLogNodes; i++) {
- jam();
- fragptr.p->srStartGci[i] = startFragReq->startGci[i];
- fragptr.p->srLastGci[i] = startFragReq->lastGci[i];
- fragptr.p->srLqhLognode[i] = startFragReq->lqhLogNode[i];
- }//for
- fragptr.p->newestGci = startFragReq->lastGci[noOfLogNodes - 1];
- } else {
- fragptr.p->newestGci = cnewestGci;
- }//if
- }//Dblqh::initFragrecSr()
- /* ==========================================================================
- * ======= INITIATE INFORMATION ABOUT GLOBAL CHECKPOINTS =======
- * IN LOG FILE RECORDS
- *
- * INPUT: LOG_FILE_PTR CURRENT LOG FILE
- * TNO_FD_DESCRIPTORS THE NUMBER OF FILE DESCRIPTORS
- * TO READ FROM THE LOG PAGE
- * LOG_PAGE_PTR PAGE ZERO IN LOG FILE
- * SUBROUTINE SHORT NAME = IGL
- * ========================================================================= */
- void Dblqh::initGciInLogFileRec(Signal* signal, Uint32 noFdDescriptors)
- {
- LogFileRecordPtr iglLogFilePtr;
- UintR tiglLoop;
- UintR tiglIndex;
- tiglLoop = 0;
- iglLogFilePtr.i = logFilePtr.i;
- iglLogFilePtr.p = logFilePtr.p;
- IGL_LOOP:
- for (tiglIndex = 0; tiglIndex <= ZNO_MBYTES_IN_FILE - 1; tiglIndex++) {
- arrGuard(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) +
- (tiglLoop * ZFD_PART_SIZE)) + tiglIndex, ZPAGE_SIZE);
- iglLogFilePtr.p->logMaxGciCompleted[tiglIndex] =
- logPagePtr.p->logPageWord[((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) +
- (tiglLoop * ZFD_PART_SIZE)) + tiglIndex];
- arrGuard((((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + ZNO_MBYTES_IN_FILE) +
- (tiglLoop * ZFD_PART_SIZE)) + tiglIndex, ZPAGE_SIZE);
- iglLogFilePtr.p->logMaxGciStarted[tiglIndex] =
- logPagePtr.p->logPageWord[(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) +
- ZNO_MBYTES_IN_FILE) +
- (tiglLoop * ZFD_PART_SIZE)) + tiglIndex];
- arrGuard((((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) +
- (2 * ZNO_MBYTES_IN_FILE)) + (tiglLoop * ZFD_PART_SIZE)) +
- tiglIndex, ZPAGE_SIZE);
- iglLogFilePtr.p->logLastPrepRef[tiglIndex] =
- logPagePtr.p->logPageWord[(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) +
- (2 * ZNO_MBYTES_IN_FILE)) +
- (tiglLoop * ZFD_PART_SIZE)) + tiglIndex];
- }//for
- tiglLoop = tiglLoop + 1;
- if (tiglLoop < noFdDescriptors) {
- jam();
- iglLogFilePtr.i = iglLogFilePtr.p->prevLogFile;
- ptrCheckGuard(iglLogFilePtr, clogFileFileSize, logFileRecord);
- goto IGL_LOOP;
- }//if
- }//Dblqh::initGciInLogFileRec()
- /* ==========================================================================
- * ======= INITIATE LCP RECORD WHEN USED FOR SYSTEM RESTART =======
- *
- * SUBROUTINE SHORT NAME = ILS
- * ========================================================================= */
- void Dblqh::initLcpSr(Signal* signal,
- Uint32 lcpNo,
- Uint32 lcpId,
- Uint32 tableId,
- Uint32 fragId,
- Uint32 fragPtr)
- {
- lcpPtr.p->lcpQueued = false;
- lcpPtr.p->currentFragment.fragPtrI = fragPtr;
- lcpPtr.p->currentFragment.lcpFragOrd.lcpNo = lcpNo;
- lcpPtr.p->currentFragment.lcpFragOrd.lcpId = lcpId;
- lcpPtr.p->currentFragment.lcpFragOrd.tableId = tableId;
- lcpPtr.p->currentFragment.lcpFragOrd.fragmentId = fragId;
- lcpPtr.p->lcpState = LcpRecord::LCP_SR_WAIT_FRAGID;
- lcpPtr.p->firstLcpLocAcc = RNIL;
- lcpPtr.p->firstLcpLocTup = RNIL;
- lcpPtr.p->lcpAccptr = RNIL;
- }//Dblqh::initLcpSr()
- /* ==========================================================================
- * ======= INITIATE LOG PART =======
- *
- * ========================================================================= */
- void Dblqh::initLogpart(Signal* signal)
- {
- logPartPtr.p->execSrLogPage = RNIL;
- logPartPtr.p->execSrLogPageIndex = ZNIL;
- logPartPtr.p->execSrExecuteIndex = 0;
- logPartPtr.p->noLogFiles = cnoLogFiles;
- logPartPtr.p->logLap = 0;
- logPartPtr.p->logTailFileNo = 0;
- logPartPtr.p->logTailMbyte = 0;
- logPartPtr.p->lastMbyte = ZNIL;
- logPartPtr.p->logPartState = LogPartRecord::SR_FIRST_PHASE;
- logPartPtr.p->logExecState = LogPartRecord::LES_IDLE;
- logPartPtr.p->firstLogTcrec = RNIL;
- logPartPtr.p->lastLogTcrec = RNIL;
- logPartPtr.p->firstLogQueue = RNIL;
- logPartPtr.p->lastLogQueue = RNIL;
- logPartPtr.p->gcprec = RNIL;
- logPartPtr.p->firstPageRef = RNIL;
- logPartPtr.p->lastPageRef = RNIL;
- logPartPtr.p->headFileNo = ZNIL;
- logPartPtr.p->headPageNo = ZNIL;
- logPartPtr.p->headPageIndex = ZNIL;
- }//Dblqh::initLogpart()
- /* ==========================================================================
- * ======= INITIATE LOG POINTERS =======
- *
- * ========================================================================= */
- void Dblqh::initLogPointers(Signal* signal)
- {
- logPartPtr.i = tcConnectptr.p->hashValue & 3;
- ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
- logFilePtr.i = logPartPtr.p->currentLogfile;
- ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
- logPagePtr.i = logFilePtr.p->currentLogpage;
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- }//Dblqh::initLogPointers()
- /* ------------------------------------------------------------------------- */
- /* ------- INIT REQUEST INFO BEFORE EXECUTING A LOG RECORD ------- */
- /* */
- /* ------------------------------------------------------------------------- */
- void Dblqh::initReqinfoExecSr(Signal* signal)
- {
- UintR Treqinfo = 0;
- TcConnectionrec * const regTcPtr = tcConnectptr.p;
- LqhKeyReq::setKeyLen(Treqinfo, regTcPtr->primKeyLen);
- /* ------------------------------------------------------------------------- */
- /* NUMBER OF BACKUPS AND STANDBYS ARE ZERO AND NEED NOT BE SET. */
- /* REPLICA TYPE IS CLEARED BY SEND_LQHKEYREQ. */
- /* ------------------------------------------------------------------------- */
- /* ------------------------------------------------------------------------- */
- /* SET LAST REPLICA NUMBER TO ZERO (BIT 10-11) */
- /* ------------------------------------------------------------------------- */
- /* ------------------------------------------------------------------------- */
- /* SET DIRTY FLAG */
- /* ------------------------------------------------------------------------- */
- LqhKeyReq::setDirtyFlag(Treqinfo, 1);
- /* ------------------------------------------------------------------------- */
- /* SET SIMPLE TRANSACTION */
- /* ------------------------------------------------------------------------- */
- LqhKeyReq::setSimpleFlag(Treqinfo, 1);
- /* ------------------------------------------------------------------------- */
- /* SET OPERATION TYPE AND LOCK MODE (NEVER READ OPERATION OR SCAN IN LOG) */
- /* ------------------------------------------------------------------------- */
- LqhKeyReq::setLockType(Treqinfo, regTcPtr->operation);
- LqhKeyReq::setOperation(Treqinfo, regTcPtr->operation);
- regTcPtr->reqinfo = Treqinfo;
- /* ------------------------------------------------------------------------ */
- /* NO OF BACKUP IS SET TO ONE AND NUMBER OF STANDBY NODES IS SET TO ZERO. */
- /* THUS THE RECEIVING NODE WILL EXPECT THAT IT IS THE LAST NODE AND WILL */
- /* SEND COMPLETED AS THE RESPONSE SIGNAL SINCE DIRTY_OP BIT IS SET. */
- /* ------------------------------------------------------------------------ */
- /* ------------------------------------------------------------------------- */
- /* SET REPLICA TYPE TO PRIMARY AND NUMBER OF REPLICA TO ONE */
- /* ------------------------------------------------------------------------- */
- regTcPtr->lastReplicaNo = 0;
- regTcPtr->apiVersionNo = 0;
- regTcPtr->nextSeqNoReplica = 0;
- regTcPtr->opExec = 0;
- regTcPtr->storedProcId = ZNIL;
- regTcPtr->readlenAi = 0;
- regTcPtr->nodeAfterNext[0] = ZNIL;
- regTcPtr->nodeAfterNext[1] = ZNIL;
- regTcPtr->dirtyOp = ZFALSE;
- regTcPtr->tcBlockref = cownref;
- }//Dblqh::initReqinfoExecSr()
- /* --------------------------------------------------------------------------
- * ------- INSERT FRAGMENT -------
- *
- * ------------------------------------------------------------------------- */
- bool Dblqh::insertFragrec(Signal* signal, Uint32 fragId)
- {
- terrorCode = ZOK;
- if (cfirstfreeFragrec == RNIL) {
- jam();
- terrorCode = ZNO_FREE_FRAGMENTREC;
- return false;
- }//if
- seizeFragmentrec(signal);
- for (Uint32 i = (MAX_FRAG_PER_NODE - 1); (Uint32)~i; i--) {
- jam();
- if (tabptr.p->fragid[i] == ZNIL) {
- jam();
- tabptr.p->fragid[i] = fragId;
- tabptr.p->fragrec[i] = fragptr.i;
- return true;
- }//if
- }//for
- terrorCode = ZTOO_MANY_FRAGMENTS;
- return false;
- }//Dblqh::insertFragrec()
- /* --------------------------------------------------------------------------
- * ------- LINK OPERATION IN ACTIVE LIST ON FRAGMENT -------
- *
- * SUBROUTINE SHORT NAME: LFQ
- // Input Pointers:
- // tcConnectptr
- // fragptr
- * ------------------------------------------------------------------------- */
- void Dblqh::linkFragQueue(Signal* signal)
- {
- TcConnectionrecPtr lfqTcConnectptr;
- TcConnectionrec * const regTcPtr = tcConnectptr.p;
- Fragrecord * const regFragPtr = fragptr.p;
- Uint32 tcIndex = tcConnectptr.i;
- lfqTcConnectptr.i = regFragPtr->lastWaitQueue;
- regTcPtr->nextTc = RNIL;
- regFragPtr->lastWaitQueue = tcIndex;
- regTcPtr->prevTc = lfqTcConnectptr.i;
- ndbrequire(regTcPtr->listState == TcConnectionrec::NOT_IN_LIST);
- regTcPtr->listState = TcConnectionrec::WAIT_QUEUE_LIST;
- if (lfqTcConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(lfqTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- lfqTcConnectptr.p->nextTc = tcIndex;
- } else {
- regFragPtr->firstWaitQueue = tcIndex;
- }//if
- return;
- }//Dblqh::linkFragQueue()
- /* -------------------------------------------------------------------------
- * ------- LINK OPERATION INTO WAITING FOR LOGGING -------
- *
- * SUBROUTINE SHORT NAME = LWL
- // Input Pointers:
- // tcConnectptr
- // logPartPtr
- * ------------------------------------------------------------------------- */
- void Dblqh::linkWaitLog(Signal* signal, LogPartRecordPtr regLogPartPtr)
- {
- TcConnectionrecPtr lwlTcConnectptr;
- /* -------------------------------------------------- */
- /* LINK ACTIVE OPERATION INTO QUEUE WAITING FOR */
- /* ACCESS TO THE LOG PART. */
- /* -------------------------------------------------- */
- lwlTcConnectptr.i = regLogPartPtr.p->lastLogQueue;
- if (lwlTcConnectptr.i == RNIL) {
- jam();
- regLogPartPtr.p->firstLogQueue = tcConnectptr.i;
- } else {
- jam();
- ptrCheckGuard(lwlTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- lwlTcConnectptr.p->nextTcLogQueue = tcConnectptr.i;
- }//if
- regLogPartPtr.p->lastLogQueue = tcConnectptr.i;
- tcConnectptr.p->nextTcLogQueue = RNIL;
- if (regLogPartPtr.p->LogLqhKeyReqSent == ZFALSE) {
- jam();
- regLogPartPtr.p->LogLqhKeyReqSent = ZTRUE;
- signal->theData[0] = ZLOG_LQHKEYREQ;
- signal->theData[1] = regLogPartPtr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
- }//if
- }//Dblqh::linkWaitLog()
- /* --------------------------------------------------------------------------
- * ------- START THE NEXT OPERATION ON THIS LOG PART IF ANY -------
- * ------- OPERATIONS ARE QUEUED. -------
- *
- * SUBROUTINE SHORT NAME = LNS
- // Input Pointers:
- // tcConnectptr
- // logPartPtr
- * ------------------------------------------------------------------------- */
- void Dblqh::logNextStart(Signal* signal)
- {
- LogPartRecordPtr lnsLogPartPtr;
- UintR tlnsStillWaiting;
- LogPartRecord * const regLogPartPtr = logPartPtr.p;
- if ((regLogPartPtr->firstLogQueue == RNIL) &&
- (regLogPartPtr->logPartState == LogPartRecord::ACTIVE) &&
- (regLogPartPtr->waitWriteGciLog != LogPartRecord::WWGL_TRUE)) {
- // --------------------------------------------------------------------------
- // Optimised route for the common case
- // --------------------------------------------------------------------------
- regLogPartPtr->logPartState = LogPartRecord::IDLE;
- return;
- }//if
- if (regLogPartPtr->firstLogQueue != RNIL) {
- jam();
- if (regLogPartPtr->LogLqhKeyReqSent == ZFALSE) {
- jam();
- regLogPartPtr->LogLqhKeyReqSent = ZTRUE;
- signal->theData[0] = ZLOG_LQHKEYREQ;
- signal->theData[1] = logPartPtr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
- }//if
- } else {
- if (regLogPartPtr->logPartState == LogPartRecord::ACTIVE) {
- jam();
- regLogPartPtr->logPartState = LogPartRecord::IDLE;
- } else {
- jam();
- }//if
- }//if
- if (regLogPartPtr->waitWriteGciLog != LogPartRecord::WWGL_TRUE) {
- jam();
- return;
- } else {
- jam();
- /* --------------------------------------------------------------------------
- * A COMPLETE GCI LOG RECORD IS WAITING TO BE WRITTEN. WE GIVE THIS HIGHEST
- * PRIORITY AND WRITE IT IMMEDIATELY. AFTER WRITING IT WE CHECK IF ANY MORE
- * LOG PARTS ARE WAITING. IF NOT WE SEND A SIGNAL THAT INITIALISES THE GCP
- * RECORD TO WAIT UNTIL ALL COMPLETE GCI LOG RECORDS HAVE REACHED TO DISK.
- * -------------------------------------------------------------------------- */
- writeCompletedGciLog(signal);
- logPartPtr.p->waitWriteGciLog = LogPartRecord::WWGL_FALSE;
- tlnsStillWaiting = ZFALSE;
- for (lnsLogPartPtr.i = 0; lnsLogPartPtr.i < 4; lnsLogPartPtr.i++) {
- jam();
- ptrAss(lnsLogPartPtr, logPartRecord);
- if (lnsLogPartPtr.p->waitWriteGciLog == LogPartRecord::WWGL_TRUE) {
- jam();
- tlnsStillWaiting = ZTRUE;
- }//if
- }//for
- if (tlnsStillWaiting == ZFALSE) {
- jam();
- signal->theData[0] = ZINIT_GCP_REC;
- sendSignal(cownref, GSN_CONTINUEB, signal, 1, JBB);
- }//if
- }//if
- }//Dblqh::logNextStart()
- /* --------------------------------------------------------------------------
- * ------- MOVE PAGES FROM LFO RECORD TO PAGE REFERENCE RECORD -------
- * WILL ALWAYS MOVE 8 PAGES TO A PAGE REFERENCE RECORD.
- *
- * SUBROUTINE SHORT NAME = MPR
- * ------------------------------------------------------------------------- */
- void Dblqh::moveToPageRef(Signal* signal)
- {
- LogPageRecordPtr mprLogPagePtr;
- PageRefRecordPtr mprPageRefPtr;
- UintR tmprIndex;
- /* --------------------------------------------------------------------------
- * ------- INSERT PAGE REFERENCE RECORD -------
- *
- * INPUT: LFO_PTR LOG FILE OPERATION RECORD
- * LOG_PART_PTR LOG PART RECORD
- * PAGE_REF_PTR THE PAGE REFERENCE RECORD TO BE INSERTED.
- * ------------------------------------------------------------------------- */
- PageRefRecordPtr iprPageRefPtr;
- if ((logPartPtr.p->mmBufferSize + 8) >= ZMAX_MM_BUFFER_SIZE) {
- jam();
- pageRefPtr.i = logPartPtr.p->firstPageRef;
- ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
- releasePrPages(signal);
- removePageRef(signal);
- } else {
- jam();
- logPartPtr.p->mmBufferSize = logPartPtr.p->mmBufferSize + 8;
- }//if
- seizePageRef(signal);
- if (logPartPtr.p->firstPageRef == RNIL) {
- jam();
- logPartPtr.p->firstPageRef = pageRefPtr.i;
- } else {
- jam();
- iprPageRefPtr.i = logPartPtr.p->lastPageRef;
- ptrCheckGuard(iprPageRefPtr, cpageRefFileSize, pageRefRecord);
- iprPageRefPtr.p->prNext = pageRefPtr.i;
- }//if
- pageRefPtr.p->prPrev = logPartPtr.p->lastPageRef;
- logPartPtr.p->lastPageRef = pageRefPtr.i;
- pageRefPtr.p->prFileNo = logFilePtr.p->fileNo;
- pageRefPtr.p->prPageNo = lfoPtr.p->lfoPageNo;
- tmprIndex = 0;
- mprLogPagePtr.i = lfoPtr.p->firstLfoPage;
- MPR_LOOP:
- arrGuard(tmprIndex, 8);
- pageRefPtr.p->pageRef[tmprIndex] = mprLogPagePtr.i;
- tmprIndex = tmprIndex + 1;
- ptrCheckGuard(mprLogPagePtr, clogPageFileSize, logPageRecord);
- mprLogPagePtr.i = mprLogPagePtr.p->logPageWord[ZNEXT_PAGE];
- if (mprLogPagePtr.i != RNIL) {
- jam();
- goto MPR_LOOP;
- }//if
- mprPageRefPtr.i = pageRefPtr.p->prPrev;
- if (mprPageRefPtr.i != RNIL) {
- jam();
- ptrCheckGuard(mprPageRefPtr, cpageRefFileSize, pageRefRecord);
- mprLogPagePtr.i = mprPageRefPtr.p->pageRef[7];
- ptrCheckGuard(mprLogPagePtr, clogPageFileSize, logPageRecord);
- mprLogPagePtr.p->logPageWord[ZNEXT_PAGE] = pageRefPtr.p->pageRef[0];
- }//if
- }//Dblqh::moveToPageRef()
- /* ------------------------------------------------------------------------- */
- /* ------- READ THE ATTRINFO FROM THE LOG ------- */
- /* */
- /* SUBROUTINE SHORT NAME = RA */
- /* ------------------------------------------------------------------------- */
- void Dblqh::readAttrinfo(Signal* signal)
- {
- Uint32 remainingLen = tcConnectptr.p->totSendlenAi;
- if (remainingLen == 0) {
- jam();
- tcConnectptr.p->reclenAiLqhkey = 0;
- return;
- }//if
- Uint32 dataLen = remainingLen;
- if (remainingLen > 5)
- dataLen = 5;
- readLogData(signal, dataLen, &tcConnectptr.p->firstAttrinfo[0]);
- tcConnectptr.p->reclenAiLqhkey = dataLen;
- remainingLen -= dataLen;
- while (remainingLen > 0) {
- jam();
- dataLen = remainingLen;
- if (remainingLen > 22)
- dataLen = 22;
- seizeAttrinbuf(signal);
- readLogData(signal, dataLen, &attrinbufptr.p->attrbuf[0]);
- attrinbufptr.p->attrbuf[ZINBUF_DATA_LEN] = dataLen;
- remainingLen -= dataLen;
- }//while
- }//Dblqh::readAttrinfo()
- /* ------------------------------------------------------------------------- */
- /* ------- READ COMMIT LOG ------- */
- /* */
- /* SUBROUTINE SHORT NAME = RCL */
- /* ------------------------------------------------------------------------- */
- void Dblqh::readCommitLog(Signal* signal, CommitLogRecord* commitLogRecord)
- {
- Uint32 trclPageIndex = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- if ((trclPageIndex + (ZCOMMIT_LOG_SIZE - 1)) < ZPAGE_SIZE) {
- jam();
- tcConnectptr.p->tableref = logPagePtr.p->logPageWord[trclPageIndex + 0];
- tcConnectptr.p->schemaVersion = logPagePtr.p->logPageWord[trclPageIndex + 1];
- tcConnectptr.p->fragmentid = logPagePtr.p->logPageWord[trclPageIndex + 2];
- commitLogRecord->fileNo = logPagePtr.p->logPageWord[trclPageIndex + 3];
- commitLogRecord->startPageNo = logPagePtr.p->logPageWord[trclPageIndex + 4];
- commitLogRecord->startPageIndex = logPagePtr.p->logPageWord[trclPageIndex + 5];
- commitLogRecord->stopPageNo = logPagePtr.p->logPageWord[trclPageIndex + 6];
- tcConnectptr.p->gci = logPagePtr.p->logPageWord[trclPageIndex + 7];
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] =
- (trclPageIndex + ZCOMMIT_LOG_SIZE) - 1;
- } else {
- jam();
- tcConnectptr.p->tableref = readLogword(signal);
- tcConnectptr.p->schemaVersion = readLogword(signal);
- tcConnectptr.p->fragmentid = readLogword(signal);
- commitLogRecord->fileNo = readLogword(signal);
- commitLogRecord->startPageNo = readLogword(signal);
- commitLogRecord->startPageIndex = readLogword(signal);
- commitLogRecord->stopPageNo = readLogword(signal);
- tcConnectptr.p->gci = readLogword(signal);
- }//if
- tcConnectptr.p->transid[0] = logPartPtr.i + 65536;
- tcConnectptr.p->transid[1] = (DBLQH << 20) + (cownNodeid << 8);
- }//Dblqh::readCommitLog()
- /* ------------------------------------------------------------------------- */
- /* ------- READ LOG PAGES FROM DISK IN ORDER TO EXECUTE A LOG ------- */
- /* RECORD WHICH WAS NOT FOUND IN MAIN MEMORY. */
- /* */
- /* SUBROUTINE SHORT NAME = REL */
- /* ------------------------------------------------------------------------- */
- void Dblqh::readExecLog(Signal* signal)
- {
- UintR trelIndex;
- UintR trelI;
- seizeLfo(signal);
- initLfo(signal);
- trelI = logPartPtr.p->execSrStopPageNo - logPartPtr.p->execSrStartPageNo;
- arrGuard(trelI + 1, 16);
- lfoPtr.p->logPageArray[trelI + 1] = logPartPtr.p->execSrStartPageNo;
- for (trelIndex = logPartPtr.p->execSrStopPageNo; (trelIndex >= logPartPtr.p->execSrStartPageNo) &&
- (UintR)~trelIndex; trelIndex--) {
- jam();
- seizeLogpage(signal);
- arrGuard(trelI, 16);
- lfoPtr.p->logPageArray[trelI] = logPagePtr.i;
- trelI--;
- }//for
- lfoPtr.p->lfoPageNo = logPartPtr.p->execSrStartPageNo;
- lfoPtr.p->noPagesRw = (logPartPtr.p->execSrStopPageNo -
- logPartPtr.p->execSrStartPageNo) + 1;
- lfoPtr.p->firstLfoPage = lfoPtr.p->logPageArray[0];
- signal->theData[0] = logFilePtr.p->fileRef;
- signal->theData[1] = cownref;
- signal->theData[2] = lfoPtr.i;
- signal->theData[3] = ZLIST_OF_MEM_PAGES; // edtjamo TR509 //ZLIST_OF_PAIRS;
- signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
- signal->theData[5] = lfoPtr.p->noPagesRw;
- signal->theData[6] = lfoPtr.p->logPageArray[0];
- signal->theData[7] = lfoPtr.p->logPageArray[1];
- signal->theData[8] = lfoPtr.p->logPageArray[2];
- signal->theData[9] = lfoPtr.p->logPageArray[3];
- signal->theData[10] = lfoPtr.p->logPageArray[4];
- signal->theData[11] = lfoPtr.p->logPageArray[5];
- signal->theData[12] = lfoPtr.p->logPageArray[6];
- signal->theData[13] = lfoPtr.p->logPageArray[7];
- signal->theData[14] = lfoPtr.p->logPageArray[8];
- signal->theData[15] = lfoPtr.p->logPageArray[9];
- sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 16, JBA);
- }//Dblqh::readExecLog()
- /* ------------------------------------------------------------------------- */
- /* ------- READ 64 KBYTES WHEN EXECUTING THE FRAGMENT LOG ------- */
- /* */
- /* SUBROUTINE SHORT NAME = RES */
- /* ------------------------------------------------------------------------- */
- void Dblqh::readExecSrNewMbyte(Signal* signal)
- {
- logFilePtr.p->currentFilepage = logFilePtr.p->currentMbyte * ZPAGES_IN_MBYTE;
- logFilePtr.p->filePosition = logFilePtr.p->currentMbyte * ZPAGES_IN_MBYTE;
- logPartPtr.p->execSrPagesRead = 0;
- logPartPtr.p->execSrPagesReading = 0;
- logPartPtr.p->execSrPagesExecuted = 0;
- readExecSr(signal);
- logPartPtr.p->logExecState = LogPartRecord::LES_WAIT_READ_EXEC_SR_NEW_MBYTE;
- }//Dblqh::readExecSrNewMbyte()
- /* ------------------------------------------------------------------------- */
- /* ------- READ 64 KBYTES WHEN EXECUTING THE FRAGMENT LOG ------- */
- /* */
- /* SUBROUTINE SHORT NAME = RES */
- /* ------------------------------------------------------------------------- */
- void Dblqh::readExecSr(Signal* signal)
- {
- UintR tresPageid;
- UintR tresIndex;
- tresPageid = logFilePtr.p->filePosition;
- seizeLfo(signal);
- initLfo(signal);
- for (tresIndex = 7; (UintR)~tresIndex; tresIndex--) {
- jam();
- /* ------------------------------------------------------------------------- */
- /* GO BACKWARDS SINCE WE INSERT AT THE BEGINNING AND WE WANT THAT FIRST PAGE */
- /* SHALL BE FIRST AND LAST PAGE LAST. */
- /* ------------------------------------------------------------------------- */
- seizeLogpage(signal);
- lfoPtr.p->logPageArray[tresIndex] = logPagePtr.i;
- }//for
- lfoPtr.p->lfoState = LogFileOperationRecord::READ_EXEC_SR;
- lfoPtr.p->lfoPageNo = tresPageid;
- logFilePtr.p->filePosition = logFilePtr.p->filePosition + 8;
- logPartPtr.p->execSrPagesReading = logPartPtr.p->execSrPagesReading + 8;
- lfoPtr.p->noPagesRw = 8;
- lfoPtr.p->firstLfoPage = lfoPtr.p->logPageArray[0];
- signal->theData[0] = logFilePtr.p->fileRef;
- signal->theData[1] = cownref;
- signal->theData[2] = lfoPtr.i;
- signal->theData[3] = ZLIST_OF_MEM_PAGES;
- signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
- signal->theData[5] = 8;
- signal->theData[6] = lfoPtr.p->logPageArray[0];
- signal->theData[7] = lfoPtr.p->logPageArray[1];
- signal->theData[8] = lfoPtr.p->logPageArray[2];
- signal->theData[9] = lfoPtr.p->logPageArray[3];
- signal->theData[10] = lfoPtr.p->logPageArray[4];
- signal->theData[11] = lfoPtr.p->logPageArray[5];
- signal->theData[12] = lfoPtr.p->logPageArray[6];
- signal->theData[13] = lfoPtr.p->logPageArray[7];
- signal->theData[14] = tresPageid;
- sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 15, JBA);
- }//Dblqh::readExecSr()
- /* ------------------------------------------------------------------------- */
- /* ------------ READ THE PRIMARY KEY FROM THE LOG ---------------- */
- /* */
- /* SUBROUTINE SHORT NAME = RK */
- /* --------------------------------------------------------------------------*/
- void Dblqh::readKey(Signal* signal)
- {
- Uint32 remainingLen = tcConnectptr.p->primKeyLen;
- ndbrequire(remainingLen != 0);
- Uint32 dataLen = remainingLen;
- if (remainingLen > 4)
- dataLen = 4;
- readLogData(signal, dataLen, &tcConnectptr.p->tupkeyData[0]);
- remainingLen -= dataLen;
- while (remainingLen > 0) {
- jam();
- seizeTupkeybuf(signal);
- dataLen = remainingLen;
- if (dataLen > 4)
- dataLen = 4;
- readLogData(signal, dataLen, &databufptr.p->data[0]);
- remainingLen -= dataLen;
- }//while
- }//Dblqh::readKey()
- /* ------------------------------------------------------------------------- */
- /* ------------ READ A NUMBER OF WORDS FROM LOG INTO CDATA ---------------- */
- /* */
- /* SUBROUTINE SHORT NAME = RLD */
- /* --------------------------------------------------------------------------*/
- void Dblqh::readLogData(Signal* signal, Uint32 noOfWords, Uint32* dataPtr)
- {
- ndbrequire(noOfWords < 32);
- Uint32 logPos = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- if ((logPos + noOfWords) >= ZPAGE_SIZE) {
- for (Uint32 i = 0; i < noOfWords; i++)
- dataPtr[i] = readLogwordExec(signal);
- } else {
- MEMCOPY_NO_WORDS(dataPtr, &logPagePtr.p->logPageWord[logPos], noOfWords);
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = logPos + noOfWords;
- }//if
- }//Dblqh::readLogData()
- /* ------------------------------------------------------------------------- */
- /* ------------ READ THE LOG HEADER OF A PREPARE LOG HEADER ---------------- */
- /* */
- /* SUBROUTINE SHORT NAME = RLH */
- /* --------------------------------------------------------------------------*/
- void Dblqh::readLogHeader(Signal* signal)
- {
- Uint32 logPos = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- if ((logPos + ZLOG_HEAD_SIZE) < ZPAGE_SIZE) {
- jam();
- tcConnectptr.p->hashValue = logPagePtr.p->logPageWord[logPos + 2];
- tcConnectptr.p->operation = logPagePtr.p->logPageWord[logPos + 3];
- tcConnectptr.p->totSendlenAi = logPagePtr.p->logPageWord[logPos + 4];
- tcConnectptr.p->primKeyLen = logPagePtr.p->logPageWord[logPos + 5];
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = logPos + ZLOG_HEAD_SIZE;
- } else {
- jam();
- readLogwordExec(signal); /* IGNORE PREPARE LOG RECORD TYPE */
- readLogwordExec(signal); /* IGNORE LOG RECORD SIZE */
- tcConnectptr.p->hashValue = readLogwordExec(signal);
- tcConnectptr.p->operation = readLogwordExec(signal);
- tcConnectptr.p->totSendlenAi = readLogwordExec(signal);
- tcConnectptr.p->primKeyLen = readLogwordExec(signal);
- }//if
- }//Dblqh::readLogHeader()
- /* ------------------------------------------------------------------------- */
- /* ------- READ A WORD FROM THE LOG ------- */
- /* */
- /* OUTPUT: TLOG_WORD */
- /* SUBROUTINE SHORT NAME = RLW */
- /* ------------------------------------------------------------------------- */
- Uint32 Dblqh::readLogword(Signal* signal)
- {
- Uint32 logPos = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- ndbrequire(logPos < ZPAGE_SIZE);
- Uint32 logWord = logPagePtr.p->logPageWord[logPos];
- logPos++;
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = logPos;
- if (logPos >= ZPAGE_SIZE) {
- jam();
- logPagePtr.i = logPagePtr.p->logPageWord[ZNEXT_PAGE];
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
- logFilePtr.p->currentLogpage = logPagePtr.i;
- logFilePtr.p->currentFilepage++;
- logPartPtr.p->execSrPagesRead--;
- logPartPtr.p->execSrPagesExecuted++;
- }//if
- return logWord;
- }//Dblqh::readLogword()
- /* ------------------------------------------------------------------------- */
- /* ------- READ A WORD FROM THE LOG WHEN EXECUTING A LOG RECORD ------- */
- /* */
- /* OUTPUT: TLOG_WORD */
- /* SUBROUTINE SHORT NAME = RWE */
- /* ------------------------------------------------------------------------- */
- Uint32 Dblqh::readLogwordExec(Signal* signal)
- {
- Uint32 logPos = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- ndbrequire(logPos < ZPAGE_SIZE);
- Uint32 logWord = logPagePtr.p->logPageWord[logPos];
- logPos++;
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = logPos;
- if (logPos >= ZPAGE_SIZE) {
- jam();
- logPagePtr.i = logPagePtr.p->logPageWord[ZNEXT_PAGE];
- if (logPagePtr.i != RNIL){
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
- } else {
- // Reading word at the last pos in the last page
- // Don't step forward to next page!
- jam();
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX]++;
- }
- }//if
- return logWord;
- }//Dblqh::readLogwordExec()
- /* ------------------------------------------------------------------------- */
- /* ------- READ A SINGLE PAGE FROM THE LOG ------- */
- /* */
- /* INPUT: TRSP_PAGE_NO */
- /* SUBROUTINE SHORT NAME = RSP */
- /* ------------------------------------------------------------------------- */
- void Dblqh::readSinglePage(Signal* signal, Uint32 pageNo)
- {
- seizeLfo(signal);
- initLfo(signal);
- seizeLogpage(signal);
- lfoPtr.p->firstLfoPage = logPagePtr.i;
- lfoPtr.p->lfoPageNo = pageNo;
- lfoPtr.p->noPagesRw = 1;
- signal->theData[0] = logFilePtr.p->fileRef;
- signal->theData[1] = cownref;
- signal->theData[2] = lfoPtr.i;
- signal->theData[3] = ZLIST_OF_PAIRS;
- signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
- signal->theData[5] = 1;
- signal->theData[6] = logPagePtr.i;
- signal->theData[7] = pageNo;
- sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 8, JBA);
- }//Dblqh::readSinglePage()
- /* --------------------------------------------------------------------------
- * ------- RELEASE OPERATION FROM ACTIVE LIST ON FRAGMENT -------
- *
- * SUBROUTINE SHORT NAME = RAC
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseAccList(Signal* signal)
- {
- TcConnectionrecPtr racTcNextConnectptr;
- TcConnectionrecPtr racTcPrevConnectptr;
- fragptr.i = tcConnectptr.p->fragmentptr;
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- racTcPrevConnectptr.i = tcConnectptr.p->prevTc;
- racTcNextConnectptr.i = tcConnectptr.p->nextTc;
- if (tcConnectptr.p->listState != TcConnectionrec::ACC_BLOCK_LIST) {
- jam();
- systemError(signal);
- }//if
- tcConnectptr.p->listState = TcConnectionrec::NOT_IN_LIST;
- if (racTcNextConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(racTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- racTcNextConnectptr.p->prevTc = racTcPrevConnectptr.i;
- }//if
- if (racTcPrevConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(racTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- racTcPrevConnectptr.p->nextTc = tcConnectptr.p->nextTc;
- } else {
- jam();
- /* ---------------------------------------------------------------------
- * OPERATION RECORD IS FIRST IN ACTIVE LIST
- * THIS MEANS THAT THERE EXISTS NO PREVIOUS TC THAT NEEDS TO BE UPDATED.
- * --------------------------------------------------------------------- */
- fragptr.p->accBlockedList = racTcNextConnectptr.i;
- }//if
- }//Dblqh::releaseAccList()
- /* --------------------------------------------------------------------------
- * ------- REMOVE COPY FRAGMENT FROM ACTIVE COPY LIST -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseActiveCopy(Signal* signal)
- {
- /* MUST BE 8 BIT */
- UintR tracFlag;
- UintR tracIndex;
- tracFlag = ZFALSE;
- for (tracIndex = 0; tracIndex < 4; tracIndex++) {
- if (tracFlag == ZFALSE) {
- jam();
- if (cactiveCopy[tracIndex] == fragptr.i) {
- jam();
- tracFlag = ZTRUE;
- }//if
- } else {
- if (tracIndex < 3) {
- jam();
- cactiveCopy[tracIndex - 1] = cactiveCopy[tracIndex];
- } else {
- jam();
- cactiveCopy[3] = RNIL;
- }//if
- }//if
- }//for
- ndbrequire(tracFlag == ZTRUE);
- cnoActiveCopy--;
- }//Dblqh::releaseActiveCopy()
- /* --------------------------------------------------------------------------
- * ------- RELEASE OPERATION FROM ACTIVE LIST ON FRAGMENT -------
- *
- * SUBROUTINE SHORT NAME = RAL
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseActiveList(Signal* signal)
- {
- TcConnectionrecPtr ralTcNextConnectptr;
- TcConnectionrecPtr ralTcPrevConnectptr;
- ralTcPrevConnectptr.i = tcConnectptr.p->prevTc;
- ralTcNextConnectptr.i = tcConnectptr.p->nextTc;
- ndbrequire(tcConnectptr.p->listState == TcConnectionrec::IN_ACTIVE_LIST);
- tcConnectptr.p->listState = TcConnectionrec::NOT_IN_LIST;
- if (ralTcNextConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(ralTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- ralTcNextConnectptr.p->prevTc = ralTcPrevConnectptr.i;
- }//if
- if (ralTcPrevConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(ralTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- ralTcPrevConnectptr.p->nextTc = tcConnectptr.p->nextTc;
- } else {
- jam();
- /* ----------------------------------------------------------------------
- * OPERATION RECORD IS FIRST IN ACTIVE LIST
- * THIS MEANS THAT THERE EXISTS NO PREVIOUS TC THAT NEEDS TO BE UPDATED.
- * --------------------------------------------------------------------- */
- fragptr.p->activeList = ralTcNextConnectptr.i;
- }//if
- }//Dblqh::releaseActiveList()
- /* --------------------------------------------------------------------------
- * ------- RELEASE ADD FRAGMENT RECORD -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseAddfragrec(Signal* signal)
- {
- addfragptr.p->addfragStatus = AddFragRecord::FREE;
- addfragptr.p->nextAddfragrec = cfirstfreeAddfragrec;
- cfirstfreeAddfragrec = addfragptr.i;
- }//Dblqh::releaseAddfragrec()
- /* --------------------------------------------------------------------------
- * ------- RELEASE FRAGMENT RECORD -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseFragrec()
- {
- fragptr.p->fragStatus = Fragrecord::FREE;
- fragptr.p->nextFrag = cfirstfreeFragrec;
- cfirstfreeFragrec = fragptr.i;
- }//Dblqh::releaseFragrec()
- /* --------------------------------------------------------------------------
- * ------- RELEASE LCP LOCAL RECORD -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseLcpLoc(Signal* signal)
- {
- lcpLocptr.p->lcpLocstate = LcpLocRecord::IDLE;
- lcpLocptr.p->nextLcpLoc = cfirstfreeLcpLoc;
- cfirstfreeLcpLoc = lcpLocptr.i;
- }//Dblqh::releaseLcpLoc()
- /* --------------------------------------------------------------------------
- * ------- RELEASE A PAGE REFERENCE RECORD. -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::releasePageRef(Signal* signal)
- {
- pageRefPtr.p->prNext = cfirstfreePageRef;
- cfirstfreePageRef = pageRefPtr.i;
- }//Dblqh::releasePageRef()
- /* --------------------------------------------------------------------------
- * --- RELEASE ALL PAGES IN THE MM BUFFER AFTER EXECUTING THE LOG ON IT. ----
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseMmPages(Signal* signal)
- {
- RMP_LOOP:
- jam();
- pageRefPtr.i = logPartPtr.p->firstPageRef;
- if (pageRefPtr.i != RNIL) {
- jam();
- ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
- releasePrPages(signal);
- removePageRef(signal);
- goto RMP_LOOP;
- }//if
- }//Dblqh::releaseMmPages()
- /* --------------------------------------------------------------------------
- * ------- RELEASE A SET OF PAGES AFTER EXECUTING THE LOG ON IT. -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::releasePrPages(Signal* signal)
- {
- UintR trppIndex;
- for (trppIndex = 0; trppIndex <= 7; trppIndex++) {
- jam();
- logPagePtr.i = pageRefPtr.p->pageRef[trppIndex];
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- releaseLogpage(signal);
- }//for
- }//Dblqh::releasePrPages()
- /* --------------------------------------------------------------------------
- * ------- RELEASE OPERATION FROM WAIT QUEUE LIST ON FRAGMENT -------
- *
- * SUBROUTINE SHORT NAME : RWA
- * ------------------------------------------------------------------------- */
- void Dblqh::releaseWaitQueue(Signal* signal)
- {
- TcConnectionrecPtr rwaTcNextConnectptr;
- TcConnectionrecPtr rwaTcPrevConnectptr;
- fragptr.i = tcConnectptr.p->fragmentptr;
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- rwaTcPrevConnectptr.i = tcConnectptr.p->prevTc;
- rwaTcNextConnectptr.i = tcConnectptr.p->nextTc;
- if (tcConnectptr.p->listState != TcConnectionrec::WAIT_QUEUE_LIST) {
- jam();
- systemError(signal);
- }//if
- tcConnectptr.p->listState = TcConnectionrec::NOT_IN_LIST;
- if (rwaTcNextConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(rwaTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- rwaTcNextConnectptr.p->prevTc = rwaTcPrevConnectptr.i;
- } else {
- jam();
- fragptr.p->lastWaitQueue = rwaTcPrevConnectptr.i;
- }//if
- if (rwaTcPrevConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(rwaTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- rwaTcPrevConnectptr.p->nextTc = rwaTcNextConnectptr.i;
- } else {
- jam();
- fragptr.p->firstWaitQueue = rwaTcNextConnectptr.i;
- }//if
- }//Dblqh::releaseWaitQueue()
- /* --------------------------------------------------------------------------
- * ------- REMOVE OPERATION RECORD FROM LIST ON LOG PART OF NOT -------
- * COMPLETED OPERATIONS IN THE LOG.
- *
- * SUBROUTINE SHORT NAME = RLO
- * ------------------------------------------------------------------------- */
- void Dblqh::removeLogTcrec(Signal* signal)
- {
- TcConnectionrecPtr rloTcNextConnectptr;
- TcConnectionrecPtr rloTcPrevConnectptr;
- rloTcPrevConnectptr.i = tcConnectptr.p->prevLogTcrec;
- rloTcNextConnectptr.i = tcConnectptr.p->nextLogTcrec;
- if (rloTcNextConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(rloTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- rloTcNextConnectptr.p->prevLogTcrec = rloTcPrevConnectptr.i;
- } else {
- jam();
- logPartPtr.p->lastLogTcrec = rloTcPrevConnectptr.i;
- }//if
- if (rloTcPrevConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(rloTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- rloTcPrevConnectptr.p->nextLogTcrec = rloTcNextConnectptr.i;
- } else {
- jam();
- logPartPtr.p->firstLogTcrec = rloTcNextConnectptr.i;
- }//if
- }//Dblqh::removeLogTcrec()
- /* --------------------------------------------------------------------------
- * ------- REMOVE PAGE REFERENCE RECORD FROM LIST IN THIS LOG PART -------
- *
- * SUBROUTINE SHORT NAME = RPR
- * ------------------------------------------------------------------------- */
- void Dblqh::removePageRef(Signal* signal)
- {
- PageRefRecordPtr rprPageRefPtr;
- pageRefPtr.i = logPartPtr.p->firstPageRef;
- if (pageRefPtr.i != RNIL) {
- jam();
- ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
- if (pageRefPtr.p->prNext == RNIL) {
- jam();
- logPartPtr.p->lastPageRef = RNIL;
- logPartPtr.p->firstPageRef = RNIL;
- } else {
- jam();
- logPartPtr.p->firstPageRef = pageRefPtr.p->prNext;
- rprPageRefPtr.i = pageRefPtr.p->prNext;
- ptrCheckGuard(rprPageRefPtr, cpageRefFileSize, pageRefRecord);
- rprPageRefPtr.p->prPrev = RNIL;
- }//if
- releasePageRef(signal);
- }//if
- }//Dblqh::removePageRef()
- /* ------------------------------------------------------------------------- */
- /* ------- RETURN FROM EXECUTION OF LOG ------- */
- /* */
- /* ------------------------------------------------------------------------- */
- Uint32 Dblqh::returnExecLog(Signal* signal)
- {
- tcConnectptr.p->connectState = TcConnectionrec::CONNECTED;
- initLogPointers(signal);
- logPartPtr.p->execSrExecuteIndex++;
- Uint32 result = checkIfExecLog(signal);
- if (result == ZOK) {
- jam();
- /* ------------------------------------------------------------------------- */
- /* THIS LOG RECORD WILL BE EXECUTED AGAIN TOWARDS ANOTHER NODE. */
- /* ------------------------------------------------------------------------- */
- logPagePtr.i = logPartPtr.p->execSrLogPage;
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] =
- logPartPtr.p->execSrLogPageIndex;
- } else {
- jam();
- /* ------------------------------------------------------------------------- */
- /* NO MORE EXECUTION OF THIS LOG RECORD. */
- /* ------------------------------------------------------------------------- */
- if (logPartPtr.p->logExecState ==
- LogPartRecord::LES_EXEC_LOGREC_FROM_FILE) {
- jam();
- /* ------------------------------------------------------------------------- */
- /* THE LOG RECORD WAS READ FROM DISK. RELEASE ITS PAGES IMMEDIATELY. */
- /* ------------------------------------------------------------------------- */
- lfoPtr.i = logPartPtr.p->execSrLfoRec;
- ptrCheckGuard(lfoPtr, clfoFileSize, logFileOperationRecord);
- releaseLfoPages(signal);
- releaseLfo(signal);
- logPartPtr.p->logExecState = LogPartRecord::LES_EXEC_LOG;
- if (logPartPtr.p->execSrExecLogFile != logPartPtr.p->currentLogfile) {
- jam();
- LogFileRecordPtr clfLogFilePtr;
- clfLogFilePtr.i = logPartPtr.p->execSrExecLogFile;
- ptrCheckGuard(clfLogFilePtr, clogFileFileSize, logFileRecord);
- clfLogFilePtr.p->logFileStatus = LogFileRecord::CLOSING_EXEC_LOG;
- closeFile(signal, clfLogFilePtr);
- result = ZCLOSE_FILE;
- }//if
- }//if
- logPartPtr.p->execSrExecuteIndex = 0;
- logPartPtr.p->execSrLogPage = RNIL;
- logPartPtr.p->execSrLogPageIndex = ZNIL;
- logPagePtr.i = logFilePtr.p->currentLogpage;
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = logPartPtr.p->savePageIndex;
- }//if
- return result;
- }//Dblqh::returnExecLog()
- /* --------------------------------------------------------------------------
- * ------- SEIZE ADD FRAGMENT RECORD ------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::seizeAddfragrec(Signal* signal)
- {
- addfragptr.i = cfirstfreeAddfragrec;
- ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
- cfirstfreeAddfragrec = addfragptr.p->nextAddfragrec;
- }//Dblqh::seizeAddfragrec()
- /* --------------------------------------------------------------------------
- * ------- SEIZE FRAGMENT RECORD -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::seizeFragmentrec(Signal* signal)
- {
- fragptr.i = cfirstfreeFragrec;
- ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord);
- cfirstfreeFragrec = fragptr.p->nextFrag;
- fragptr.p->nextFrag = RNIL;
- }//Dblqh::seizeFragmentrec()
- /* ------------------------------------------------------------------------- */
- /* ------- SEIZE A PAGE REFERENCE RECORD. ------- */
- /* */
- /* ------------------------------------------------------------------------- */
- void Dblqh::seizePageRef(Signal* signal)
- {
- pageRefPtr.i = cfirstfreePageRef;
- ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
- cfirstfreePageRef = pageRefPtr.p->prNext;
- pageRefPtr.p->prNext = RNIL;
- }//Dblqh::seizePageRef()
- /* --------------------------------------------------------------------------
- * ------- SEND ABORTED -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::sendAborted(Signal* signal)
- {
- UintR TlastInd;
- if (tcConnectptr.p->nextReplica == ZNIL) {
- TlastInd = ZTRUE;
- } else {
- TlastInd = ZFALSE;
- }//if
- signal->theData[0] = tcConnectptr.p->tcOprec;
- signal->theData[1] = tcConnectptr.p->transid[0];
- signal->theData[2] = tcConnectptr.p->transid[1];
- signal->theData[3] = cownNodeid;
- signal->theData[4] = TlastInd;
- sendSignal(tcConnectptr.p->tcBlockref, GSN_ABORTED, signal, 5, JBB);
- return;
- }//Dblqh::sendAborted()
- /* --------------------------------------------------------------------------
- * ------- SEND LQH_TRANSCONF -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::sendLqhTransconf(Signal* signal, LqhTransConf::OperationStatus stat)
- {
- tcNodeFailptr.i = tcConnectptr.p->tcNodeFailrec;
- ptrCheckGuard(tcNodeFailptr, ctcNodeFailrecFileSize, tcNodeFailRecord);
- Uint32 reqInfo = 0;
- LqhTransConf::setReplicaType(reqInfo, tcConnectptr.p->replicaType);
- LqhTransConf::setReplicaNo(reqInfo, tcConnectptr.p->seqNoReplica);
- LqhTransConf::setLastReplicaNo(reqInfo, tcConnectptr.p->lastReplicaNo);
- LqhTransConf::setSimpleFlag(reqInfo, tcConnectptr.p->opSimple);
- LqhTransConf::setDirtyFlag(reqInfo, tcConnectptr.p->dirtyOp);
- LqhTransConf::setOperation(reqInfo, tcConnectptr.p->operation);
-
- LqhTransConf * const lqhTransConf = (LqhTransConf *)&signal->theData[0];
- lqhTransConf->tcRef = tcNodeFailptr.p->newTcRef;
- lqhTransConf->lqhNodeId = cownNodeid;
- lqhTransConf->operationStatus = stat;
- lqhTransConf->lqhConnectPtr = tcConnectptr.i;
- lqhTransConf->transId1 = tcConnectptr.p->transid[0];
- lqhTransConf->transId2 = tcConnectptr.p->transid[1];
- lqhTransConf->oldTcOpRec = tcConnectptr.p->tcOprec;
- lqhTransConf->requestInfo = reqInfo;
- lqhTransConf->gci = tcConnectptr.p->gci;
- lqhTransConf->nextNodeId1 = tcConnectptr.p->nextReplica;
- lqhTransConf->nextNodeId2 = tcConnectptr.p->nodeAfterNext[0];
- lqhTransConf->nextNodeId3 = tcConnectptr.p->nodeAfterNext[1];
- lqhTransConf->apiRef = tcConnectptr.p->applRef;
- lqhTransConf->apiOpRec = tcConnectptr.p->applOprec;
- lqhTransConf->tableId = tcConnectptr.p->tableref;
- sendSignal(tcNodeFailptr.p->newTcBlockref, GSN_LQH_TRANSCONF,
- signal, LqhTransConf::SignalLength, JBB);
- tcNodeFailptr.p->tcRecNow = tcConnectptr.i + 1;
- signal->theData[0] = ZLQH_TRANS_NEXT;
- signal->theData[1] = tcNodeFailptr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
- }//Dblqh::sendLqhTransconf()
- /* --------------------------------------------------------------------------
- * ------- START ANOTHER PHASE OF LOG EXECUTION -------
- * RESET THE VARIABLES NEEDED BY THIS PROCESS AND SEND THE START SIGNAL
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::startExecSr(Signal* signal)
- {
- cnoFragmentsExecSr = 0;
- signal->theData[0] = cfirstCompletedFragSr;
- signal->theData[1] = RNIL;
- sendSignal(cownref, GSN_START_EXEC_SR, signal, 2, JBB);
- }//Dblqh::startExecSr()
- /* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
- * ¤¤¤¤¤¤¤ LOG MODULE ¤¤¤¤¤¤¤
- * ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
- /* --------------------------------------------------------------------------
- * ------- STEP FORWARD IN FRAGMENT LOG DURING LOG EXECUTION -------
- *
- * ------------------------------------------------------------------------- */
- void Dblqh::stepAhead(Signal* signal, Uint32 stepAheadWords)
- {
- UintR tsaPos;
- tsaPos = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- while ((stepAheadWords + tsaPos) >= ZPAGE_SIZE) {
- jam();
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_SIZE;
- stepAheadWords = stepAheadWords - (ZPAGE_SIZE - tsaPos);
- logFilePtr.p->currentLogpage = logPagePtr.p->logPageWord[ZNEXT_PAGE];
- logPagePtr.i = logPagePtr.p->logPageWord[ZNEXT_PAGE];
- logFilePtr.p->currentFilepage++;
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
- logPartPtr.p->execSrPagesRead--;
- logPartPtr.p->execSrPagesExecuted++;
- tsaPos = ZPAGE_HEADER_SIZE;
- }//while
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = stepAheadWords + tsaPos;
- }//Dblqh::stepAhead()
- /* --------------------------------------------------------------------------
- * ------- WRITE A ABORT LOG RECORD -------
- *
- * SUBROUTINE SHORT NAME: WAL
- * ------------------------------------------------------------------------- */
- void Dblqh::writeAbortLog(Signal* signal)
- {
- if ((ZABORT_LOG_SIZE + ZNEXT_LOG_SIZE) >
- logFilePtr.p->remainingWordsInMbyte) {
- jam();
- changeMbyte(signal);
- }//if
- logFilePtr.p->remainingWordsInMbyte =
- logFilePtr.p->remainingWordsInMbyte - ZABORT_LOG_SIZE;
- writeLogWord(signal, ZABORT_TYPE);
- writeLogWord(signal, tcConnectptr.p->transid[0]);
- writeLogWord(signal, tcConnectptr.p->transid[1]);
- }//Dblqh::writeAbortLog()
- /* --------------------------------------------------------------------------
- * ------- WRITE A COMMIT LOG RECORD -------
- *
- * SUBROUTINE SHORT NAME: WCL
- * ------------------------------------------------------------------------- */
- void Dblqh::writeCommitLog(Signal* signal, LogPartRecordPtr regLogPartPtr)
- {
- LogFileRecordPtr regLogFilePtr;
- LogPageRecordPtr regLogPagePtr;
- TcConnectionrec * const regTcPtr = tcConnectptr.p;
- regLogFilePtr.i = regLogPartPtr.p->currentLogfile;
- ptrCheckGuard(regLogFilePtr, clogFileFileSize, logFileRecord);
- regLogPagePtr.i = regLogFilePtr.p->currentLogpage;
- Uint32 twclTmp = regLogFilePtr.p->remainingWordsInMbyte;
- ptrCheckGuard(regLogPagePtr, clogPageFileSize, logPageRecord);
- logPartPtr = regLogPartPtr;
- logFilePtr = regLogFilePtr;
- logPagePtr = regLogPagePtr;
- if ((ZCOMMIT_LOG_SIZE + ZNEXT_LOG_SIZE) > twclTmp) {
- jam();
- changeMbyte(signal);
- twclTmp = logFilePtr.p->remainingWordsInMbyte;
- }//if
- Uint32 twclLogPos = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- Uint32 tableId = regTcPtr->tableref;
- Uint32 schemaVersion = regTcPtr->schemaVersion;
- Uint32 fragId = regTcPtr->fragmentid;
- Uint32 fileNo = regTcPtr->logStartFileNo;
- Uint32 startPageNo = regTcPtr->logStartPageNo;
- Uint32 pageIndex = regTcPtr->logStartPageIndex;
- Uint32 stopPageNo = regTcPtr->logStopPageNo;
- Uint32 gci = regTcPtr->gci;
- logFilePtr.p->remainingWordsInMbyte = twclTmp - ZCOMMIT_LOG_SIZE;
- if ((twclLogPos + ZCOMMIT_LOG_SIZE) >= ZPAGE_SIZE) {
- writeLogWord(signal, ZCOMMIT_TYPE);
- writeLogWord(signal, tableId);
- writeLogWord(signal, schemaVersion);
- writeLogWord(signal, fragId);
- writeLogWord(signal, fileNo);
- writeLogWord(signal, startPageNo);
- writeLogWord(signal, pageIndex);
- writeLogWord(signal, stopPageNo);
- writeLogWord(signal, gci);
- } else {
- Uint32* dataPtr = &logPagePtr.p->logPageWord[twclLogPos];
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = twclLogPos + ZCOMMIT_LOG_SIZE;
- dataPtr[0] = ZCOMMIT_TYPE;
- dataPtr[1] = tableId;
- dataPtr[2] = schemaVersion;
- dataPtr[3] = fragId;
- dataPtr[4] = fileNo;
- dataPtr[5] = startPageNo;
- dataPtr[6] = pageIndex;
- dataPtr[7] = stopPageNo;
- dataPtr[8] = gci;
- }//if
- TcConnectionrecPtr rloTcNextConnectptr;
- TcConnectionrecPtr rloTcPrevConnectptr;
- rloTcPrevConnectptr.i = regTcPtr->prevLogTcrec;
- rloTcNextConnectptr.i = regTcPtr->nextLogTcrec;
- if (rloTcNextConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(rloTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- rloTcNextConnectptr.p->prevLogTcrec = rloTcPrevConnectptr.i;
- } else {
- regLogPartPtr.p->lastLogTcrec = rloTcPrevConnectptr.i;
- }//if
- if (rloTcPrevConnectptr.i != RNIL) {
- jam();
- ptrCheckGuard(rloTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
- rloTcPrevConnectptr.p->nextLogTcrec = rloTcNextConnectptr.i;
- } else {
- regLogPartPtr.p->firstLogTcrec = rloTcNextConnectptr.i;
- }//if
- }//Dblqh::writeCommitLog()
- /* --------------------------------------------------------------------------
- * ------- WRITE A COMPLETED GCI LOG RECORD -------
- *
- * SUBROUTINE SHORT NAME: WCG
- // Input Pointers:
- // logFilePtr
- // logPartPtr
- * ------------------------------------------------------------------------- */
- void Dblqh::writeCompletedGciLog(Signal* signal)
- {
- if ((ZCOMPLETED_GCI_LOG_SIZE + ZNEXT_LOG_SIZE) >
- logFilePtr.p->remainingWordsInMbyte) {
- jam();
- changeMbyte(signal);
- }//if
- logFilePtr.p->remainingWordsInMbyte =
- logFilePtr.p->remainingWordsInMbyte - ZCOMPLETED_GCI_LOG_SIZE;
- writeLogWord(signal, ZCOMPLETED_GCI_TYPE);
- writeLogWord(signal, cnewestCompletedGci);
- logPartPtr.p->logPartNewestCompletedGCI = cnewestCompletedGci;
- }//Dblqh::writeCompletedGciLog()
- /* --------------------------------------------------------------------------
- * ------- WRITE A DIRTY PAGE DURING LOG EXECUTION -------
- *
- * SUBROUTINE SHORT NAME: WD
- * ------------------------------------------------------------------------- */
- void Dblqh::writeDirty(Signal* signal, Uint32 place)
- {
- logPagePtr.p->logPageWord[ZPOS_DIRTY] = ZNOT_DIRTY;
- ndbassert(logPartPtr.p->prevFilepage ==
- logPagePtr.p->logPageWord[ZPOS_PAGE_NO]);
- writeDbgInfoPageHeader(logPagePtr, place, logPartPtr.p->prevFilepage,
- ZPAGE_SIZE);
- // Calculate checksum for page
- logPagePtr.p->logPageWord[ZPOS_CHECKSUM] = calcPageCheckSum(logPagePtr);
- seizeLfo(signal);
- initLfo(signal);
- lfoPtr.p->lfoPageNo = logPartPtr.p->prevFilepage;
- lfoPtr.p->noPagesRw = 1;
- lfoPtr.p->lfoState = LogFileOperationRecord::WRITE_DIRTY;
- lfoPtr.p->firstLfoPage = logPagePtr.i;
- signal->theData[0] = logFilePtr.p->fileRef;
- signal->theData[1] = cownref;
- signal->theData[2] = lfoPtr.i;
- signal->theData[3] = ZLIST_OF_PAIRS_SYNCH;
- signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
- signal->theData[5] = 1;
- signal->theData[6] = logPagePtr.i;
- signal->theData[7] = logPartPtr.p->prevFilepage;
- sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 8, JBA);
- }//Dblqh::writeDirty()
- /* --------------------------------------------------------------------------
- * ------- WRITE A WORD INTO THE LOG, CHECK FOR NEW PAGE -------
- *
- * SUBROUTINE SHORT NAME: WLW
- * ------------------------------------------------------------------------- */
- void Dblqh::writeLogWord(Signal* signal, Uint32 data)
- {
- Uint32 logPos = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
- ndbrequire(logPos < ZPAGE_SIZE);
- logPagePtr.p->logPageWord[logPos] = data;
- logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = logPos + 1;
- if ((logPos + 1) == ZPAGE_SIZE) {
- jam();
- completedLogPage(signal, ZNORMAL, __LINE__);
- seizeLogpage(signal);
- initLogpage(signal);
- logFilePtr.p->currentLogpage = logPagePtr.i;
- logFilePtr.p->currentFilepage++;
- }//if
- }//Dblqh::writeLogWord()
- /* --------------------------------------------------------------------------
- * ------- WRITE A NEXT LOG RECORD AND CHANGE TO NEXT MBYTE -------
- *
- * SUBROUTINE SHORT NAME: WNL
- // Input Pointers:
- // logFilePtr(Redefines)
- // logPagePtr (Redefines)
- // logPartPtr
- * ------------------------------------------------------------------------- */
- void Dblqh::writeNextLog(Signal* signal)
- {
- LogFileRecordPtr wnlNextLogFilePtr;
- UintR twnlNextFileNo;
- UintR twnlNewMbyte;
- UintR twnlRemWords;
- UintR twnlNextMbyte;
- /* -------------------------------------------------- */
- /* CALCULATE THE NEW NUMBER OF REMAINING WORDS */
- /* AS 128*2036 WHERE 128 * 8 KBYTE = 1 MBYTE */
- /* AND 2036 IS THE NUMBER OF WORDS IN A PAGE */
- /* THAT IS USED FOR LOG INFORMATION. */
- /* -------------------------------------------------- */
- twnlRemWords = ZPAGE_SIZE - ZPAGE_HEADER_SIZE;
- twnlRemWords = twnlRemWords * ZPAGES_IN_MBYTE;
- wnlNextLogFilePtr.i = logFilePtr.p->nextLogFile;
- ptrCheckGuard(wnlNextLogFilePtr, clogFileFileSize, logFileRecord);
- /* -------------------------------------------------- */
- /* WRITE THE NEXT LOG RECORD. */
- /* -------------------------------------------------- */
- ndbrequire(logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] < ZPAGE_SIZE);
- logPagePtr.p->logPageWord[logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX]] =
- ZNEXT_MBYTE_TYPE;
- if (logFilePtr.p->currentMbyte == (ZNO_MBYTES_IN_FILE - 1)) {
- jam();
- /* -------------------------------------------------- */
- /* CALCULATE THE NEW REMAINING WORDS WHEN */
- /* CHANGING LOG FILE IS PERFORMED */
- /* -------------------------------------------------- */
- twnlRemWords = twnlRemWords - (ZPAGE_SIZE - ZPAGE_HEADER_SIZE);
- /* -------------------------------------------------- */
- /* ENSURE THAT THE LOG PAGES ARE WRITTEN AFTER */
- /* WE HAVE CHANGED MBYTE. */
- /* -------------------------------------------------- */
- /* ENSURE LAST PAGE IN PREVIOUS MBYTE IS */
- /* WRITTEN AND THAT THE STATE OF THE WRITE IS */
- /* PROPERLY SET. */
- /* -------------------------------------------------- */
- /* WE HAVE TO CHANGE LOG FILE */
- /* -------------------------------------------------- */
- completedLogPage(signal, ZLAST_WRITE_IN_FILE, __LINE__);
- if (wnlNextLogFilePtr.p->fileNo == 0) {
- jam();
- /* -------------------------------------------------- */
- /* WE HAVE FINALISED A LOG LAP, START FROM LOG */
- /* FILE 0 AGAIN */
- /* -------------------------------------------------- */
- logPartPtr.p->logLap++;
- }//if
- logPartPtr.p->currentLogfile = wnlNextLogFilePtr.i;
- logFilePtr.i = wnlNextLogFilePtr.i;
- logFilePtr.p = wnlNextLogFilePtr.p;
- twnlNewMbyte = 0;
- } else {
- jam();
- /* -------------------------------------------------- */
- /* INCREMENT THE CURRENT MBYTE */
- /* SET PAGE INDEX TO PAGE HEADER SIZE */
- /* -------------------------------------------------- */
- completedLogPage(signal, ZENFORCE_WRITE, __LINE__);
- twnlNewMbyte = logFilePtr.p->currentMbyte + 1;
- }//if
- /* -------------------------------------------------- */
- /* CHANGE TO NEW LOG FILE IF NECESSARY */
- /* UPDATE THE FILE POSITION TO THE NEW MBYTE */
- /* FOUND IN PAGE PART OF TNEXT_LOG_PTR */
- /* ALLOCATE AND INITIATE A NEW PAGE SINCE WE */
- /* HAVE SENT THE PREVIOUS PAGE TO DISK. */
- /* SET THE NEW NUMBER OF REMAINING WORDS IN THE */
- /* NEW MBYTE ALLOCATED. */
- /* -------------------------------------------------- */
- logFilePtr.p->currentMbyte = twnlNewMbyte;
- logFilePtr.p->filePosition = twnlNewMbyte * ZPAGES_IN_MBYTE;
- logFilePtr.p->currentFilepage = twnlNewMbyte * ZPAGES_IN_MBYTE;
- logFilePtr.p->remainingWordsInMbyte = twnlRemWords;
- seizeLogpage(signal);
- if (logFilePtr.p->currentMbyte == 0) {
- jam();
- logFilePtr.p->lastPageWritten = 0;
- if (logFilePtr.p->fileNo == 0) {
- jam();
- releaseLogpage(signal);
- logPagePtr.i = logFilePtr.p->logPageZero;
- ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
- }//if
- }//if
- initLogpage(signal);
- logFilePtr.p->currentLogpage = logPagePtr.i;
- if (logFilePtr.p->currentMbyte == 0) {
- jam();
- /* -------------------------------------------------- */
- /* THIS IS A NEW FILE, WRITE THE FILE DESCRIPTOR*/
- /* ALSO OPEN THE NEXT LOG FILE TO ENSURE THAT */
- /* THIS FILE IS OPEN WHEN ITS TURN COMES. */
- /* -------------------------------------------------- */
- writeFileHeaderOpen(signal, ZNORMAL);
- openNextLogfile(signal);
- logFilePtr.p->fileChangeState = LogFileRecord::BOTH_WRITES_ONGOING;
- }//if
- if (logFilePtr.p->fileNo == logPartPtr.p->logTailFileNo) {
- if (logFilePtr.p->currentMbyte == logPartPtr.p->logTailMbyte) {
- jam();
- /* -------------------------------------------------- */
- /* THE HEAD AND TAIL HAS MET. THIS SHOULD NEVER */
- /* OCCUR. CAN HAPPEN IF THE LOCAL CHECKPOINTS */
- /* TAKE FAR TOO LONG TIME. SO TIMING PROBLEMS */
- /* CAN INVOKE THIS SYSTEM CRASH. HOWEVER ONLY */
- /* VERY SERIOUS TIMING PROBLEMS. */
- /* -------------------------------------------------- */
- systemError(signal);
- }//if
- }//if
- if (logFilePtr.p->currentMbyte == (ZNO_MBYTES_IN_FILE - 1)) {
- jam();
- twnlNextMbyte = 0;
- if (logFilePtr.p->fileChangeState != LogFileRecord::NOT_ONGOING) {
- jam();
- logPartPtr.p->logPartState = LogPartRecord::FILE_CHANGE_PROBLEM;
- }//if
- twnlNextFileNo = wnlNextLogFilePtr.p->fileNo;
- } else {
- jam();
- twnlNextMbyte = logFilePtr.p->currentMbyte + 1;
- twnlNextFileNo = logFilePtr.p->fileNo;
- }//if
- if (twnlNextFileNo == logPartPtr.p->logTailFileNo) {
- if (logPartPtr.p->logTailMbyte == twnlNextMbyte) {
- jam();
- /* -------------------------------------------------- */
- /* THE NEXT MBYTE WILL BE THE TAIL. WE MUST */
- /* STOP LOGGING NEW OPERATIONS. THIS OPERATION */
- /* ALLOWED TO PASS. ALSO COMMIT, NEXT, COMPLETED*/
- /* GCI, ABORT AND FRAGMENT SPLIT IS ALLOWED. */
- /* OPERATIONS ARE ALLOWED AGAIN WHEN THE TAIL */
- /* IS MOVED FORWARD AS A RESULT OF A START_LCP */
- /* _ROUND SIGNAL ARRIVING FROM DBDIH. */
- /* -------------------------------------------------- */
- logPartPtr.p->logPartState = LogPartRecord::TAIL_PROBLEM;
- }//if
- }//if
- }//Dblqh::writeNextLog()
- void
- Dblqh::execDUMP_STATE_ORD(Signal* signal)
- {
- DumpStateOrd * const dumpState = (DumpStateOrd *)&signal->theData[0];
- if(dumpState->args[0] == DumpStateOrd::CommitAckMarkersSize){
- infoEvent("LQH: m_commitAckMarkerPool: %d free size: %d",
- m_commitAckMarkerPool.getNoOfFree(),
- m_commitAckMarkerPool.getSize());
- }
- if(dumpState->args[0] == DumpStateOrd::CommitAckMarkersDump){
- infoEvent("LQH: m_commitAckMarkerPool: %d free size: %d",
- m_commitAckMarkerPool.getNoOfFree(),
- m_commitAckMarkerPool.getSize());
-
- CommitAckMarkerIterator iter;
- for(m_commitAckMarkerHash.first(iter); iter.curr.i != RNIL;
- m_commitAckMarkerHash.next(iter)){
- infoEvent("CommitAckMarker: i = %d (0x%x, 0x%x)"
- " ApiRef: 0x%x apiOprec: 0x%x TcNodeId: %d",
- iter.curr.i,
- iter.curr.p->transid1,
- iter.curr.p->transid2,
- iter.curr.p->apiRef,
- iter.curr.p->apiOprec,
- iter.curr.p->tcNodeId);
- }
- }
- // Dump info about number of log pages
- if(dumpState->args[0] == DumpStateOrd::LqhDumpNoLogPages){
- infoEvent("LQH: Log pages : %d Free: %d",
- clogPageFileSize,
- cnoOfLogPages);
- }
- // Dump all defined tables that LQH knowns about
- if(dumpState->args[0] == DumpStateOrd::LqhDumpAllDefinedTabs){
- for(Uint32 i = 0; i<ctabrecFileSize; i++){
- TablerecPtr tabPtr;
- tabPtr.i = i;
- ptrAss(tabPtr, tablerec);
- if(tabPtr.p->tableStatus != Tablerec::NOT_DEFINED){
- infoEvent("Table %d Status: %d Usage: %d",
- i, tabPtr.p->tableStatus, tabPtr.p->usageCount);
- }
- }
- return;
- }
- // Dump all ScanRecords
- if (dumpState->args[0] == DumpStateOrd::LqhDumpAllScanRec){
- Uint32 recordNo = 0;
- if (signal->length() == 1)
- infoEvent("LQH: Dump all ScanRecords - size: %d",
- cscanrecFileSize);
- else if (signal->length() == 2)
- recordNo = dumpState->args[1];
- else
- return;
-
- dumpState->args[0] = DumpStateOrd::LqhDumpOneScanRec;
- dumpState->args[1] = recordNo;
- execDUMP_STATE_ORD(signal);
-
- if (recordNo < cscanrecFileSize-1){
- dumpState->args[0] = DumpStateOrd::LqhDumpAllScanRec;
- dumpState->args[1] = recordNo+1;
- sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
- }
- return;
- }
-
- // Dump all active ScanRecords
- if (dumpState->args[0] == DumpStateOrd::LqhDumpAllActiveScanRec){
- Uint32 recordNo = 0;
- if (signal->length() == 1)
- infoEvent("LQH: Dump active ScanRecord - size: %d",
- cscanrecFileSize);
- else if (signal->length() == 2)
- recordNo = dumpState->args[1];
- else
- return;
- ScanRecordPtr sp;
- sp.i = recordNo;
- c_scanRecordPool.getPtr(scanptr);
- if (sp.p->scanState != ScanRecord::SCAN_FREE){
- dumpState->args[0] = DumpStateOrd::LqhDumpOneScanRec;
- dumpState->args[1] = recordNo;
- execDUMP_STATE_ORD(signal);
- }
-
- if (recordNo < cscanrecFileSize-1){
- dumpState->args[0] = DumpStateOrd::LqhDumpAllActiveScanRec;
- dumpState->args[1] = recordNo+1;
- sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
- }
- return;
- }
- if(dumpState->args[0] == DumpStateOrd::LqhDumpOneScanRec){
- Uint32 recordNo = RNIL;
- if (signal->length() == 2)
- recordNo = dumpState->args[1];
- else
- return;
- if (recordNo >= cscanrecFileSize)
- return;
- ScanRecordPtr sp;
- sp.i = recordNo;
- c_scanRecordPool.getPtr(sp);
- infoEvent("Dblqh::ScanRecord[%d]: state=%d, type=%d, "
- "complStatus=%d, scanNodeId=%d",
- sp.i,
- sp.p->scanState,
- sp.p->scanType,
- sp.p->scanCompletedStatus,
- sp.p->scanNodeId);
- infoEvent(" apiBref=0x%x, scanAccPtr=%d",
- sp.p->scanApiBlockref,
- sp.p->scanAccPtr);
- infoEvent(" copyptr=%d, ailen=%d, complOps=%d, concurrOps=%d",
- sp.p->copyPtr,
- sp.p->scanAiLength,
- sp.p->m_curr_batch_size_rows,
- sp.p->m_max_batch_size_rows);
- infoEvent(" errCnt=%d, localFid=%d, schV=%d",
- sp.p->scanErrorCounter,
- sp.p->scanLocalFragid,
- sp.p->scanSchemaVersion);
- infoEvent(" stpid=%d, flag=%d, lhold=%d, lmode=%d, num=%d",
- sp.p->scanStoredProcId,
- sp.p->scanFlag,
- sp.p->scanLockHold,
- sp.p->scanLockMode,
- sp.p->scanNumber);
- infoEvent(" relCount=%d, TCwait=%d, TCRec=%d, KIflag=%d",
- sp.p->scanReleaseCounter,
- sp.p->scanTcWaiting,
- sp.p->scanTcrec,
- sp.p->scanKeyinfoFlag);
- return;
- }
- if(dumpState->args[0] == DumpStateOrd::LqhDumpLcpState){
- infoEvent("== LQH LCP STATE ==");
- infoEvent(" clcpCompletedState=%d, c_lcpId=%d, cnoOfFragsCheckpointed=%d",
- clcpCompletedState,
- c_lcpId,
- cnoOfFragsCheckpointed);
- LcpRecordPtr TlcpPtr;
- // Print information about the current local checkpoint
- TlcpPtr.i = 0;
- ptrAss(TlcpPtr, lcpRecord);
- infoEvent(" lcpState=%d firstLcpLocTup=%d firstLcpLocAcc=%d",
- TlcpPtr.p->lcpState,
- TlcpPtr.p->firstLcpLocTup,
- TlcpPtr.p->firstLcpLocAcc);
- infoEvent(" lcpAccptr=%d lastFragmentFlag=%d",
- TlcpPtr.p->lcpAccptr,
- TlcpPtr.p->lastFragmentFlag);
- infoEvent("currentFragment.fragPtrI=%d",
- TlcpPtr.p->currentFragment.fragPtrI);
- infoEvent("currentFragment.lcpFragOrd.tableId=%d",
- TlcpPtr.p->currentFragment.lcpFragOrd.tableId);
- infoEvent(" lcpQueued=%d reportEmpty=%d",
- TlcpPtr.p->lcpQueued,
- TlcpPtr.p->reportEmpty);
- char buf[8*_NDB_NODE_BITMASK_SIZE+1];
- infoEvent(" m_EMPTY_LCP_REQ=%d",
- TlcpPtr.p->m_EMPTY_LCP_REQ.getText(buf));
-
- return;
- }
- }//Dblqh::execDUMP_STATE_ORD()
- void Dblqh::execSET_VAR_REQ(Signal* signal)
- {
- #if 0
- SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0];
- ConfigParamId var = setVarReq->variable();
- switch (var) {
- case NoOfConcurrentCheckpointsAfterRestart:
- sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB);
- break;
- case NoOfConcurrentCheckpointsDuringRestart:
- // Valid only during start so value not set.
- sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB);
- break;
- default:
- sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB);
- } // switch
- #endif
- }//execSET_VAR_REQ()
- /* **************************************************************** */
- /* ---------------------------------------------------------------- */
- /* ---------------------- TRIGGER HANDLING ------------------------ */
- /* ---------------------------------------------------------------- */
- /* */
- /* All trigger signals from TRIX are forwarded top TUP */
- /* ---------------------------------------------------------------- */
- /* **************************************************************** */
- // Trigger signals
- void
- Dblqh::execCREATE_TRIG_REQ(Signal* signal)
- {
- jamEntry();
- NodeId myNodeId = getOwnNodeId();
- BlockReference tupref = calcTupBlockRef(myNodeId);
- sendSignal(tupref, GSN_CREATE_TRIG_REQ, signal, CreateTrigReq::SignalLength, JBB);
- }
- void
- Dblqh::execCREATE_TRIG_CONF(Signal* signal)
- {
- jamEntry();
- NodeId myNodeId = getOwnNodeId();
- BlockReference dictref = calcDictBlockRef(myNodeId);
- sendSignal(dictref, GSN_CREATE_TRIG_CONF, signal, CreateTrigConf::SignalLength, JBB);
- }
- void
- Dblqh::execCREATE_TRIG_REF(Signal* signal)
- {
- jamEntry();
- NodeId myNodeId = getOwnNodeId();
- BlockReference dictref = calcDictBlockRef(myNodeId);
- sendSignal(dictref, GSN_CREATE_TRIG_REF, signal, CreateTrigRef::SignalLength, JBB);
- }
- void
- Dblqh::execDROP_TRIG_REQ(Signal* signal)
- {
- jamEntry();
- NodeId myNodeId = getOwnNodeId();
- BlockReference tupref = calcTupBlockRef(myNodeId);
- sendSignal(tupref, GSN_DROP_TRIG_REQ, signal, DropTrigReq::SignalLength, JBB);
- }
- void
- Dblqh::execDROP_TRIG_CONF(Signal* signal)
- {
- jamEntry();
- NodeId myNodeId = getOwnNodeId();
- BlockReference dictref = calcDictBlockRef(myNodeId);
- sendSignal(dictref, GSN_DROP_TRIG_CONF, signal, DropTrigConf::SignalLength, JBB);
- }
- void
- Dblqh::execDROP_TRIG_REF(Signal* signal)
- {
- jamEntry();
- NodeId myNodeId = getOwnNodeId();
- BlockReference dictref = calcDictBlockRef(myNodeId);
- sendSignal(dictref, GSN_DROP_TRIG_REF, signal, DropTrigRef::SignalLength, JBB);
- }
- Uint32 Dblqh::calcPageCheckSum(LogPageRecordPtr logP){
- Uint32 checkSum = 37;
- #ifdef VM_TRACE
- for (Uint32 i = (ZPOS_CHECKSUM+1); i<ZPAGE_SIZE; i++)
- checkSum = logP.p->logPageWord[i] ^ checkSum;
- #endif
- return checkSum;
- }
- void Dblqh::writeDbgInfoPageHeader(LogPageRecordPtr logP, Uint32 place,
- Uint32 pageNo, Uint32 wordWritten)
- {
- logP.p->logPageWord[ZPOS_LOG_TIMER]= logPartPtr.p->logTimer;
- logP.p->logPageWord[ZPOS_PREV_PAGE_NO]= logP.p->logPageWord[ZPOS_PAGE_NO];
- logP.p->logPageWord[ZPOS_PAGE_I]= logP.i;
- logP.p->logPageWord[ZPOS_PLACE_WRITTEN_FROM]= place;
- logP.p->logPageWord[ZPOS_PAGE_NO]= pageNo;
- logP.p->logPageWord[ZPOS_PAGE_FILE_NO]= logFilePtr.p->fileNo;
- logP.p->logPageWord[ZPOS_WORD_WRITTEN]= wordWritten;
- logP.p->logPageWord[ZPOS_IN_WRITING]= 1;
- }