DbdihMain.cpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:494k
- createReplica->logNodeId[logNode] = fblFoundReplicaPtr.p->procNode;
- createReplica->logStartGci[logNode] = startGci;
- if (fblStopGci >= stopGci) {
- jam();
- createReplica->logStopGci[logNode] = stopGci;
- } else {
- jam();
- createReplica->logStopGci[logNode] = fblStopGci;
- }//if
- }//if
- return fblStopGci != 0;
- }//Dbdih::findBestLogNode()
- Uint32 Dbdih::findLogInterval(ConstPtr<ReplicaRecord> replicaPtr,
- Uint32 startGci)
- {
- ndbrequire(replicaPtr.p->noCrashedReplicas <= 8);
- Uint32 loopLimit = replicaPtr.p->noCrashedReplicas + 1;
- for (Uint32 i = 0; i < loopLimit; i++) {
- jam();
- if (replicaPtr.p->createGci[i] <= startGci) {
- if (replicaPtr.p->replicaLastGci[i] >= startGci) {
- jam();
- return replicaPtr.p->replicaLastGci[i];
- }//if
- }//if
- }//for
- return 0;
- }//Dbdih::findLogInterval()
- /*************************************************************************/
- /* */
- /* MODULE: FIND THE MINIMUM GCI THAT THIS NODE HAS LOG RECORDS FOR.*/
- /*************************************************************************/
- void Dbdih::findMinGci(ReplicaRecordPtr fmgReplicaPtr,
- Uint32& keepGci,
- Uint32& oldestRestorableGci)
- {
- Uint32 nextLcpNo;
- Uint32 lcpNo;
- for (Uint32 i = 0; i < MAX_LCP_STORED; i++) {
- jam();
- if ((fmgReplicaPtr.p->lcpStatus[i] == ZVALID) &&
- ((fmgReplicaPtr.p->lcpId[i] + MAX_LCP_STORED) <= (SYSFILE->latestLCP_ID + 1))) {
- jam();
- /*--------------------------------------------------------------------*/
- // We invalidate the checkpoint we are preparing to overwrite.
- // The LCP id is still the old lcp id,
- // this is the reason of comparing with lcpId + 1.
- /*---------------------------------------------------------------------*/
- fmgReplicaPtr.p->lcpStatus[i] = ZINVALID;
- }//if
- }//for
- keepGci = (Uint32)-1;
- oldestRestorableGci = 0;
- nextLcpNo = fmgReplicaPtr.p->nextLcp;
- lcpNo = fmgReplicaPtr.p->nextLcp;
- do {
- ndbrequire(lcpNo < MAX_LCP_STORED);
- if (fmgReplicaPtr.p->lcpStatus[lcpNo] == ZVALID &&
- fmgReplicaPtr.p->maxGciStarted[lcpNo] <= coldgcp)
- {
- jam();
- keepGci = fmgReplicaPtr.p->maxGciCompleted[lcpNo];
- oldestRestorableGci = fmgReplicaPtr.p->maxGciStarted[lcpNo];
- ndbrequire(((int)oldestRestorableGci) >= 0);
- return;
- } else {
- jam();
- if (fmgReplicaPtr.p->createGci[0] == fmgReplicaPtr.p->initialGci) {
- jam();
- /*-------------------------------------------------------------------
- * WE CAN STILL RESTORE THIS REPLICA WITHOUT ANY LOCAL CHECKPOINTS BY
- * ONLY USING THE LOG. IF THIS IS NOT POSSIBLE THEN WE REPORT THE LAST
- * VALID LOCAL CHECKPOINT AS THE MINIMUM GCI RECOVERABLE.
- *-----------------------------------------------------------------*/
- keepGci = fmgReplicaPtr.p->createGci[0];
- }//if
- }//if
- lcpNo = prevLcpNo(lcpNo);
- } while (lcpNo != nextLcpNo);
- return;
- }//Dbdih::findMinGci()
- bool Dbdih::findStartGci(ConstPtr<ReplicaRecord> replicaPtr,
- Uint32 stopGci,
- Uint32& startGci,
- Uint32& lcpNo)
- {
- lcpNo = replicaPtr.p->nextLcp;
- const Uint32 startLcpNo = lcpNo;
- do {
- lcpNo = prevLcpNo(lcpNo);
- ndbrequire(lcpNo < MAX_LCP_STORED);
- if (replicaPtr.p->lcpStatus[lcpNo] == ZVALID) {
- if (replicaPtr.p->maxGciStarted[lcpNo] < stopGci) {
- jam();
- /* ----------------------------------------------------------------- */
- /* WE HAVE FOUND A USEFUL LOCAL CHECKPOINT THAT CAN BE USED FOR */
- /* RESTARTING THIS FRAGMENT REPLICA. */
- /* ----------------------------------------------------------------- */
- startGci = replicaPtr.p->maxGciCompleted[lcpNo] + 1;
- return true;
- }
- }
- } while (lcpNo != startLcpNo);
- /* --------------------------------------------------------------------- */
- /* NO VALID LOCAL CHECKPOINT WAS AVAILABLE. WE WILL ADD THE */
- /* FRAGMENT. THUS THE NEXT LCP MUST BE SET TO ZERO. */
- /* WE MUST EXECUTE THE LOG FROM THE INITIAL GLOBAL CHECKPOINT WHEN */
- /* THE TABLE WAS CREATED. */
- /* --------------------------------------------------------------------- */
- startGci = replicaPtr.p->initialGci;
- ndbrequire(replicaPtr.p->nextLcp == 0);
- return false;
- }//Dbdih::findStartGci()
- /**************************************************************************/
- /* ---------------------------------------------------------------------- */
- /* FIND A TAKE OVER REPLICA WHICH IS TO BE STARTED OR COMMITTED WHEN*/
- /* TAKING OVER A FAILED NODE. */
- /* ---------------------------------------------------------------------- */
- /*************************************************************************/
- void Dbdih::findToReplica(TakeOverRecord* regTakeOver,
- Uint32 replicaType,
- FragmentstorePtr fragPtr,
- ReplicaRecordPtr& ftrReplicaPtr)
- {
- switch (replicaType) {
- case CreateFragReq::STORED:
- case CreateFragReq::COMMIT_STORED:
- /* ----------------------------------------------------------------------*/
- /* HERE WE SEARCH FOR STORED REPLICAS. THE REPLICA MUST BE STORED IN THE */
- /* SECTION FOR OLD STORED REPLICAS SINCE WE HAVE NOT TAKEN OVER YET. */
- /* ----------------------------------------------------------------------*/
- ftrReplicaPtr.i = fragPtr.p->oldStoredReplicas;
- while (ftrReplicaPtr.i != RNIL) {
- ptrCheckGuard(ftrReplicaPtr, creplicaFileSize, replicaRecord);
- if (ftrReplicaPtr.p->procNode == regTakeOver->toStartingNode) {
- jam();
- return;
- } else {
- if (ftrReplicaPtr.p->procNode == regTakeOver->toFailedNode) {
- jam();
- return;
- } else {
- jam();
- ftrReplicaPtr.i = ftrReplicaPtr.p->nextReplica;
- }//if
- }//if
- }//while
- break;
- default:
- ndbrequire(false);
- break;
- }//switch
- }//Dbdih::findToReplica()
- void Dbdih::initCommonData()
- {
- c_blockCommit = false;
- c_blockCommitNo = 0;
- c_createFragmentLock = RNIL;
- c_endToLock = RNIL;
- cfailurenr = 1;
- cfirstAliveNode = RNIL;
- cfirstDeadNode = RNIL;
- cfirstVerifyQueue = RNIL;
- cgckptflag = false;
- cgcpDelay = 0;
- cgcpMasterTakeOverState = GMTOS_IDLE;
- cgcpOrderBlocked = 0;
- cgcpParticipantState = GCP_PARTICIPANT_READY;
- cgcpSameCounter = 0;
- cgcpStartCounter = 0;
- cgcpStatus = GCP_READY;
- clastVerifyQueue = RNIL;
- c_lcpMasterTakeOverState.set(LMTOS_IDLE, __LINE__);
- c_lcpState.clcpDelay = 0;
- c_lcpState.lcpStart = ZIDLE;
- c_lcpState.lcpStartGcp = 0;
- c_lcpState.setLcpStatus(LCP_STATUS_IDLE, __LINE__);
- c_lcpState.currentFragment.tableId = 0;
- c_lcpState.currentFragment.fragmentId = 0;
- c_lcpState.noOfLcpFragRepOutstanding = 0;
- c_lcpState.keepGci = 0;
- c_lcpState.oldestRestorableGci = 0;
- c_lcpState.ctcCounter = 0;
- c_lcpState.ctimer = 0;
- c_lcpState.immediateLcpStart = false;
- c_lcpState.m_MASTER_LCPREQ_Received = false;
-
- cmasterdihref = 0;
- cmasterNodeId = 0;
- cmasterState = MASTER_IDLE;
- cmasterTakeOverNode = 0;
- cnewgcp = 0;
- cnoHotSpare = 0;
- cnoOfActiveTables = 0;
- cnoOfNodeGroups = 0;
- cnoReplicas = 0;
- coldgcp = 0;
- coldGcpId = 0;
- coldGcpStatus = cgcpStatus;
- con_lineNodes = 0;
- creceivedfrag = 0;
- crestartGci = 0;
- crestartInfoFile[0] = RNIL;
- crestartInfoFile[1] = RNIL;
- cstartGcpNow = false;
- cstartPhase = 0;
- c_startToLock = RNIL;
- cstarttype = (Uint32)-1;
- csystemnodes = 0;
- c_updateToLock = RNIL;
- currentgcp = 0;
- cverifyQueueCounter = 0;
- cwaitLcpSr = false;
- nodeResetStart();
- c_nodeStartMaster.wait = ZFALSE;
- memset(&sysfileData[0], 0, sizeof(sysfileData));
- const ndb_mgm_configuration_iterator * p =
- theConfiguration.getOwnConfigIterator();
- ndbrequire(p != 0);
-
- c_lcpState.clcpDelay = 20;
- ndb_mgm_get_int_parameter(p, CFG_DB_LCP_INTERVAL, &c_lcpState.clcpDelay);
- c_lcpState.clcpDelay = c_lcpState.clcpDelay > 31 ? 31 : c_lcpState.clcpDelay;
-
- cminHotSpareNodes = 0;
- //ndb_mgm_get_int_parameter(p, CFG_DB_MIN_HOT_SPARES, &cminHotSpareNodes);
- cminHotSpareNodes = cminHotSpareNodes > 2 ? 2 : cminHotSpareNodes;
- cnoReplicas = 1;
- ndb_mgm_get_int_parameter(p, CFG_DB_NO_REPLICAS, &cnoReplicas);
- cnoReplicas = cnoReplicas > 4 ? 4 : cnoReplicas;
- cgcpDelay = 2000;
- ndb_mgm_get_int_parameter(p, CFG_DB_GCP_INTERVAL, &cgcpDelay);
- cgcpDelay = cgcpDelay > 60000 ? 60000 : (cgcpDelay < 10 ? 10 : cgcpDelay);
- }//Dbdih::initCommonData()
- void Dbdih::initFragstore(FragmentstorePtr fragPtr)
- {
- fragPtr.p->storedReplicas = RNIL;
- fragPtr.p->oldStoredReplicas = RNIL;
-
- fragPtr.p->noStoredReplicas = 0;
- fragPtr.p->noOldStoredReplicas = 0;
- fragPtr.p->fragReplicas = 0;
- fragPtr.p->preferredPrimary = 0;
- for (Uint32 i = 0; i < MAX_REPLICAS; i++)
- fragPtr.p->activeNodes[i] = 0;
-
- fragPtr.p->noLcpReplicas = 0;
- fragPtr.p->distributionKey = 0;
- }//Dbdih::initFragstore()
- /*************************************************************************/
- /* */
- /* MODULE: INIT_RESTART_INFO */
- /* DESCRIPTION: INITIATE RESTART INFO VARIABLE AND VARIABLES FOR */
- /* GLOBAL CHECKPOINTS. */
- /*************************************************************************/
- void Dbdih::initRestartInfo()
- {
- Uint32 i;
- for (i = 0; i < MAX_NDB_NODES; i++) {
- SYSFILE->lastCompletedGCI[i] = 0;
- }//for
- NodeRecordPtr nodePtr;
- nodePtr.i = cfirstAliveNode;
- do {
- jam();
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- SYSFILE->lastCompletedGCI[nodePtr.i] = 1;
- /* FIRST GCP = 1 ALREADY SET BY LQH */
- nodePtr.i = nodePtr.p->nextNode;
- } while (nodePtr.i != RNIL);
- coldgcp = 1;
- currentgcp = 2;
- cnewgcp = 2;
- crestartGci = 1;
- SYSFILE->keepGCI = 1;
- SYSFILE->oldestRestorableGCI = 1;
- SYSFILE->newestRestorableGCI = 1;
- SYSFILE->systemRestartBits = 0;
- for (i = 0; i < NodeBitmask::Size; i++) {
- SYSFILE->lcpActive[0] = 0;
- }//for
- for (i = 0; i < Sysfile::TAKE_OVER_SIZE; i++) {
- SYSFILE->takeOver[i] = 0;
- }//for
- Sysfile::setInitialStartOngoing(SYSFILE->systemRestartBits);
- }//Dbdih::initRestartInfo()
- /*--------------------------------------------------------------------*/
- /* NODE GROUP BITS ARE INITIALISED BEFORE THIS. */
- /* NODE ACTIVE BITS ARE INITIALISED BEFORE THIS. */
- /*--------------------------------------------------------------------*/
- /*************************************************************************/
- /* */
- /* MODULE: INIT_RESTORABLE_GCI_FILES */
- /* DESCRIPTION: THE SUBROUTINE SETS UP THE FILES THAT REFERS TO THE*/
- /* FILES THAT KEEP THE VARIABLE CRESTART_INFO */
- /*************************************************************************/
- void Dbdih::initRestorableGciFiles()
- {
- Uint32 tirgTmp;
- FileRecordPtr filePtr;
- seizeFile(filePtr);
- filePtr.p->tabRef = RNIL;
- filePtr.p->fileType = FileRecord::GCP_FILE;
- filePtr.p->reqStatus = FileRecord::IDLE;
- filePtr.p->fileStatus = FileRecord::CLOSED;
- crestartInfoFile[0] = filePtr.i;
- filePtr.p->fileName[0] = (Uint32)-1; /* T DIRECTORY NOT USED */
- filePtr.p->fileName[1] = (Uint32)-1; /* F DIRECTORY NOT USED */
- filePtr.p->fileName[2] = (Uint32)-1; /* S PART IGNORED */
- tirgTmp = 1; /* FILE NAME VERSION 1 */
- tirgTmp = (tirgTmp << 8) + 6; /* .SYSFILE */
- tirgTmp = (tirgTmp << 8) + 1; /* D1 DIRECTORY */
- tirgTmp = (tirgTmp << 8) + 0; /* P0 FILE NAME */
- filePtr.p->fileName[3] = tirgTmp;
- /* --------------------------------------------------------------------- */
- /* THE NAME BECOMES /D1/DBDICT/S0.SYSFILE */
- /* --------------------------------------------------------------------- */
- seizeFile(filePtr);
- filePtr.p->tabRef = RNIL;
- filePtr.p->fileType = FileRecord::GCP_FILE;
- filePtr.p->reqStatus = FileRecord::IDLE;
- filePtr.p->fileStatus = FileRecord::CLOSED;
- crestartInfoFile[1] = filePtr.i;
- filePtr.p->fileName[0] = (Uint32)-1; /* T DIRECTORY NOT USED */
- filePtr.p->fileName[1] = (Uint32)-1; /* F DIRECTORY NOT USED */
- filePtr.p->fileName[2] = (Uint32)-1; /* S PART IGNORED */
- tirgTmp = 1; /* FILE NAME VERSION 1 */
- tirgTmp = (tirgTmp << 8) + 6; /* .SYSFILE */
- tirgTmp = (tirgTmp << 8) + 2; /* D1 DIRECTORY */
- tirgTmp = (tirgTmp << 8) + 0; /* P0 FILE NAME */
- filePtr.p->fileName[3] = tirgTmp;
- /* --------------------------------------------------------------------- */
- /* THE NAME BECOMES /D2/DBDICT/P0.SYSFILE */
- /* --------------------------------------------------------------------- */
- }//Dbdih::initRestorableGciFiles()
- void Dbdih::initTable(TabRecordPtr tabPtr)
- {
- tabPtr.p->noOfFragChunks = 0;
- tabPtr.p->method = TabRecord::NOTDEFINED;
- tabPtr.p->tabStatus = TabRecord::TS_IDLE;
- tabPtr.p->noOfWords = 0;
- tabPtr.p->noPages = 0;
- tabPtr.p->tabLcpStatus = TabRecord::TLS_COMPLETED;
- tabPtr.p->tabCopyStatus = TabRecord::CS_IDLE;
- tabPtr.p->tabUpdateState = TabRecord::US_IDLE;
- tabPtr.p->noOfBackups = 0;
- tabPtr.p->kvalue = 0;
- tabPtr.p->hashpointer = (Uint32)-1;
- tabPtr.p->mask = 0;
- tabPtr.p->storedTable = 1;
- tabPtr.p->tabErrorCode = 0;
- tabPtr.p->schemaVersion = (Uint32)-1;
- tabPtr.p->tabRemoveNode = RNIL;
- tabPtr.p->totalfragments = (Uint32)-1;
- tabPtr.p->connectrec = RNIL;
- tabPtr.p->tabFile[0] = RNIL;
- tabPtr.p->tabFile[1] = RNIL;
- tabPtr.p->m_dropTab.tabUserRef = 0;
- tabPtr.p->m_dropTab.tabUserPtr = RNIL;
- Uint32 i;
- for (i = 0; i < MAX_NDB_NODES; i++) {
- tabPtr.p->startFid[i] = RNIL;
- }//for
- for (i = 0; i < 8; i++) {
- tabPtr.p->pageRef[i] = RNIL;
- }//for
- tabPtr.p->tableType = DictTabInfo::UndefTableType;
- }//Dbdih::initTable()
- /*************************************************************************/
- /* */
- /* MODULE: INIT_TABLE_FILES */
- /* DESCRIPTION: THE SUBROUTINE SETS UP THE FILES THAT REFERS TO THE*/
- /* FILES THAT KEEP THE TABLE FRAGMENTATION DESCRIPTION. */
- /*************************************************************************/
- void Dbdih::initTableFile(TabRecordPtr tabPtr)
- {
- Uint32 titfTmp;
- FileRecordPtr filePtr;
- seizeFile(filePtr);
- filePtr.p->tabRef = tabPtr.i;
- filePtr.p->fileType = FileRecord::TABLE_FILE;
- filePtr.p->reqStatus = FileRecord::IDLE;
- filePtr.p->fileStatus = FileRecord::CLOSED;
- tabPtr.p->tabFile[0] = filePtr.i;
- filePtr.p->fileName[0] = (Uint32)-1; /* T DIRECTORY NOT USED */
- filePtr.p->fileName[1] = (Uint32)-1; /* F DIRECTORY NOT USED */
- filePtr.p->fileName[2] = tabPtr.i; /* Stid FILE NAME */
- titfTmp = 1; /* FILE NAME VERSION 1 */
- titfTmp = (titfTmp << 8) + 3; /* .FRAGLIST */
- titfTmp = (titfTmp << 8) + 1; /* D1 DIRECTORY */
- titfTmp = (titfTmp << 8) + 255; /* P PART IGNORED */
- filePtr.p->fileName[3] = titfTmp;
- /* --------------------------------------------------------------------- */
- /* THE NAME BECOMES /D1/DBDICT/Stid.FRAGLIST */
- /* --------------------------------------------------------------------- */
- seizeFile(filePtr);
- filePtr.p->tabRef = tabPtr.i;
- filePtr.p->fileType = FileRecord::TABLE_FILE;
- filePtr.p->reqStatus = FileRecord::IDLE;
- filePtr.p->fileStatus = FileRecord::CLOSED;
- tabPtr.p->tabFile[1] = filePtr.i;
- filePtr.p->fileName[0] = (Uint32)-1; /* T DIRECTORY NOT USED */
- filePtr.p->fileName[1] = (Uint32)-1; /* F DIRECTORY NOT USED */
- filePtr.p->fileName[2] = tabPtr.i; /* Stid FILE NAME */
- titfTmp = 1; /* FILE NAME VERSION 1 */
- titfTmp = (titfTmp << 8) + 3; /* .FRAGLIST */
- titfTmp = (titfTmp << 8) + 2; /* D2 DIRECTORY */
- titfTmp = (titfTmp << 8) + 255; /* P PART IGNORED */
- filePtr.p->fileName[3] = titfTmp;
- /* --------------------------------------------------------------------- */
- /* THE NAME BECOMES /D2/DBDICT/Stid.FRAGLIST */
- /* --------------------------------------------------------------------- */
- }//Dbdih::initTableFile()
- void Dbdih::initialiseRecordsLab(Signal* signal,
- Uint32 stepNo, Uint32 retRef, Uint32 retData)
- {
- switch (stepNo) {
- case 0:
- jam();
- initCommonData();
- break;
- case 1:{
- ApiConnectRecordPtr apiConnectptr;
- jam();
- /******** INTIALIZING API CONNECT RECORDS ********/
- for (apiConnectptr.i = 0; apiConnectptr.i < capiConnectFileSize; apiConnectptr.i++) {
- refresh_watch_dog();
- ptrAss(apiConnectptr, apiConnectRecord);
- apiConnectptr.p->nextApi = RNIL;
- }//for
- jam();
- break;
- }
- case 2:{
- ConnectRecordPtr connectPtr;
- jam();
- /****** CONNECT ******/
- for (connectPtr.i = 0; connectPtr.i < cconnectFileSize; connectPtr.i++) {
- refresh_watch_dog();
- ptrAss(connectPtr, connectRecord);
- connectPtr.p->userpointer = RNIL;
- connectPtr.p->userblockref = ZNIL;
- connectPtr.p->connectState = ConnectRecord::FREE;
- connectPtr.p->table = RNIL;
- connectPtr.p->nfConnect = connectPtr.i + 1;
- }//for
- connectPtr.i = cconnectFileSize - 1;
- ptrAss(connectPtr, connectRecord);
- connectPtr.p->nfConnect = RNIL;
- cfirstconnect = 0;
- break;
- }
- case 3:
- {
- FileRecordPtr filePtr;
- jam();
- /******** INTIALIZING FILE RECORDS ********/
- for (filePtr.i = 0; filePtr.i < cfileFileSize; filePtr.i++) {
- ptrAss(filePtr, fileRecord);
- filePtr.p->nextFile = filePtr.i + 1;
- filePtr.p->fileStatus = FileRecord::CLOSED;
- filePtr.p->reqStatus = FileRecord::IDLE;
- }//for
- filePtr.i = cfileFileSize - 1;
- ptrAss(filePtr, fileRecord);
- filePtr.p->nextFile = RNIL;
- cfirstfreeFile = 0;
- initRestorableGciFiles();
- break;
- }
- case 4:
- jam();
- initialiseFragstore();
- break;
- case 5:
- {
- jam();
- /******* NODE GROUP RECORD ******/
- /******* NODE RECORD ******/
- NodeGroupRecordPtr loopNGPtr;
- for (loopNGPtr.i = 0; loopNGPtr.i < MAX_NDB_NODES; loopNGPtr.i++) {
- ptrAss(loopNGPtr, nodeGroupRecord);
- loopNGPtr.p->nodesInGroup[0] = RNIL;
- loopNGPtr.p->nodesInGroup[1] = RNIL;
- loopNGPtr.p->nodesInGroup[2] = RNIL;
- loopNGPtr.p->nodesInGroup[3] = RNIL;
- loopNGPtr.p->nextReplicaNode = 0;
- loopNGPtr.p->nodeCount = 0;
- loopNGPtr.p->activeTakeOver = false;
- }//for
- NodeRecordPtr nodePtr;
- for (nodePtr.i = 0; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) {
- ptrAss(nodePtr, nodeRecord);
- new (nodePtr.p) NodeRecord();
- }//for
- break;
- }
- case 6:
- {
- PageRecordPtr pagePtr;
- jam();
- /******* PAGE RECORD ******/
- for (pagePtr.i = 0; pagePtr.i < cpageFileSize; pagePtr.i++) {
- refresh_watch_dog();
- ptrAss(pagePtr, pageRecord);
- pagePtr.p->nextfreepage = pagePtr.i + 1;
- }//for
- pagePtr.i = cpageFileSize - 1;
- ptrAss(pagePtr, pageRecord);
- pagePtr.p->nextfreepage = RNIL;
- cfirstfreepage = 0;
- break;
- }
- case 7:
- {
- ReplicaRecordPtr initReplicaPtr;
- jam();
- /******* REPLICA RECORD ******/
- for (initReplicaPtr.i = 0; initReplicaPtr.i < creplicaFileSize;
- initReplicaPtr.i++) {
- refresh_watch_dog();
- ptrAss(initReplicaPtr, replicaRecord);
- initReplicaPtr.p->lcpIdStarted = 0;
- initReplicaPtr.p->lcpOngoingFlag = false;
- initReplicaPtr.p->nextReplica = initReplicaPtr.i + 1;
- }//for
- initReplicaPtr.i = creplicaFileSize - 1;
- ptrAss(initReplicaPtr, replicaRecord);
- initReplicaPtr.p->nextReplica = RNIL;
- cnoFreeReplicaRec = creplicaFileSize;
- cfirstfreeReplica = 0;
- break;
- }
- case 8:
- {
- TabRecordPtr loopTabptr;
- jam();
- /********* TAB-DESCRIPTOR ********/
- for (loopTabptr.i = 0; loopTabptr.i < ctabFileSize; loopTabptr.i++) {
- ptrAss(loopTabptr, tabRecord);
- refresh_watch_dog();
- initTable(loopTabptr);
- }//for
- break;
- }
- case 9:
- {
- TakeOverRecordPtr takeOverPtr;
- jam();
- cfirstfreeTakeOver = RNIL;
- for (takeOverPtr.i = 0; takeOverPtr.i < MAX_NDB_NODES; takeOverPtr.i++) {
- ptrAss(takeOverPtr, takeOverRecord);
- initTakeOver(takeOverPtr);
- releaseTakeOver(takeOverPtr.i);
- }//for
- 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
- jam();
- /* ---------------------------------------------------------------------- */
- /* SEND REAL-TIME BREAK DURING INIT OF VARIABLES DURING SYSTEM RESTART. */
- /* ---------------------------------------------------------------------- */
- signal->theData[0] = DihContinueB::ZINITIALISE_RECORDS;
- signal->theData[1] = stepNo + 1;
- signal->theData[2] = retRef;
- signal->theData[3] = retData;
- sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
- }//Dbdih::initialiseRecordsLab()
- /*************************************************************************/
- /* INSERT THE NODE INTO THE LINKED LIST OF NODES INVOLVED ALL */
- /* DISTRIBUTED PROTOCOLS (EXCEPT GCP PROTOCOL THAT USES THE DIH */
- /* LINKED LIST INSTEAD). */
- /*************************************************************************/
- void Dbdih::insertAlive(NodeRecordPtr newNodePtr)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = cfirstAliveNode;
- if (nodePtr.i == RNIL) {
- jam();
- cfirstAliveNode = newNodePtr.i;
- } else {
- do {
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- if (nodePtr.p->nextNode == RNIL) {
- jam();
- nodePtr.p->nextNode = newNodePtr.i;
- break;
- } else {
- jam();
- nodePtr.i = nodePtr.p->nextNode;
- }//if
- } while (1);
- }//if
- newNodePtr.p->nextNode = RNIL;
- }//Dbdih::insertAlive()
- void Dbdih::insertBackup(FragmentstorePtr fragPtr, Uint32 nodeId)
- {
- for (Uint32 i = fragPtr.p->fragReplicas; i > 1; i--) {
- jam();
- ndbrequire(i < MAX_REPLICAS && i > 0);
- fragPtr.p->activeNodes[i] = fragPtr.p->activeNodes[i - 1];
- }//for
- fragPtr.p->activeNodes[1] = nodeId;
- fragPtr.p->fragReplicas++;
- }//Dbdih::insertBackup()
- void Dbdih::insertDeadNode(NodeRecordPtr newNodePtr)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = cfirstDeadNode;
- if (nodePtr.i == RNIL) {
- jam();
- cfirstDeadNode = newNodePtr.i;
- } else {
- do {
- jam();
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- if (nodePtr.p->nextNode == RNIL) {
- jam();
- nodePtr.p->nextNode = newNodePtr.i;
- break;
- } else {
- jam();
- nodePtr.i = nodePtr.p->nextNode;
- }//if
- } while (1);
- }//if
- newNodePtr.p->nextNode = RNIL;
- }//Dbdih::insertDeadNode()
- void Dbdih::linkOldStoredReplica(FragmentstorePtr fragPtr,
- ReplicaRecordPtr replicatePtr)
- {
- ReplicaRecordPtr losReplicaPtr;
- replicatePtr.p->nextReplica = RNIL;
- fragPtr.p->noOldStoredReplicas++;
- losReplicaPtr.i = fragPtr.p->oldStoredReplicas;
- if (losReplicaPtr.i == RNIL) {
- jam();
- fragPtr.p->oldStoredReplicas = replicatePtr.i;
- return;
- }//if
- ptrCheckGuard(losReplicaPtr, creplicaFileSize, replicaRecord);
- while (losReplicaPtr.p->nextReplica != RNIL) {
- jam();
- losReplicaPtr.i = losReplicaPtr.p->nextReplica;
- ptrCheckGuard(losReplicaPtr, creplicaFileSize, replicaRecord);
- }//if
- losReplicaPtr.p->nextReplica = replicatePtr.i;
- }//Dbdih::linkOldStoredReplica()
- void Dbdih::linkStoredReplica(FragmentstorePtr fragPtr,
- ReplicaRecordPtr replicatePtr)
- {
- ReplicaRecordPtr lsrReplicaPtr;
- fragPtr.p->noStoredReplicas++;
- replicatePtr.p->nextReplica = RNIL;
- lsrReplicaPtr.i = fragPtr.p->storedReplicas;
- if (fragPtr.p->storedReplicas == RNIL) {
- jam();
- fragPtr.p->storedReplicas = replicatePtr.i;
- return;
- }//if
- ptrCheckGuard(lsrReplicaPtr, creplicaFileSize, replicaRecord);
- while (lsrReplicaPtr.p->nextReplica != RNIL) {
- jam();
- lsrReplicaPtr.i = lsrReplicaPtr.p->nextReplica;
- ptrCheckGuard(lsrReplicaPtr, creplicaFileSize, replicaRecord);
- }//if
- lsrReplicaPtr.p->nextReplica = replicatePtr.i;
- }//Dbdih::linkStoredReplica()
- /*************************************************************************/
- /* MAKE NODE GROUPS BASED ON THE LIST OF NODES RECEIVED FROM CNTR */
- /*************************************************************************/
- void Dbdih::makeNodeGroups(Uint32 nodeArray[])
- {
- NodeRecordPtr mngNodeptr;
- Uint32 tmngNode;
- Uint32 tmngNodeGroup;
- Uint32 tmngReplica;
- Uint32 tmngLimit;
- Uint32 i;
- /**-----------------------------------------------------------------------
- * ASSIGN ALL ACTIVE NODES INTO NODE GROUPS. HOT SPARE NODES ARE ASSIGNED
- * TO NODE GROUP ZNIL
- *-----------------------------------------------------------------------*/
- tmngNodeGroup = 0;
- tmngReplica = 0;
- tmngLimit = csystemnodes - cnoHotSpare;
- ndbrequire(tmngLimit < MAX_NDB_NODES);
- for (i = 0; i < tmngLimit; i++) {
- NodeGroupRecordPtr NGPtr;
- jam();
- tmngNode = nodeArray[i];
- mngNodeptr.i = tmngNode;
- ptrCheckGuard(mngNodeptr, MAX_NDB_NODES, nodeRecord);
- mngNodeptr.p->nodeGroup = tmngNodeGroup;
- NGPtr.i = tmngNodeGroup;
- ptrCheckGuard(NGPtr, MAX_NDB_NODES, nodeGroupRecord);
- arrGuard(tmngReplica, MAX_REPLICAS);
- NGPtr.p->nodesInGroup[tmngReplica] = mngNodeptr.i;
- tmngReplica++;
- if (tmngReplica == cnoReplicas) {
- jam();
- tmngNodeGroup++;
- tmngReplica = 0;
- }//if
- }//for
- cnoOfNodeGroups = tmngNodeGroup;
- ndbrequire(csystemnodes < MAX_NDB_NODES);
- for (i = tmngLimit + 1; i < csystemnodes; i++) {
- jam();
- tmngNode = nodeArray[i];
- mngNodeptr.i = tmngNode;
- ptrCheckGuard(mngNodeptr, MAX_NDB_NODES, nodeRecord);
- mngNodeptr.p->nodeGroup = ZNIL;
- }//for
- for(i = 0; i < MAX_NDB_NODES; i++){
- jam();
- Sysfile::setNodeGroup(i, SYSFILE->nodeGroups, NO_NODE_GROUP_ID);
- }//for
- for (mngNodeptr.i = 1; mngNodeptr.i < MAX_NDB_NODES; mngNodeptr.i++) {
- jam();
- ptrAss(mngNodeptr, nodeRecord);
- if (mngNodeptr.p->nodeGroup != ZNIL) {
- jam();
- Sysfile::setNodeGroup(mngNodeptr.i, SYSFILE->nodeGroups, mngNodeptr.p->nodeGroup);
- }//if
- }//for
- }//Dbdih::makeNodeGroups()
- /**
- * On node failure QMGR asks DIH about node groups. This is
- * a direct signal (function call in same process). Input is
- * bitmask of surviving nodes. The routine is not concerned
- * about node count. Reply is one of:
- * 1) win - we can survive, and nobody else can
- * 2) lose - we cannot survive
- * 3) partition - we can survive but there could be others
- */
- void Dbdih::execCHECKNODEGROUPSREQ(Signal* signal)
- {
- jamEntry();
- CheckNodeGroups* sd = (CheckNodeGroups*)&signal->theData[0];
- bool direct = (sd->requestType & CheckNodeGroups::Direct);
- bool ok = false;
- switch(sd->requestType & ~CheckNodeGroups::Direct){
- case CheckNodeGroups::ArbitCheck:{
- ok = true;
- jam();
- unsigned missall = 0;
- unsigned haveall = 0;
- for (Uint32 i = 0; i < cnoOfNodeGroups; i++) {
- jam();
- NodeGroupRecordPtr ngPtr;
- ngPtr.i = i;
- ptrAss(ngPtr, nodeGroupRecord);
- Uint32 count = 0;
- for (Uint32 j = 0; j < ngPtr.p->nodeCount; j++) {
- jam();
- Uint32 nodeId = ngPtr.p->nodesInGroup[j];
- if (sd->mask.get(nodeId)) {
- jam();
- count++;
- }//if
- }//for
- if (count == 0) {
- jam();
- missall++;
- }//if
- if (count == ngPtr.p->nodeCount) {
- haveall++;
- }//if
- }//for
- if (missall) {
- jam();
- sd->output = CheckNodeGroups::Lose;
- } else if (haveall) {
- jam();
- sd->output = CheckNodeGroups::Win;
- } else {
- jam();
- sd->output = CheckNodeGroups::Partitioning;
- }//if
- }
- break;
- case CheckNodeGroups::GetNodeGroup:
- ok = true;
- sd->output = Sysfile::getNodeGroup(getOwnNodeId(), SYSFILE->nodeGroups);
- break;
- case CheckNodeGroups::GetNodeGroupMembers: {
- ok = true;
- Uint32 ownNodeGoup =
- Sysfile::getNodeGroup(sd->nodeId, SYSFILE->nodeGroups);
- sd->output = ownNodeGoup;
- sd->mask.clear();
- NodeGroupRecordPtr ngPtr;
- ngPtr.i = ownNodeGoup;
- ptrAss(ngPtr, nodeGroupRecord);
- for (Uint32 j = 0; j < ngPtr.p->nodeCount; j++) {
- jam();
- sd->mask.set(ngPtr.p->nodesInGroup[j]);
- }
- #if 0
- for (int i = 0; i < MAX_NDB_NODES; i++) {
- if (ownNodeGoup ==
- Sysfile::getNodeGroup(i, SYSFILE->nodeGroups)) {
- sd->mask.set(i);
- }
- }
- #endif
- }
- break;
- }
- ndbrequire(ok);
-
- if (!direct)
- sendSignal(sd->blockRef, GSN_CHECKNODEGROUPSCONF, signal,
- CheckNodeGroups::SignalLength, JBB);
- }//Dbdih::execCHECKNODEGROUPSREQ()
- void Dbdih::makePrnList(ReadNodesConf * readNodes, Uint32 nodeArray[])
- {
- cfirstAliveNode = RNIL;
- ndbrequire(con_lineNodes > 0);
- ndbrequire(csystemnodes < MAX_NDB_NODES);
- for (Uint32 i = 0; i < csystemnodes; i++) {
- NodeRecordPtr nodePtr;
- jam();
- nodePtr.i = nodeArray[i];
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- new (nodePtr.p) NodeRecord();
- if (NodeBitmask::get(readNodes->inactiveNodes, nodePtr.i) == false){
- jam();
- nodePtr.p->nodeStatus = NodeRecord::ALIVE;
- nodePtr.p->useInTransactions = true;
- nodePtr.p->copyCompleted = true;
- nodePtr.p->m_inclDihLcp = true;
- insertAlive(nodePtr);
- } else {
- jam();
- nodePtr.p->nodeStatus = NodeRecord::DEAD;
- insertDeadNode(nodePtr);
- }//if
- }//for
- }//Dbdih::makePrnList()
- /*************************************************************************/
- /* A NEW CRASHED REPLICA IS ADDED BY A NODE FAILURE. */
- /*************************************************************************/
- void Dbdih::newCrashedReplica(Uint32 nodeId, ReplicaRecordPtr ncrReplicaPtr)
- {
- /*----------------------------------------------------------------------*/
- /* SET THE REPLICA_LAST_GCI OF THE CRASHED REPLICA TO LAST GCI */
- /* EXECUTED BY THE FAILED NODE. */
- /*----------------------------------------------------------------------*/
- /* WE HAVE A NEW CRASHED REPLICA. INITIATE CREATE GCI TO INDICATE */
- /* THAT THE NEW REPLICA IS NOT STARTED YET AND REPLICA_LAST_GCI IS*/
- /* SET TO -1 TO INDICATE THAT IT IS NOT DEAD YET. */
- /*----------------------------------------------------------------------*/
- arrGuard(ncrReplicaPtr.p->noCrashedReplicas + 1, 8);
- ncrReplicaPtr.p->replicaLastGci[ncrReplicaPtr.p->noCrashedReplicas] =
- SYSFILE->lastCompletedGCI[nodeId];
- ncrReplicaPtr.p->noCrashedReplicas = ncrReplicaPtr.p->noCrashedReplicas + 1;
- ncrReplicaPtr.p->createGci[ncrReplicaPtr.p->noCrashedReplicas] = 0;
- ncrReplicaPtr.p->replicaLastGci[ncrReplicaPtr.p->noCrashedReplicas] =
- (Uint32)-1;
- }//Dbdih::newCrashedReplica()
- /*************************************************************************/
- /* AT NODE FAILURE DURING START OF A NEW NODE WE NEED TO RESET A */
- /* SET OF VARIABLES CONTROLLING THE START AND INDICATING ONGOING */
- /* START OF A NEW NODE. */
- /*************************************************************************/
- void Dbdih::nodeResetStart()
- {
- jam();
- c_nodeStartMaster.startNode = RNIL;
- c_nodeStartMaster.failNr = cfailurenr;
- c_nodeStartMaster.activeState = false;
- c_nodeStartMaster.blockGcp = false;
- c_nodeStartMaster.blockLcp = false;
- c_nodeStartMaster.m_outstandingGsn = 0;
- }//Dbdih::nodeResetStart()
- void Dbdih::openFileRw(Signal* signal, FileRecordPtr filePtr)
- {
- signal->theData[0] = reference();
- signal->theData[1] = filePtr.i;
- signal->theData[2] = filePtr.p->fileName[0];
- signal->theData[3] = filePtr.p->fileName[1];
- signal->theData[4] = filePtr.p->fileName[2];
- signal->theData[5] = filePtr.p->fileName[3];
- signal->theData[6] = FsOpenReq::OM_READWRITE;
- sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, 7, JBA);
- }//Dbdih::openFileRw()
- void Dbdih::openFileRo(Signal* signal, FileRecordPtr filePtr)
- {
- signal->theData[0] = reference();
- signal->theData[1] = filePtr.i;
- signal->theData[2] = filePtr.p->fileName[0];
- signal->theData[3] = filePtr.p->fileName[1];
- signal->theData[4] = filePtr.p->fileName[2];
- signal->theData[5] = filePtr.p->fileName[3];
- signal->theData[6] = FsOpenReq::OM_READONLY;
- sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, 7, JBA);
- }//Dbdih::openFileRw()
- /*************************************************************************/
- /* REMOVE A CRASHED REPLICA BY PACKING THE ARRAY OF CREATED GCI AND*/
- /* THE LAST GCI OF THE CRASHED REPLICA. */
- /*************************************************************************/
- void Dbdih::packCrashedReplicas(ReplicaRecordPtr replicaPtr)
- {
- ndbrequire(replicaPtr.p->noCrashedReplicas > 0);
- ndbrequire(replicaPtr.p->noCrashedReplicas <= 8);
- for (Uint32 i = 0; i < replicaPtr.p->noCrashedReplicas; i++) {
- jam();
- replicaPtr.p->createGci[i] = replicaPtr.p->createGci[i + 1];
- replicaPtr.p->replicaLastGci[i] = replicaPtr.p->replicaLastGci[i + 1];
- }//for
- replicaPtr.p->noCrashedReplicas--;
- #ifdef VM_TRACE
- for (Uint32 i = 0; i < replicaPtr.p->noCrashedReplicas; i++) {
- jam();
- ndbrequire(replicaPtr.p->createGci[i] != 0xF1F1F1F1);
- ndbrequire(replicaPtr.p->replicaLastGci[i] != 0xF1F1F1F1);
- }//for
- #endif
- }//Dbdih::packCrashedReplicas()
- void Dbdih::prepareReplicas(FragmentstorePtr fragPtr)
- {
- ReplicaRecordPtr prReplicaPtr;
- Uint32 prevReplica = RNIL;
- /* --------------------------------------------------------------------- */
- /* BEGIN BY LINKING ALL REPLICA RECORDS ONTO THE OLD STORED REPLICA*/
- /* LIST. */
- /* AT A SYSTEM RESTART OBVIOUSLY ALL NODES ARE OLD. */
- /* --------------------------------------------------------------------- */
- prReplicaPtr.i = fragPtr.p->storedReplicas;
- while (prReplicaPtr.i != RNIL) {
- jam();
- prevReplica = prReplicaPtr.i;
- ptrCheckGuard(prReplicaPtr, creplicaFileSize, replicaRecord);
- prReplicaPtr.i = prReplicaPtr.p->nextReplica;
- }//while
- /* --------------------------------------------------------------------- */
- /* LIST OF STORED REPLICAS WILL BE EMPTY NOW. */
- /* --------------------------------------------------------------------- */
- if (prevReplica != RNIL) {
- prReplicaPtr.i = prevReplica;
- ptrCheckGuard(prReplicaPtr, creplicaFileSize, replicaRecord);
- prReplicaPtr.p->nextReplica = fragPtr.p->oldStoredReplicas;
- fragPtr.p->oldStoredReplicas = fragPtr.p->storedReplicas;
- fragPtr.p->storedReplicas = RNIL;
- fragPtr.p->noOldStoredReplicas += fragPtr.p->noStoredReplicas;
- fragPtr.p->noStoredReplicas = 0;
- }//if
- }//Dbdih::prepareReplicas()
- void Dbdih::readFragment(RWFragment* rf, FragmentstorePtr fragPtr)
- {
- Uint32 TreadFid = readPageWord(rf);
- fragPtr.p->preferredPrimary = readPageWord(rf);
- fragPtr.p->noStoredReplicas = readPageWord(rf);
- fragPtr.p->noOldStoredReplicas = readPageWord(rf);
- Uint32 TdistKey = readPageWord(rf);
- ndbrequire(fragPtr.p->noStoredReplicas > 0);
- ndbrequire(TreadFid == rf->fragId);
- ndbrequire(TdistKey < 256);
- if ((cstarttype == NodeState::ST_NODE_RESTART) ||
- (cstarttype == NodeState::ST_INITIAL_NODE_RESTART)) {
- jam();
- fragPtr.p->distributionKey = TdistKey;
- }//if
- }//Dbdih::readFragment()
- Uint32 Dbdih::readPageWord(RWFragment* rf)
- {
- if (rf->wordIndex >= 2048) {
- jam();
- ndbrequire(rf->wordIndex == 2048);
- rf->pageIndex++;
- ndbrequire(rf->pageIndex < 8);
- rf->rwfPageptr.i = rf->rwfTabPtr.p->pageRef[rf->pageIndex];
- ptrCheckGuard(rf->rwfPageptr, cpageFileSize, pageRecord);
- rf->wordIndex = 32;
- }//if
- Uint32 dataWord = rf->rwfPageptr.p->word[rf->wordIndex];
- rf->wordIndex++;
- return dataWord;
- }//Dbdih::readPageWord()
- void Dbdih::readReplica(RWFragment* rf, ReplicaRecordPtr readReplicaPtr)
- {
- Uint32 i;
- readReplicaPtr.p->procNode = readPageWord(rf);
- readReplicaPtr.p->initialGci = readPageWord(rf);
- readReplicaPtr.p->noCrashedReplicas = readPageWord(rf);
- readReplicaPtr.p->nextLcp = readPageWord(rf);
- for (i = 0; i < MAX_LCP_STORED; i++) {
- readReplicaPtr.p->maxGciCompleted[i] = readPageWord(rf);
- readReplicaPtr.p->maxGciStarted[i] = readPageWord(rf);
- readReplicaPtr.p->lcpId[i] = readPageWord(rf);
- readReplicaPtr.p->lcpStatus[i] = readPageWord(rf);
- }//for
- const Uint32 noCrashedReplicas = readReplicaPtr.p->noCrashedReplicas;
- ndbrequire(noCrashedReplicas < 8);
- for (i = 0; i < noCrashedReplicas; i++) {
- readReplicaPtr.p->createGci[i] = readPageWord(rf);
- readReplicaPtr.p->replicaLastGci[i] = readPageWord(rf);
- ndbrequire(readReplicaPtr.p->createGci[i] != 0xF1F1F1F1);
- ndbrequire(readReplicaPtr.p->replicaLastGci[i] != 0xF1F1F1F1);
- }//for
- for(i = noCrashedReplicas; i<8; i++){
- readReplicaPtr.p->createGci[i] = readPageWord(rf);
- readReplicaPtr.p->replicaLastGci[i] = readPageWord(rf);
- // They are not initialized...
- readReplicaPtr.p->createGci[i] = 0;
- readReplicaPtr.p->replicaLastGci[i] = ~0;
- }
- /* ---------------------------------------------------------------------- */
- /* IF THE LAST COMPLETED LOCAL CHECKPOINT IS VALID AND LARGER THAN */
- /* THE LAST COMPLETED CHECKPOINT THEN WE WILL INVALIDATE THIS LOCAL */
- /* CHECKPOINT FOR THIS REPLICA. */
- /* ---------------------------------------------------------------------- */
- Uint32 trraLcp = prevLcpNo(readReplicaPtr.p->nextLcp);
- ndbrequire(trraLcp < MAX_LCP_STORED);
- if ((readReplicaPtr.p->lcpStatus[trraLcp] == ZVALID) &&
- (readReplicaPtr.p->lcpId[trraLcp] > SYSFILE->latestLCP_ID)) {
- jam();
- readReplicaPtr.p->lcpStatus[trraLcp] = ZINVALID;
- }//if
- /* ---------------------------------------------------------------------- */
- /* WE ALSO HAVE TO INVALIDATE ANY LOCAL CHECKPOINTS THAT HAVE BEEN */
- /* INVALIDATED BY MOVING BACK THE RESTART GCI. */
- /* ---------------------------------------------------------------------- */
- for (i = 0; i < MAX_LCP_STORED; i++) {
- jam();
- if ((readReplicaPtr.p->lcpStatus[i] == ZVALID) &&
- (readReplicaPtr.p->maxGciStarted[i] > SYSFILE->newestRestorableGCI)) {
- jam();
- readReplicaPtr.p->lcpStatus[i] = ZINVALID;
- }//if
- }//for
- /* ---------------------------------------------------------------------- */
- /* WE WILL REMOVE ANY OCCURRENCES OF REPLICAS THAT HAVE CRASHED */
- /* THAT ARE NO LONGER VALID DUE TO MOVING RESTART GCI BACKWARDS. */
- /* ---------------------------------------------------------------------- */
- removeTooNewCrashedReplicas(readReplicaPtr);
- /* ---------------------------------------------------------------------- */
- /* WE WILL REMOVE ANY OCCURRENCES OF REPLICAS THAT HAVE CRASHED */
- /* THAT ARE NO LONGER VALID SINCE THEY ARE NO LONGER RESTORABLE. */
- /* ---------------------------------------------------------------------- */
- removeOldCrashedReplicas(readReplicaPtr);
- /* --------------------------------------------------------------------- */
- // We set the last GCI of the replica that was alive before the node
- // crashed last time. We set it to the last GCI which the node participated in.
- /* --------------------------------------------------------------------- */
- ndbrequire(readReplicaPtr.p->noCrashedReplicas < 8);
- readReplicaPtr.p->replicaLastGci[readReplicaPtr.p->noCrashedReplicas] =
- SYSFILE->lastCompletedGCI[readReplicaPtr.p->procNode];
- /* ---------------------------------------------------------------------- */
- /* FIND PROCESSOR RECORD */
- /* ---------------------------------------------------------------------- */
- }//Dbdih::readReplica()
- void Dbdih::readReplicas(RWFragment* rf, FragmentstorePtr fragPtr)
- {
- Uint32 i;
- ReplicaRecordPtr newReplicaPtr;
- Uint32 noStoredReplicas = fragPtr.p->noStoredReplicas;
- Uint32 noOldStoredReplicas = fragPtr.p->noOldStoredReplicas;
- /* ----------------------------------------------------------------------- */
- /* WE CLEAR THE NUMBER OF STORED REPLICAS SINCE IT WILL BE CALCULATED */
- /* BY THE LINKING SUBROUTINES. */
- /* ----------------------------------------------------------------------- */
- fragPtr.p->noStoredReplicas = 0;
- fragPtr.p->noOldStoredReplicas = 0;
- Uint32 replicaIndex = 0;
- ndbrequire(noStoredReplicas + noOldStoredReplicas <= MAX_REPLICAS);
- for (i = 0; i < noStoredReplicas; i++) {
- seizeReplicaRec(newReplicaPtr);
- readReplica(rf, newReplicaPtr);
- if (checkNodeAlive(newReplicaPtr.p->procNode)) {
- jam();
- ndbrequire(replicaIndex < MAX_REPLICAS);
- fragPtr.p->activeNodes[replicaIndex] = newReplicaPtr.p->procNode;
- replicaIndex++;
- linkStoredReplica(fragPtr, newReplicaPtr);
- } else {
- jam();
- linkOldStoredReplica(fragPtr, newReplicaPtr);
- }//if
- }//for
- fragPtr.p->fragReplicas = noStoredReplicas;
- for (i = 0; i < noOldStoredReplicas; i++) {
- jam();
- seizeReplicaRec(newReplicaPtr);
- readReplica(rf, newReplicaPtr);
- linkOldStoredReplica(fragPtr, newReplicaPtr);
- }//for
- }//Dbdih::readReplicas()
- void Dbdih::readRestorableGci(Signal* signal, FileRecordPtr filePtr)
- {
- signal->theData[0] = filePtr.p->fileRef;
- signal->theData[1] = reference();
- signal->theData[2] = filePtr.i;
- signal->theData[3] = ZLIST_OF_PAIRS;
- signal->theData[4] = ZVAR_NO_CRESTART_INFO;
- signal->theData[5] = 1;
- signal->theData[6] = 0;
- signal->theData[7] = 0;
- sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 8, JBA);
- }//Dbdih::readRestorableGci()
- void Dbdih::readTabfile(Signal* signal, TabRecord* tab, FileRecordPtr filePtr)
- {
- signal->theData[0] = filePtr.p->fileRef;
- signal->theData[1] = reference();
- signal->theData[2] = filePtr.i;
- signal->theData[3] = ZLIST_OF_PAIRS;
- signal->theData[4] = ZVAR_NO_WORD;
- signal->theData[5] = tab->noPages;
- for (Uint32 i = 0; i < tab->noPages; i++) {
- signal->theData[6 + (2 * i)] = tab->pageRef[i];
- signal->theData[7 + (2 * i)] = i;
- }//for
- sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 22, JBA);
- }//Dbdih::readTabfile()
- void Dbdih::releasePage(Uint32 pageIndex)
- {
- PageRecordPtr pagePtr;
- pagePtr.i = pageIndex;
- ptrCheckGuard(pagePtr, cpageFileSize, pageRecord);
- pagePtr.p->nextfreepage = cfirstfreepage;
- cfirstfreepage = pagePtr.i;
- }//Dbdih::releasePage()
- void Dbdih::releaseTabPages(Uint32 tableId)
- {
- TabRecordPtr tabPtr;
- tabPtr.i = tableId;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
- ndbrequire(tabPtr.p->noPages <= 8);
- for (Uint32 i = 0; i < tabPtr.p->noPages; i++) {
- jam();
- releasePage(tabPtr.p->pageRef[i]);
- }//for
- tabPtr.p->noPages = 0;
- }//Dbdih::releaseTabPages()
- /*************************************************************************/
- /* REMOVE NODE FROM SET OF ALIVE NODES. */
- /*************************************************************************/
- void Dbdih::removeAlive(NodeRecordPtr removeNodePtr)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = cfirstAliveNode;
- if (nodePtr.i == removeNodePtr.i) {
- jam();
- cfirstAliveNode = removeNodePtr.p->nextNode;
- return;
- }//if
- do {
- jam();
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- if (nodePtr.p->nextNode == removeNodePtr.i) {
- jam();
- nodePtr.p->nextNode = removeNodePtr.p->nextNode;
- break;
- } else {
- jam();
- nodePtr.i = nodePtr.p->nextNode;
- }//if
- } while (1);
- }//Dbdih::removeAlive()
- /*************************************************************************/
- /* REMOVE NODE FROM SET OF DEAD NODES. */
- /*************************************************************************/
- void Dbdih::removeDeadNode(NodeRecordPtr removeNodePtr)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = cfirstDeadNode;
- if (nodePtr.i == removeNodePtr.i) {
- jam();
- cfirstDeadNode = removeNodePtr.p->nextNode;
- return;
- }//if
- do {
- jam();
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- if (nodePtr.p->nextNode == removeNodePtr.i) {
- jam();
- nodePtr.p->nextNode = removeNodePtr.p->nextNode;
- break;
- } else {
- jam();
- nodePtr.i = nodePtr.p->nextNode;
- }//if
- } while (1);
- }//Dbdih::removeDeadNode()
- /*---------------------------------------------------------------*/
- /* REMOVE REPLICAS OF A FAILED NODE FROM LIST OF STORED */
- /* REPLICAS AND MOVE IT TO THE LIST OF OLD STORED REPLICAS.*/
- /* ALSO UPDATE THE CRASHED REPLICA INFORMATION. */
- /*---------------------------------------------------------------*/
- void Dbdih::removeNodeFromStored(Uint32 nodeId,
- FragmentstorePtr fragPtr,
- ReplicaRecordPtr replicatePtr)
- {
- newCrashedReplica(nodeId, replicatePtr);
- removeStoredReplica(fragPtr, replicatePtr);
- linkOldStoredReplica(fragPtr, replicatePtr);
- ndbrequire(fragPtr.p->storedReplicas != RNIL);
- }//Dbdih::removeNodeFromStored()
- /*************************************************************************/
- /* REMOVE ANY OLD CRASHED REPLICAS THAT ARE NOT RESTORABLE ANY MORE*/
- /*************************************************************************/
- void Dbdih::removeOldCrashedReplicas(ReplicaRecordPtr rocReplicaPtr)
- {
- while (rocReplicaPtr.p->noCrashedReplicas > 0) {
- jam();
- /* --------------------------------------------------------------------- */
- /* ONLY IF THERE IS AT LEAST ONE REPLICA THEN CAN WE REMOVE ANY. */
- /* --------------------------------------------------------------------- */
- if (rocReplicaPtr.p->replicaLastGci[0] < SYSFILE->oldestRestorableGCI){
- jam();
- /* ------------------------------------------------------------------- */
- /* THIS CRASHED REPLICA HAS BECOME EXTINCT AND MUST BE REMOVED TO */
- /* GIVE SPACE FOR NEW CRASHED REPLICAS. */
- /* ------------------------------------------------------------------- */
- packCrashedReplicas(rocReplicaPtr);
- } else {
- break;
- }//if
- }//while
- if (rocReplicaPtr.p->createGci[0] < SYSFILE->keepGCI){
- jam();
- /* --------------------------------------------------------------------- */
- /* MOVE FORWARD THE CREATE GCI TO A GCI THAT CAN BE USED. WE HAVE */
- /* NO CERTAINTY IN FINDING ANY LOG RECORDS FROM OLDER GCI'S. */
- /* --------------------------------------------------------------------- */
- rocReplicaPtr.p->createGci[0] = SYSFILE->keepGCI;
- ndbrequire(SYSFILE->keepGCI != 0xF1F1F1F1);
- }//if
- }//Dbdih::removeOldCrashedReplicas()
- void Dbdih::removeOldStoredReplica(FragmentstorePtr fragPtr,
- ReplicaRecordPtr replicatePtr)
- {
- ReplicaRecordPtr rosTmpReplicaPtr;
- ReplicaRecordPtr rosPrevReplicaPtr;
- fragPtr.p->noOldStoredReplicas--;
- if (fragPtr.p->oldStoredReplicas == replicatePtr.i) {
- jam();
- fragPtr.p->oldStoredReplicas = replicatePtr.p->nextReplica;
- } else {
- rosPrevReplicaPtr.i = fragPtr.p->oldStoredReplicas;
- ptrCheckGuard(rosPrevReplicaPtr, creplicaFileSize, replicaRecord);
- rosTmpReplicaPtr.i = rosPrevReplicaPtr.p->nextReplica;
- while (rosTmpReplicaPtr.i != replicatePtr.i) {
- jam();
- rosPrevReplicaPtr.i = rosTmpReplicaPtr.i;
- ptrCheckGuard(rosPrevReplicaPtr, creplicaFileSize, replicaRecord);
- ptrCheckGuard(rosTmpReplicaPtr, creplicaFileSize, replicaRecord);
- rosTmpReplicaPtr.i = rosTmpReplicaPtr.p->nextReplica;
- }//if
- rosPrevReplicaPtr.p->nextReplica = replicatePtr.p->nextReplica;
- }//if
- }//Dbdih::removeOldStoredReplica()
- void Dbdih::removeStoredReplica(FragmentstorePtr fragPtr,
- ReplicaRecordPtr replicatePtr)
- {
- ReplicaRecordPtr rsrTmpReplicaPtr;
- ReplicaRecordPtr rsrPrevReplicaPtr;
- fragPtr.p->noStoredReplicas--;
- if (fragPtr.p->storedReplicas == replicatePtr.i) {
- jam();
- fragPtr.p->storedReplicas = replicatePtr.p->nextReplica;
- } else {
- jam();
- rsrPrevReplicaPtr.i = fragPtr.p->storedReplicas;
- rsrTmpReplicaPtr.i = fragPtr.p->storedReplicas;
- ptrCheckGuard(rsrTmpReplicaPtr, creplicaFileSize, replicaRecord);
- rsrTmpReplicaPtr.i = rsrTmpReplicaPtr.p->nextReplica;
- while (rsrTmpReplicaPtr.i != replicatePtr.i) {
- jam();
- rsrPrevReplicaPtr.i = rsrTmpReplicaPtr.i;
- ptrCheckGuard(rsrTmpReplicaPtr, creplicaFileSize, replicaRecord);
- rsrTmpReplicaPtr.i = rsrTmpReplicaPtr.p->nextReplica;
- }//while
- ptrCheckGuard(rsrPrevReplicaPtr, creplicaFileSize, replicaRecord);
- rsrPrevReplicaPtr.p->nextReplica = replicatePtr.p->nextReplica;
- }//if
- }//Dbdih::removeStoredReplica()
- /*************************************************************************/
- /* REMOVE ALL TOO NEW CRASHED REPLICAS THAT IS IN THIS REPLICA. */
- /*************************************************************************/
- void Dbdih::removeTooNewCrashedReplicas(ReplicaRecordPtr rtnReplicaPtr)
- {
- while (rtnReplicaPtr.p->noCrashedReplicas > 0) {
- jam();
- /* --------------------------------------------------------------------- */
- /* REMOVE ALL REPLICAS THAT ONLY LIVED IN A PERIOD THAT HAVE BEEN */
- /* REMOVED FROM THE RESTART INFORMATION SINCE THE RESTART FAILED */
- /* TOO MANY TIMES. */
- /* --------------------------------------------------------------------- */
- arrGuard(rtnReplicaPtr.p->noCrashedReplicas - 1, 8);
- if (rtnReplicaPtr.p->createGci[rtnReplicaPtr.p->noCrashedReplicas - 1] >
- SYSFILE->newestRestorableGCI){
- jam();
- rtnReplicaPtr.p->createGci[rtnReplicaPtr.p->noCrashedReplicas - 1] =
- (Uint32)-1;
- rtnReplicaPtr.p->replicaLastGci[rtnReplicaPtr.p->noCrashedReplicas - 1] =
- (Uint32)-1;
- rtnReplicaPtr.p->noCrashedReplicas--;
- } else {
- break;
- }//if
- }//while
- }//Dbdih::removeTooNewCrashedReplicas()
- /*************************************************************************/
- /* */
- /* MODULE: SEARCH FOR POSSIBLE REPLICAS THAT CAN HANDLE THE GLOBAL */
- /* CHECKPOINT WITHOUT NEEDING ANY EXTRA LOGGING FACILITIES.*/
- /* A MAXIMUM OF FOUR NODES IS RETRIEVED. */
- /*************************************************************************/
- void Dbdih::searchStoredReplicas(FragmentstorePtr fragPtr)
- {
- Uint32 nextReplicaPtrI;
- ConstPtr<ReplicaRecord> replicaPtr;
- replicaPtr.i = fragPtr.p->storedReplicas;
- while (replicaPtr.i != RNIL) {
- jam();
- ptrCheckGuard(replicaPtr, creplicaFileSize, replicaRecord);
- nextReplicaPtrI = replicaPtr.p->nextReplica;
- NodeRecordPtr nodePtr;
- nodePtr.i = replicaPtr.p->procNode;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- if (nodePtr.p->nodeStatus == NodeRecord::ALIVE) {
- jam();
- switch (nodePtr.p->activeStatus) {
- case Sysfile::NS_Active:
- case Sysfile::NS_ActiveMissed_1:
- case Sysfile::NS_ActiveMissed_2:{
- /* ----------------------------------------------------------------- */
- /* INITIALISE THE CREATE REPLICA STRUCTURE THAT IS USED FOR SENDING*/
- /* TO LQH START_FRAGREQ. */
- /* SET THE DATA NODE WHERE THE LOCAL CHECKPOINT IS FOUND. ALSO */
- /* SET A REFERENCE TO THE REPLICA POINTER OF THAT. */
- /* ----------------------------------------------------------------- */
- CreateReplicaRecordPtr createReplicaPtr;
- createReplicaPtr.i = cnoOfCreateReplicas;
- ptrCheckGuard(createReplicaPtr, 4, createReplicaRecord);
- cnoOfCreateReplicas++;
- createReplicaPtr.p->dataNodeId = replicaPtr.p->procNode;
- createReplicaPtr.p->replicaRec = replicaPtr.i;
- /* ----------------------------------------------------------------- */
- /* WE NEED TO SEARCH FOR A PROPER LOCAL CHECKPOINT TO USE FOR THE */
- /* SYSTEM RESTART. */
- /* ----------------------------------------------------------------- */
- Uint32 startGci;
- Uint32 startLcpNo;
- Uint32 stopGci = SYSFILE->newestRestorableGCI;
- bool result = findStartGci(replicaPtr,
- stopGci,
- startGci,
- startLcpNo);
- if (!result) {
- jam();
- /* --------------------------------------------------------------- */
- /* WE COULD NOT FIND ANY LOCAL CHECKPOINT. THE FRAGMENT THUS DO NOT*/
- /* CONTAIN ANY VALID LOCAL CHECKPOINT. IT DOES HOWEVER CONTAIN A */
- /* VALID FRAGMENT LOG. THUS BY FIRST CREATING THE FRAGMENT AND THEN*/
- /* EXECUTING THE FRAGMENT LOG WE CAN CREATE THE FRAGMENT AS */
- /* DESIRED. THIS SHOULD ONLY OCCUR AFTER CREATING A FRAGMENT. */
- /* */
- /* TO INDICATE THAT NO LOCAL CHECKPOINT IS TO BE USED WE SET THE */
- /* LOCAL CHECKPOINT TO ZNIL. */
- /* --------------------------------------------------------------- */
- createReplicaPtr.p->lcpNo = ZNIL;
- } else {
- jam();
- /* --------------------------------------------------------------- */
- /* WE FOUND A PROPER LOCAL CHECKPOINT TO RESTART FROM. */
- /* SET LOCAL CHECKPOINT ID AND LOCAL CHECKPOINT NUMBER. */
- /* --------------------------------------------------------------- */
- createReplicaPtr.p->lcpNo = startLcpNo;
- arrGuard(startLcpNo, MAX_LCP_STORED);
- createReplicaPtr.p->createLcpId = replicaPtr.p->lcpId[startLcpNo];
- }//if
- if(ERROR_INSERTED(7073) || ERROR_INSERTED(7074)){
- jam();
- nodePtr.p->nodeStatus = NodeRecord::DEAD;
- }
- /* ----------------------------------------------------------------- */
- /* WE HAVE EITHER FOUND A LOCAL CHECKPOINT OR WE ARE PLANNING TO */
- /* EXECUTE THE LOG FROM THE INITIAL CREATION OF THE TABLE. IN BOTH */
- /* CASES WE NEED TO FIND A SET OF LOGS THAT CAN EXECUTE SUCH THAT */
- /* WE RECOVER TO THE SYSTEM RESTART GLOBAL CHECKPOINT. */
- /* -_--------------------------------------------------------------- */
- if (!findLogNodes(createReplicaPtr.p, fragPtr, startGci, stopGci)) {
- jam();
- /* --------------------------------------------------------------- */
- /* WE WERE NOT ABLE TO FIND ANY WAY OF RESTORING THIS REPLICA. */
- /* THIS IS A POTENTIAL SYSTEM ERROR. */
- /* --------------------------------------------------------------- */
- cnoOfCreateReplicas--;
- return;
- }//if
-
- if(ERROR_INSERTED(7073) || ERROR_INSERTED(7074)){
- jam();
- nodePtr.p->nodeStatus = NodeRecord::ALIVE;
- }
-
- break;
- }
- default:
- jam();
- /*empty*/;
- break;
- }//switch
- }
- replicaPtr.i = nextReplicaPtrI;
- }//while
- }//Dbdih::searchStoredReplicas()
- /*************************************************************************/
- /* */
- /* MODULE: SEIZE_FILE */
- /* DESCRIPTION: THE SUBROUTINE SEIZES A FILE RECORD FROM THE */
- /* FREE LIST. */
- /*************************************************************************/
- void Dbdih::seizeFile(FileRecordPtr& filePtr)
- {
- filePtr.i = cfirstfreeFile;
- ptrCheckGuard(filePtr, cfileFileSize, fileRecord);
- cfirstfreeFile = filePtr.p->nextFile;
- filePtr.p->nextFile = RNIL;
- }//Dbdih::seizeFile()
- /*************************************************************************/
- /* SEND CREATE_FRAGREQ TO ALL NODES IN THE NDB CLUSTER. */
- /*************************************************************************/
- /*************************************************************************/
- /* */
- /* MODULE: FIND THE START GCI AND LOCAL CHECKPOINT TO USE. */
- /*************************************************************************/
- void Dbdih::sendStartFragreq(Signal* signal,
- TabRecordPtr tabPtr, Uint32 fragId)
- {
- CreateReplicaRecordPtr replicaPtr;
- for (replicaPtr.i = 0; replicaPtr.i < cnoOfCreateReplicas; replicaPtr.i++) {
- jam();
- ptrAss(replicaPtr, createReplicaRecord);
- BlockReference ref = calcLqhBlockRef(replicaPtr.p->dataNodeId);
- StartFragReq * const startFragReq = (StartFragReq *)&signal->theData[0];
- startFragReq->userPtr = replicaPtr.p->replicaRec;
- startFragReq->userRef = reference();
- startFragReq->lcpNo = replicaPtr.p->lcpNo;
- startFragReq->lcpId = replicaPtr.p->createLcpId;
- startFragReq->tableId = tabPtr.i;
- startFragReq->fragId = fragId;
- if(ERROR_INSERTED(7072) || ERROR_INSERTED(7074)){
- jam();
- const Uint32 noNodes = replicaPtr.p->noLogNodes;
- Uint32 start = replicaPtr.p->logStartGci[noNodes - 1];
- const Uint32 stop = replicaPtr.p->logStopGci[noNodes - 1];
- for(Uint32 i = noNodes; i < 4 && (stop - start) > 0; i++){
- replicaPtr.p->noLogNodes++;
- replicaPtr.p->logStopGci[i - 1] = start;
-
- replicaPtr.p->logNodeId[i] = replicaPtr.p->logNodeId[i-1];
- replicaPtr.p->logStartGci[i] = start + 1;
- replicaPtr.p->logStopGci[i] = stop;
- start += 1;
- }
- }
-
- startFragReq->noOfLogNodes = replicaPtr.p->noLogNodes;
-
- for (Uint32 i = 0; i < 4 ; i++) {
- startFragReq->lqhLogNode[i] = replicaPtr.p->logNodeId[i];
- startFragReq->startGci[i] = replicaPtr.p->logStartGci[i];
- startFragReq->lastGci[i] = replicaPtr.p->logStopGci[i];
- }//for
- sendSignal(ref, GSN_START_FRAGREQ, signal,
- StartFragReq::SignalLength, JBB);
- }//for
- }//Dbdih::sendStartFragreq()
- /*************************************************************************/
- /* SET THE INITIAL ACTIVE STATUS ON ALL NODES AND PUT INTO LISTS. */
- /*************************************************************************/
- void Dbdih::setInitialActiveStatus()
- {
- NodeRecordPtr siaNodeptr;
- Uint32 tsiaNodeActiveStatus;
- Uint32 tsiaNoActiveNodes;
- tsiaNoActiveNodes = csystemnodes - cnoHotSpare;
- for(Uint32 i = 0; i<Sysfile::NODE_STATUS_SIZE; i++)
- SYSFILE->nodeStatus[i] = 0;
- for (siaNodeptr.i = 1; siaNodeptr.i < MAX_NDB_NODES; siaNodeptr.i++) {
- ptrAss(siaNodeptr, nodeRecord);
- if (siaNodeptr.p->nodeStatus == NodeRecord::ALIVE) {
- if (tsiaNoActiveNodes == 0) {
- jam();
- siaNodeptr.p->activeStatus = Sysfile::NS_HotSpare;
- } else {
- jam();
- tsiaNoActiveNodes = tsiaNoActiveNodes - 1;
- siaNodeptr.p->activeStatus = Sysfile::NS_Active;
- }//if
- } else {
- jam();
- siaNodeptr.p->activeStatus = Sysfile::NS_NotDefined;
- }//if
- switch (siaNodeptr.p->activeStatus) {
- case Sysfile::NS_Active:
- jam();
- tsiaNodeActiveStatus = Sysfile::NS_Active;
- break;
- case Sysfile::NS_HotSpare:
- jam();
- tsiaNodeActiveStatus = Sysfile::NS_HotSpare;
- break;
- case Sysfile::NS_NotDefined:
- jam();
- tsiaNodeActiveStatus = Sysfile::NS_NotDefined;
- break;
- default:
- ndbrequire(false);
- return;
- break;
- }//switch
- Sysfile::setNodeStatus(siaNodeptr.i, SYSFILE->nodeStatus,
- tsiaNodeActiveStatus);
- }//for
- }//Dbdih::setInitialActiveStatus()
- /*************************************************************************/
- /* SET LCP ACTIVE STATUS AT THE END OF A LOCAL CHECKPOINT. */
- /*************************************************************************/
- void Dbdih::setLcpActiveStatusEnd()
- {
- NodeRecordPtr nodePtr;
- for (nodePtr.i = 1; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) {
- jam();
- ptrAss(nodePtr, nodeRecord);
- if (c_lcpState.m_participatingLQH.get(nodePtr.i)){
- switch (nodePtr.p->activeStatus) {
- case Sysfile::NS_Active:
- case Sysfile::NS_ActiveMissed_1:
- case Sysfile::NS_ActiveMissed_2:
- jam();
- /*-------------------------------------------------------------------*/
- /* THE NODE PARTICIPATED IN THIS CHECKPOINT.
- * WE CAN SET ITS STATUS TO ACTIVE */
- /*-------------------------------------------------------------------*/
- nodePtr.p->activeStatus = Sysfile::NS_Active;
- takeOverCompleted(nodePtr.i);
- break;
- case Sysfile::NS_TakeOver:
- jam();
- /*-------------------------------------------------------------------*/
- /* THE NODE HAS COMPLETED A CHECKPOINT AFTER TAKE OVER. WE CAN NOW */
- /* SET ITS STATUS TO ACTIVE. WE CAN ALSO COMPLETE THE TAKE OVER */
- /* AND ALSO WE CLEAR THE TAKE OVER NODE IN THE RESTART INFO. */
- /*-------------------------------------------------------------------*/
- nodePtr.p->activeStatus = Sysfile::NS_Active;
- takeOverCompleted(nodePtr.i);
- break;
- default:
- ndbrequire(false);
- return;
- break;
- }//switch
- }//if
- }//for
- if(getNodeState().getNodeRestartInProgress()){
- jam();
- if(c_lcpState.m_participatingLQH.get(getOwnNodeId())){
- nodePtr.i = getOwnNodeId();
- ptrAss(nodePtr, nodeRecord);
- ndbrequire(nodePtr.p->activeStatus == Sysfile::NS_Active);
- ndbout_c("NR: setLcpActiveStatusEnd - m_participatingLQH");
- } else {
- ndbout_c("NR: setLcpActiveStatusEnd - !m_participatingLQH");
- }
- }
-
- c_lcpState.m_participatingDIH.clear();
- c_lcpState.m_participatingLQH.clear();
- if (isMaster()) {
- jam();
- setNodeRestartInfoBits();
- }//if
- }//Dbdih::setLcpActiveStatusEnd()
- void Dbdih::takeOverCompleted(Uint32 aNodeId)
- {
- TakeOverRecordPtr takeOverPtr;
- takeOverPtr.i = findTakeOver(aNodeId);
- if (takeOverPtr.i != RNIL) {
- jam();
- ptrCheckGuard(takeOverPtr, MAX_NDB_NODES, takeOverRecord);
- if (takeOverPtr.p->toMasterStatus != TakeOverRecord::WAIT_LCP) {
- jam();
- ndbrequire(!isMaster());
- return;
- }//if
- ndbrequire(isMaster());
- Sysfile::setTakeOverNode(aNodeId, SYSFILE->takeOver, 0);
- takeOverPtr.p->toMasterStatus = TakeOverRecord::TO_END_COPY;
- cstartGcpNow = true;
- }//if
- }//Dbdih::takeOverCompleted()
- /*************************************************************************/
- /* SET LCP ACTIVE STATUS BEFORE STARTING A LOCAL CHECKPOINT. */
- /*************************************************************************/
- void Dbdih::setLcpActiveStatusStart(Signal* signal)
- {
- NodeRecordPtr nodePtr;
- c_lcpState.m_participatingLQH.clear();
- c_lcpState.m_participatingDIH.clear();
-
- for (nodePtr.i = 1; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) {
- ptrAss(nodePtr, nodeRecord);
- #if 0
- if(nodePtr.p->nodeStatus != NodeRecord::NOT_IN_CLUSTER){
- infoEvent("Node %d nodeStatus=%d activeStatus=%d copyCompleted=%d lcp=%d",
- nodePtr.i,
- nodePtr.p->nodeStatus,
- nodePtr.p->activeStatus,
- nodePtr.p->copyCompleted,
- nodePtr.p->m_inclDihLcp);
- }
- #endif
- if(nodePtr.p->nodeStatus == NodeRecord::ALIVE && nodePtr.p->m_inclDihLcp){
- jam();
- c_lcpState.m_participatingDIH.set(nodePtr.i);
- }
- if ((nodePtr.p->nodeStatus == NodeRecord::ALIVE) &&
- (nodePtr.p->copyCompleted)) {
- switch (nodePtr.p->activeStatus) {
- case Sysfile::NS_Active:
- jam();
- /*-------------------------------------------------------------------*/
- // The normal case. Starting a LCP for a started node which hasn't
- // missed the previous LCP.
- /*-------------------------------------------------------------------*/
- c_lcpState.m_participatingLQH.set(nodePtr.i);
- break;
- case Sysfile::NS_ActiveMissed_1:
- jam();
- /*-------------------------------------------------------------------*/
- // The node is starting up and is participating in a local checkpoint
- // as the final phase of the start-up. We can still use the checkpoints
- // on the node after a system restart.
- /*-------------------------------------------------------------------*/
- c_lcpState.m_participatingLQH.set(nodePtr.i);
- break;
- case Sysfile::NS_ActiveMissed_2:
- jam();
- /*-------------------------------------------------------------------*/
- // The node is starting up and is participating in a local checkpoint
- // as the final phase of the start-up. We have missed so
- // many checkpoints that we no longer can use this node to
- // recreate fragments from disk.
- // It must be taken over with the copy fragment process after a system
- // crash. We indicate this by setting the active status to TAKE_OVER.
- /*-------------------------------------------------------------------*/
- nodePtr.p->activeStatus = Sysfile::NS_TakeOver;
- //break; // Fall through
- case Sysfile::NS_TakeOver:{
- TakeOverRecordPtr takeOverPtr;
- jam();
- /*-------------------------------------------------------------------*/
- /* THIS NODE IS CURRENTLY TAKING OVER A FAILED NODE. */
- /*-------------------------------------------------------------------*/
- takeOverPtr.i = findTakeOver(nodePtr.i);
- if (takeOverPtr.i != RNIL) {
- jam();
- ptrCheckGuard(takeOverPtr, MAX_NDB_NODES, takeOverRecord);
- if (takeOverPtr.p->toMasterStatus == TakeOverRecord::WAIT_LCP) {
- jam();
- /*---------------------------------------------------------------
- * ALL THE INFORMATION HAVE BEEN REPLICATED TO THE NEW
- * NODE AND WE ARE ONLY WAITING FOR A LOCAL CHECKPOINT TO BE
- * PERFORMED ON THE NODE TO SET ITS STATUS TO ACTIVE.
- */
- infoEvent("Node %d is WAIT_LCP including in LCP", nodePtr.i);
- c_lcpState.m_participatingLQH.set(nodePtr.i);
- }//if
- }//if
- break;
- }
- default:
- jam();
- /*empty*/;
- break;
- }//switch
- } else {
- switch (nodePtr.p->activeStatus) {
- case Sysfile::NS_Active:
- jam();
- nodePtr.p->activeStatus = Sysfile::NS_ActiveMissed_1;
- break;
- case Sysfile::NS_ActiveMissed_1:
- jam();
- nodePtr.p->activeStatus = Sysfile::NS_ActiveMissed_2;
- break;
- case Sysfile::NS_ActiveMissed_2:
- jam();
- if ((nodePtr.p->nodeStatus == NodeRecord::ALIVE) &&
- (!nodePtr.p->copyCompleted)) {
- jam();
- /*-----------------------------------------------------------------*/
- // The node is currently starting up and has not completed the
- // copy phase.
- // It will thus be in the TAKE_OVER state.
- /*-----------------------------------------------------------------*/
- ndbrequire(findTakeOver(nodePtr.i) != RNIL);
- nodePtr.p->activeStatus = Sysfile::NS_TakeOver;
- } else {
- jam();
- /*-----------------------------------------------------------------*/
- /* THE NODE IS ACTIVE AND HAS NOT COMPLETED ANY OF THE LAST 3
- * CHECKPOINTS */
- /* WE MUST TAKE IT OUT OF ACTION AND START A NEW NODE TO TAKE OVER.*/
- /*-----------------------------------------------------------------*/
- nodePtr.p->activeStatus = Sysfile::NS_NotActive_NotTakenOver;
- }//if
- break;
- case Sysfile::NS_TakeOver:
- jam();
- break;
- default:
- jam();
- /*empty*/;
- break;
- }//switch
- }//if
- }//for
- if (isMaster()) {
- jam();
- checkStartTakeOver(signal);
- setNodeRestartInfoBits();
- }//if
- }//Dbdih::setLcpActiveStatusStart()
- /*************************************************************************/
- /* SET NODE ACTIVE STATUS AT SYSTEM RESTART AND WHEN UPDATED BY MASTER */
- /*************************************************************************/
- void Dbdih::setNodeActiveStatus()
- {
- NodeRecordPtr snaNodeptr;
- for (snaNodeptr.i = 1; snaNodeptr.i < MAX_NDB_NODES; snaNodeptr.i++) {
- ptrAss(snaNodeptr, nodeRecord);
- const Uint32 tsnaNodeBits = Sysfile::getNodeStatus(snaNodeptr.i,
- SYSFILE->nodeStatus);
- switch (tsnaNodeBits) {
- case Sysfile::NS_Active:
- jam();
- snaNodeptr.p->activeStatus = Sysfile::NS_Active;
- break;
- case Sysfile::NS_ActiveMissed_1:
- jam();
- snaNodeptr.p->activeStatus = Sysfile::NS_ActiveMissed_1;
- break;
- case Sysfile::NS_ActiveMissed_2:
- jam();
- snaNodeptr.p->activeStatus = Sysfile::NS_ActiveMissed_2;
- break;
- case Sysfile::NS_TakeOver:
- jam();
- snaNodeptr.p->activeStatus = Sysfile::NS_TakeOver;
- break;
- case Sysfile::NS_HotSpare:
- jam();
- snaNodeptr.p->activeStatus = Sysfile::NS_HotSpare;
- break;
- case Sysfile::NS_NotActive_NotTakenOver:
- jam();
- snaNodeptr.p->activeStatus = Sysfile::NS_NotActive_NotTakenOver;
- break;
- case Sysfile::NS_NotDefined:
- jam();
- snaNodeptr.p->activeStatus = Sysfile::NS_NotDefined;
- break;
- default:
- ndbrequire(false);
- break;
- }//switch
- }//for
- }//Dbdih::setNodeActiveStatus()
- /***************************************************************************/
- /* SET THE NODE GROUP BASED ON THE RESTART INFORMATION OR AS SET BY MASTER */
- /***************************************************************************/
- void Dbdih::setNodeGroups()
- {
- NodeGroupRecordPtr NGPtr;
- NodeRecordPtr sngNodeptr;
- Uint32 Ti;
- for (Ti = 0; Ti < MAX_NDB_NODES; Ti++) {
- NGPtr.i = Ti;
- ptrAss(NGPtr, nodeGroupRecord);
- NGPtr.p->nodeCount = 0;
- }//for
- for (sngNodeptr.i = 1; sngNodeptr.i < MAX_NDB_NODES; sngNodeptr.i++) {
- ptrAss(sngNodeptr, nodeRecord);
- Sysfile::ActiveStatus s =
- (Sysfile::ActiveStatus)Sysfile::getNodeStatus(sngNodeptr.i,
- SYSFILE->nodeStatus);
- switch (s){
- case Sysfile::NS_Active:
- case Sysfile::NS_ActiveMissed_1:
- case Sysfile::NS_ActiveMissed_2:
- case Sysfile::NS_NotActive_NotTakenOver:
- case Sysfile::NS_TakeOver:
- jam();
- sngNodeptr.p->nodeGroup = Sysfile::getNodeGroup(sngNodeptr.i,
- SYSFILE->nodeGroups);
- NGPtr.i = sngNodeptr.p->nodeGroup;
- ptrCheckGuard(NGPtr, MAX_NDB_NODES, nodeGroupRecord);
- NGPtr.p->nodesInGroup[NGPtr.p->nodeCount] = sngNodeptr.i;
- NGPtr.p->nodeCount++;
- break;
- case Sysfile::NS_HotSpare:
- case Sysfile::NS_NotDefined:
- jam();
- sngNodeptr.p->nodeGroup = ZNIL;
- break;
- default:
- ndbrequire(false);
- return;
- break;
- }//switch
- }//for
- cnoOfNodeGroups = 0;
- for (Ti = 0; Ti < MAX_NDB_NODES; Ti++) {
- jam();
- NGPtr.i = Ti;
- ptrAss(NGPtr, nodeGroupRecord);
- if (NGPtr.p->nodeCount != 0) {
- jam();
- cnoOfNodeGroups++;
- }//if
- }//for
- cnoHotSpare = csystemnodes - (cnoOfNodeGroups * cnoReplicas);
- }//Dbdih::setNodeGroups()
- /*************************************************************************/
- /* SET NODE INFORMATION AFTER RECEIVING RESTART INFORMATION FROM MASTER. */
- /* WE TAKE THE OPPORTUNITY TO SYNCHRONISE OUR DATA WITH THE MASTER. IT */
- /* IS ONLY THE MASTER THAT WILL ACT ON THIS DATA. WE WILL KEEP THEM */
- /* UPDATED FOR THE CASE WHEN WE HAVE TO BECOME MASTER. */
- /*************************************************************************/
- void Dbdih::setNodeInfo(Signal* signal)
- {
- setNodeActiveStatus();
- setNodeGroups();
- sendHOT_SPAREREP(signal);
- }//Dbdih::setNodeInfo()
- /*************************************************************************/
- // Keep also DBDICT informed about the Hot Spare situation in the cluster.
- /*************************************************************************/
- void Dbdih::sendHOT_SPAREREP(Signal* signal)
- {
- NodeRecordPtr locNodeptr;
- Uint32 Ti = 0;
- HotSpareRep * const hotSpare = (HotSpareRep*)&signal->theData[0];
- NodeBitmask::clear(hotSpare->theHotSpareNodes);
- for (locNodeptr.i = 1; locNodeptr.i < MAX_NDB_NODES; locNodeptr.i++) {
- ptrAss(locNodeptr, nodeRecord);
- switch (locNodeptr.p->activeStatus) {
- case Sysfile::NS_HotSpare:
- jam();
- NodeBitmask::set(hotSpare->theHotSpareNodes, locNodeptr.i);
- Ti++;
- break;
- default:
- jam();
- break;
- }//switch
- }//for
- hotSpare->noHotSpareNodes = Ti;
- sendSignal(DBDICT_REF, GSN_HOT_SPAREREP,
- signal, HotSpareRep::SignalLength, JBB);
- }//Dbdih::sendHOT_SPAREREP()
- /*************************************************************************/
- /* SET LCP ACTIVE STATUS FOR ALL NODES BASED ON THE INFORMATION IN */
- /* THE RESTART INFORMATION. */
- /*************************************************************************/
- #if 0
- void Dbdih::setNodeLcpActiveStatus()
- {
- c_lcpState.m_lcpActiveStatus.clear();
- for (Uint32 i = 1; i < MAX_NDB_NODES; i++) {
- if (NodeBitmask::get(SYSFILE->lcpActive, i)) {
- jam();
- c_lcpState.m_lcpActiveStatus.set(i);
- }//if
- }//for
- }//Dbdih::setNodeLcpActiveStatus()
- #endif
- /*************************************************************************/
- /* SET THE RESTART INFO BITS BASED ON THE NODES ACTIVE STATUS. */
- /*************************************************************************/
- void Dbdih::setNodeRestartInfoBits()
- {
- NodeRecordPtr nodePtr;
- Uint32 tsnrNodeGroup;
- Uint32 tsnrNodeActiveStatus;
- Uint32 i;
- for(i = 1; i < MAX_NDB_NODES; i++){
- Sysfile::setNodeStatus(i, SYSFILE->nodeStatus, Sysfile::NS_Active);
- }//for
- for(i = 1; i < Sysfile::NODE_GROUPS_SIZE; i++){
- SYSFILE->nodeGroups[i] = 0;
- }//for
- NdbNodeBitmask::clear(SYSFILE->lcpActive);
-
- for (nodePtr.i = 1; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) {
- ptrAss(nodePtr, nodeRecord);
- switch (nodePtr.p->activeStatus) {
- case Sysfile::NS_Active:
- jam();
- tsnrNodeActiveStatus = Sysfile::NS_Active;
- break;
- case Sysfile::NS_ActiveMissed_1:
- jam();
- tsnrNodeActiveStatus = Sysfile::NS_ActiveMissed_1;
- break;
- case Sysfile::NS_ActiveMissed_2:
- jam();
- tsnrNodeActiveStatus = Sysfile::NS_ActiveMissed_2;
- break;
- case Sysfile::NS_HotSpare:
- jam();
- tsnrNodeActiveStatus = Sysfile::NS_HotSpare;
- break;
- case Sysfile::NS_TakeOver:
- jam();
- tsnrNodeActiveStatus = Sysfile::NS_TakeOver;
- break;
- case Sysfile::NS_NotActive_NotTakenOver:
- jam();
- tsnrNodeActiveStatus = Sysfile::NS_NotActive_NotTakenOver;
- break;
- case Sysfile::NS_NotDefined:
- jam();
- tsnrNodeActiveStatus = Sysfile::NS_NotDefined;
- break;
- default:
- ndbrequire(false);
- tsnrNodeActiveStatus = Sysfile::NS_NotDefined; // remove warning
- break;
- }//switch
- Sysfile::setNodeStatus(nodePtr.i, SYSFILE->nodeStatus,
- tsnrNodeActiveStatus);
- if (nodePtr.p->nodeGroup == ZNIL) {
- jam();
- tsnrNodeGroup = NO_NODE_GROUP_ID;
- } else {
- jam();
- tsnrNodeGroup = nodePtr.p->nodeGroup;
- }//if
- Sysfile::setNodeGroup(nodePtr.i, SYSFILE->nodeGroups, tsnrNodeGroup);
- if (c_lcpState.m_participatingLQH.get(nodePtr.i)){
- jam();
- NodeBitmask::set(SYSFILE->lcpActive, nodePtr.i);
- }//if
- }//for
- }//Dbdih::setNodeRestartInfoBits()
- /*************************************************************************/
- /* START THE GLOBAL CHECKPOINT PROTOCOL IN MASTER AT START-UP */
- /*************************************************************************/
- void Dbdih::startGcp(Signal* signal)
- {
- cgcpStatus = GCP_READY;
- coldGcpStatus = cgcpStatus;
- coldGcpId = cnewgcp;
- cgcpSameCounter = 0;
- signal->theData[0] = DihContinueB::ZSTART_GCP;
- signal->theData[1] = 0;
- sendSignal(reference(), GSN_CONTINUEB, signal, 2, JBB);
- signal->theData[0] = DihContinueB::ZCHECK_GCP_STOP;
- sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 1);
- }//Dbdih::startGcp()
- void Dbdih::updateNodeInfo(FragmentstorePtr fragPtr)
- {
- ReplicaRecordPtr replicatePtr;
- Uint32 index = 0;
- replicatePtr.i = fragPtr.p->storedReplicas;
- do {
- jam();
- ptrCheckGuard(replicatePtr, creplicaFileSize, replicaRecord);
- ndbrequire(index < MAX_REPLICAS);
- fragPtr.p->activeNodes[index] = replicatePtr.p->procNode;
- index++;
- replicatePtr.i = replicatePtr.p->nextReplica;
- } while (replicatePtr.i != RNIL);
- fragPtr.p->fragReplicas = index;
- /* ----------------------------------------------------------------------- */
- // We switch primary to the preferred primary if the preferred primary is
- // in the list.
- /* ----------------------------------------------------------------------- */
- const Uint32 prefPrim = fragPtr.p->preferredPrimary;
- for (Uint32 i = 1; i < index; i++) {
- jam();
- ndbrequire(i < MAX_REPLICAS);
- if (fragPtr.p->activeNodes[i] == prefPrim){
- jam();
- Uint32 switchNode = fragPtr.p->activeNodes[0];
- fragPtr.p->activeNodes[0] = prefPrim;
- fragPtr.p->activeNodes[i] = switchNode;
- break;
- }//if
- }//for
- }//Dbdih::updateNodeInfo()
- void Dbdih::writeFragment(RWFragment* wf, FragmentstorePtr fragPtr)
- {
- writePageWord(wf, wf->fragId);
- writePageWord(wf, fragPtr.p->preferredPrimary);
- writePageWord(wf, fragPtr.p->noStoredReplicas);
- writePageWord(wf, fragPtr.p->noOldStoredReplicas);
- writePageWord(wf, fragPtr.p->distributionKey);
- }//Dbdih::writeFragment()
- void Dbdih::writePageWord(RWFragment* wf, Uint32 dataWord)
- {
- if (wf->wordIndex >= 2048) {
- jam();
- ndbrequire(wf->wordIndex == 2048);
- allocpage(wf->rwfPageptr);
- wf->wordIndex = 32;
- wf->pageIndex++;
- ndbrequire(wf->pageIndex < 8);
- wf->rwfTabPtr.p->pageRef[wf->pageIndex] = wf->rwfPageptr.i;
- wf->rwfTabPtr.p->noPages++;
- }//if
- wf->rwfPageptr.p->word[wf->wordIndex] = dataWord;
- wf->wordIndex++;
- }//Dbdih::writePageWord()
- void Dbdih::writeReplicas(RWFragment* wf, Uint32 replicaStartIndex)
- {
- ReplicaRecordPtr wfReplicaPtr;
- wfReplicaPtr.i = replicaStartIndex;
- while (wfReplicaPtr.i != RNIL) {
- jam();
- ptrCheckGuard(wfReplicaPtr, creplicaFileSize, replicaRecord);
- writePageWord(wf, wfReplicaPtr.p->procNode);
- writePageWord(wf, wfReplicaPtr.p->initialGci);
- writePageWord(wf, wfReplicaPtr.p->noCrashedReplicas);
- writePageWord(wf, wfReplicaPtr.p->nextLcp);
- Uint32 i;
- for (i = 0; i < MAX_LCP_STORED; i++) {
- writePageWord(wf, wfReplicaPtr.p->maxGciCompleted[i]);
- writePageWord(wf, wfReplicaPtr.p->maxGciStarted[i]);
- writePageWord(wf, wfReplicaPtr.p->lcpId[i]);
- writePageWord(wf, wfReplicaPtr.p->lcpStatus[i]);
- }//if
- for (i = 0; i < 8; i++) {
- writePageWord(wf, wfReplicaPtr.p->createGci[i]);
- writePageWord(wf, wfReplicaPtr.p->replicaLastGci[i]);
- }//if
- wfReplicaPtr.i = wfReplicaPtr.p->nextReplica;
- }//while
- }//Dbdih::writeReplicas()
- void Dbdih::writeRestorableGci(Signal* signal, FileRecordPtr filePtr)
- {
- for (Uint32 i = 0; i < Sysfile::SYSFILE_SIZE32; i++) {
- sysfileDataToFile[i] = sysfileData[i];
- }//for
- signal->theData[0] = filePtr.p->fileRef;
- signal->theData[1] = reference();
- signal->theData[2] = filePtr.i;
- signal->theData[3] = ZLIST_OF_PAIRS_SYNCH;
- signal->theData[4] = ZVAR_NO_CRESTART_INFO_TO_FILE;
- signal->theData[5] = 1; /* AMOUNT OF PAGES */
- signal->theData[6] = 0; /* MEMORY PAGE = 0 SINCE COMMON STORED VARIABLE */
- signal->theData[7] = 0;
- sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 8, JBA);
- }//Dbdih::writeRestorableGci()
- void Dbdih::writeTabfile(Signal* signal, TabRecord* tab, FileRecordPtr filePtr)
- {
- signal->theData[0] = filePtr.p->fileRef;
- signal->theData[1] = reference();
- signal->theData[2] = filePtr.i;
- signal->theData[3] = ZLIST_OF_PAIRS;
- signal->theData[4] = ZVAR_NO_WORD;
- signal->theData[5] = tab->noPages;
- for (Uint32 i = 0; i < tab->noPages; i++) {
- jam();
- signal->theData[6 + (2 * i)] = tab->pageRef[i];
- signal->theData[7 + (2 * i)] = i;
- }//for
- Uint32 length = 6 + (2 * tab->noPages);
- sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, length, JBA);
- }//Dbdih::writeTabfile()
- void Dbdih::execDEBUG_SIG(Signal* signal)
- {
- signal = signal; //Avoid compiler warnings
- }//Dbdih::execDEBUG_SIG()
- void
- Dbdih::execDUMP_STATE_ORD(Signal* signal)
- {
- DumpStateOrd * const & dumpState = (DumpStateOrd *)&signal->theData[0];
- if (dumpState->args[0] == DumpStateOrd::DihDumpNodeRestartInfo) {
- infoEvent("c_nodeStartMaster.blockLcp = %d, c_nodeStartMaster.blockGcp = %d, c_nodeStartMaster.wait = %d",
- c_nodeStartMaster.blockLcp, c_nodeStartMaster.blockGcp, c_nodeStartMaster.wait);
- infoEvent("cstartGcpNow = %d, cgcpStatus = %d",
- cstartGcpNow, cgcpStatus);
- infoEvent("cfirstVerifyQueue = %d, cverifyQueueCounter = %d",
- cfirstVerifyQueue, cverifyQueueCounter);
- infoEvent("cgcpOrderBlocked = %d, cgcpStartCounter = %d",
- cgcpOrderBlocked, cgcpStartCounter);
- }//if
- if (dumpState->args[0] == DumpStateOrd::DihDumpNodeStatusInfo) {
- NodeRecordPtr localNodePtr;
- infoEvent("Printing nodeStatus of all nodes");
- for (localNodePtr.i = 1; localNodePtr.i < MAX_NDB_NODES; localNodePtr.i++) {
- ptrAss(localNodePtr, nodeRecord);
- if (localNodePtr.p->nodeStatus != NodeRecord::NOT_IN_CLUSTER) {
- infoEvent("Node = %d has status = %d",
- localNodePtr.i, localNodePtr.p->nodeStatus);
- }//if
- }//for
- }//if
-
- if (dumpState->args[0] == DumpStateOrd::DihPrintFragmentation){
- infoEvent("Printing fragmentation of all tables --");
- for(Uint32 i = 0; i<ctabFileSize; i++){
- TabRecordPtr tabPtr;
- tabPtr.i = i;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
-
- if(tabPtr.p->tabStatus != TabRecord::TS_ACTIVE)
- continue;
-
- for(Uint32 j = 0; j < tabPtr.p->totalfragments; j++){
- FragmentstorePtr fragPtr;
- getFragstore(tabPtr.p, j, fragPtr);
-
- Uint32 nodeOrder[MAX_REPLICAS];
- const Uint32 noOfReplicas = extractNodeInfo(fragPtr.p, nodeOrder);
- char buf[100];
- BaseString::snprintf(buf, sizeof(buf), " Table %d Fragment %d - ", tabPtr.i, j);
- for(Uint32 k = 0; k < noOfReplicas; k++){
- char tmp[100];
- BaseString::snprintf(tmp, sizeof(tmp), "%d ", nodeOrder[k]);
- strcat(buf, tmp);
- }
- infoEvent(buf);
- }
- }
- }
-
- if (signal->theData[0] == 7000) {
- infoEvent("ctimer = %d, cgcpParticipantState = %d, cgcpStatus = %d",
- c_lcpState.ctimer, cgcpParticipantState, cgcpStatus);
- infoEvent("coldGcpStatus = %d, coldGcpId = %d, cmasterState = %d",
- coldGcpStatus, coldGcpId, cmasterState);
- infoEvent("cmasterTakeOverNode = %d, ctcCounter = %d",
- cmasterTakeOverNode, c_lcpState.ctcCounter);
- }//if
- if (signal->theData[0] == 7001) {
- infoEvent("c_lcpState.keepGci = %d",
- c_lcpState.keepGci);
- infoEvent("c_lcpState.lcpStatus = %d, clcpStartGcp = %d",
- c_lcpState.lcpStatus,
- c_lcpState.lcpStartGcp);
- infoEvent("cgcpStartCounter = %d, cimmediateLcpStart = %d",
- cgcpStartCounter, c_lcpState.immediateLcpStart);
- }//if
- if (signal->theData[0] == 7002) {
- infoEvent("cnoOfActiveTables = %d, cgcpDelay = %d",
- cnoOfActiveTables, cgcpDelay);
- infoEvent("cdictblockref = %d, cfailurenr = %d",
- cdictblockref, cfailurenr);
- infoEvent("con_lineNodes = %d, reference() = %d, creceivedfrag = %d",
- con_lineNodes, reference(), creceivedfrag);
- }//if
- if (signal->theData[0] == 7003) {
- infoEvent("cfirstAliveNode = %d, cgckptflag = %d",
- cfirstAliveNode, cgckptflag);
- infoEvent("clocallqhblockref = %d, clocaltcblockref = %d, cgcpOrderBlocked = %d",
- clocallqhblockref, clocaltcblockref, cgcpOrderBlocked);
- infoEvent("cstarttype = %d, csystemnodes = %d, currentgcp = %d",
- cstarttype, csystemnodes, currentgcp);
- }//if
- if (signal->theData[0] == 7004) {
- infoEvent("cmasterdihref = %d, cownNodeId = %d, cnewgcp = %d",
- cmasterdihref, cownNodeId, cnewgcp);
- infoEvent("cndbStartReqBlockref = %d, cremainingfrags = %d",
- cndbStartReqBlockref, cremainingfrags);
- infoEvent("cntrlblockref = %d, cgcpSameCounter = %d, coldgcp = %d",
- cntrlblockref, cgcpSameCounter, coldgcp);
- }//if
- if (signal->theData[0] == 7005) {
- infoEvent("crestartGci = %d",
- crestartGci);
- }//if
- if (signal->theData[0] == 7006) {
- infoEvent("clcpDelay = %d, cgcpMasterTakeOverState = %d",
- c_lcpState.clcpDelay, cgcpMasterTakeOverState);
- infoEvent("cmasterNodeId = %d", cmasterNodeId);
- infoEvent("cnoHotSpare = %d, c_nodeStartMaster.startNode = %d, c_nodeStartMaster.wait = %d",
- cnoHotSpare, c_nodeStartMaster.startNode, c_nodeStartMaster.wait);
- }//if
- if (signal->theData[0] == 7007) {
- infoEvent("c_nodeStartMaster.failNr = %d", c_nodeStartMaster.failNr);
- infoEvent("c_nodeStartMaster.startInfoErrorCode = %d",
- c_nodeStartMaster.startInfoErrorCode);
- infoEvent("c_nodeStartMaster.blockLcp = %d, c_nodeStartMaster.blockGcp = %d",
- c_nodeStartMaster.blockLcp, c_nodeStartMaster.blockGcp);
- }//if
- if (signal->theData[0] == 7008) {
- infoEvent("cfirstDeadNode = %d, cstartPhase = %d, cnoReplicas = %d",
- cfirstDeadNode, cstartPhase, cnoReplicas);
- infoEvent("cwaitLcpSr = %d",cwaitLcpSr);
- }//if
- if (signal->theData[0] == 7009) {
- infoEvent("ccalcOldestRestorableGci = %d, cnoOfNodeGroups = %d",
- c_lcpState.oldestRestorableGci, cnoOfNodeGroups);
- infoEvent("cstartGcpNow = %d",
- cstartGcpNow);
- infoEvent("crestartGci = %d",
- crestartGci);
- }//if
- if (signal->theData[0] == 7010) {
- infoEvent("cminHotSpareNodes = %d, c_lcpState.lcpStatusUpdatedPlace = %d, cLcpStart = %d",
- cminHotSpareNodes, c_lcpState.lcpStatusUpdatedPlace, c_lcpState.lcpStart);
- infoEvent("c_blockCommit = %d, c_blockCommitNo = %d",
- c_blockCommit, c_blockCommitNo);
- }//if
- if (signal->theData[0] == 7011){
- infoEvent("c_COPY_GCIREQ_Counter = %s",
- c_COPY_GCIREQ_Counter.getText());
- infoEvent("c_COPY_TABREQ_Counter = %s",
- c_COPY_TABREQ_Counter.getText());
- infoEvent("c_CREATE_FRAGREQ_Counter = %s",
- c_CREATE_FRAGREQ_Counter.getText());
- infoEvent("c_DIH_SWITCH_REPLICA_REQ_Counter = %s",
- c_DIH_SWITCH_REPLICA_REQ_Counter.getText());
- infoEvent("c_EMPTY_LCP_REQ_Counter = %s",c_EMPTY_LCP_REQ_Counter.getText());
- infoEvent("c_END_TOREQ_Counter = %s", c_END_TOREQ_Counter.getText());
- infoEvent("c_GCP_COMMIT_Counter = %s", c_GCP_COMMIT_Counter.getText());
- infoEvent("c_GCP_PREPARE_Counter = %s", c_GCP_PREPARE_Counter.getText());
- infoEvent("c_GCP_SAVEREQ_Counter = %s", c_GCP_SAVEREQ_Counter.getText());
- infoEvent("c_INCL_NODEREQ_Counter = %s", c_INCL_NODEREQ_Counter.getText());
- infoEvent("c_MASTER_GCPREQ_Counter = %s",
- c_MASTER_GCPREQ_Counter.getText());
- infoEvent("c_MASTER_LCPREQ_Counter = %s",
- c_MASTER_LCPREQ_Counter.getText());
- infoEvent("c_START_INFOREQ_Counter = %s",
- c_START_INFOREQ_Counter.getText());
- infoEvent("c_START_RECREQ_Counter = %s", c_START_RECREQ_Counter.getText());
- infoEvent("c_START_TOREQ_Counter = %s", c_START_TOREQ_Counter.getText());
- infoEvent("c_STOP_ME_REQ_Counter = %s", c_STOP_ME_REQ_Counter.getText());
- infoEvent("c_TC_CLOPSIZEREQ_Counter = %s",
- c_TC_CLOPSIZEREQ_Counter.getText());
- infoEvent("c_TCGETOPSIZEREQ_Counter = %s",
- c_TCGETOPSIZEREQ_Counter.getText());
- infoEvent("c_UPDATE_TOREQ_Counter = %s", c_UPDATE_TOREQ_Counter.getText());
- }
- if(signal->theData[0] == 7012){
- char buf[8*_NDB_NODE_BITMASK_SIZE+1];
- infoEvent("ParticipatingDIH = %s", c_lcpState.m_participatingDIH.getText(buf));
- infoEvent("ParticipatingLQH = %s", c_lcpState.m_participatingLQH.getText(buf));
- infoEvent("m_LCP_COMPLETE_REP_Counter_DIH = %s",
- c_lcpState.m_LCP_COMPLETE_REP_Counter_DIH.getText());
- infoEvent("m_LCP_COMPLETE_REP_Counter_LQH = %s",
- c_lcpState.m_LCP_COMPLETE_REP_Counter_LQH.getText());
- infoEvent("m_LAST_LCP_FRAG_ORD = %s",
- c_lcpState.m_LAST_LCP_FRAG_ORD.getText());
- infoEvent("m_LCP_COMPLETE_REP_From_Master_Received = %d",
- c_lcpState.m_LCP_COMPLETE_REP_From_Master_Received);
-
- NodeRecordPtr nodePtr;
- for (nodePtr.i = 1; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) {
- jam();
- ptrAss(nodePtr, nodeRecord);
- if(nodePtr.p->nodeStatus == NodeRecord::ALIVE){
- Uint32 i;
- for(i = 0; i<nodePtr.p->noOfStartedChkpt; i++){
- infoEvent("Node %d: started: table=%d fragment=%d replica=%d",
- nodePtr.i,
- nodePtr.p->startedChkpt[i].tableId,
- nodePtr.p->startedChkpt[i].fragId,
- nodePtr.p->startedChkpt[i].replicaPtr);
- }
-
- for(i = 0; i<nodePtr.p->noOfQueuedChkpt; i++){
- infoEvent("Node %d: queued: table=%d fragment=%d replica=%d",
- nodePtr.i,
- nodePtr.p->queuedChkpt[i].tableId,
- nodePtr.p->queuedChkpt[i].fragId,
- nodePtr.p->queuedChkpt[i].replicaPtr);
- }
- }
- }
- }
- if(dumpState->args[0] == 7019 && signal->getLength() == 2)
- {
- char buf2[8+1];
- NodeRecordPtr nodePtr;
- nodePtr.i = signal->theData[1];
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- infoEvent("NF Node %d tc: %d lqh: %d dih: %d dict: %d recNODE_FAILREP: %d",
- nodePtr.i,
- nodePtr.p->dbtcFailCompleted,
- nodePtr.p->dblqhFailCompleted,
- nodePtr.p->dbdihFailCompleted,
- nodePtr.p->dbdictFailCompleted,
- nodePtr.p->recNODE_FAILREP);
- infoEvent(" m_NF_COMPLETE_REP: %s m_nodefailSteps: %s",
- nodePtr.p->m_NF_COMPLETE_REP.getText(),
- nodePtr.p->m_nodefailSteps.getText(buf2));
- }
-
- if(dumpState->args[0] == 7020 && signal->getLength() > 3)
- {
- Uint32 gsn= signal->theData[1];
- Uint32 block= signal->theData[2];
- Uint32 length= signal->length() - 3;
- memmove(signal->theData, signal->theData+3, 4*length);
- sendSignal(numberToRef(block, getOwnNodeId()), gsn, signal, length, JBB);
-
- warningEvent("-- SENDING CUSTOM SIGNAL --");
- char buf[100], buf2[100];
- buf2[0]= 0;
- for(Uint32 i = 0; i<length; i++)
- {
- snprintf(buf, 100, "%s %.8x", buf2, signal->theData[i]);
- snprintf(buf2, 100, "%s", buf);
- }
- warningEvent("gsn: %d block: %s, length: %d theData: %s",
- gsn, getBlockName(block, "UNKNOWN"), length, buf);
- g_eventLogger.warning("-- SENDING CUSTOM SIGNAL --");
- g_eventLogger.warning("gsn: %d block: %s, length: %d theData: %s",
- gsn, getBlockName(block, "UNKNOWN"), length, buf);
- }
-
- if(dumpState->args[0] == DumpStateOrd::DihDumpLCPState){
- infoEvent("-- Node %d LCP STATE --", getOwnNodeId());
- infoEvent("lcpStatus = %d (update place = %d) ",
- c_lcpState.lcpStatus, c_lcpState.lcpStatusUpdatedPlace);
- infoEvent
- ("lcpStart = %d lcpStartGcp = %d keepGci = %d oldestRestorable = %d",
- c_lcpState.lcpStart, c_lcpState.lcpStartGcp,
- c_lcpState.keepGci, c_lcpState.oldestRestorableGci);
-
- infoEvent
- ("immediateLcpStart = %d masterLcpNodeId = %d",
- c_lcpState.immediateLcpStart,
- refToNode(c_lcpState.m_masterLcpDihRef));
- infoEvent("-- Node %d LCP STATE --", getOwnNodeId());
- }
- if(dumpState->args[0] == DumpStateOrd::DihDumpLCPMasterTakeOver){
- infoEvent("-- Node %d LCP MASTER TAKE OVER STATE --", getOwnNodeId());
- infoEvent
- ("c_lcpMasterTakeOverState.state = %d updatePlace = %d failedNodeId = %d",
- c_lcpMasterTakeOverState.state,
- c_lcpMasterTakeOverState.updatePlace,
- c_lcpMasterTakeOverState.failedNodeId);
-
- infoEvent("c_lcpMasterTakeOverState.minTableId = %u minFragId = %u",
- c_lcpMasterTakeOverState.minTableId,
- c_lcpMasterTakeOverState.minFragId);
-
- infoEvent("-- Node %d LCP MASTER TAKE OVER STATE --", getOwnNodeId());
- }
- if (signal->theData[0] == 7015){
- for(Uint32 i = 0; i<ctabFileSize; i++){
- TabRecordPtr tabPtr;
- tabPtr.i = i;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
-
- if(tabPtr.p->tabStatus != TabRecord::TS_ACTIVE)
- continue;
-
- infoEvent
- ("Table %d: TabCopyStatus: %d TabUpdateStatus: %d TabLcpStatus: %d",
- tabPtr.i,
- tabPtr.p->tabCopyStatus,
- tabPtr.p->tabUpdateState,
- tabPtr.p->tabLcpStatus);
- FragmentstorePtr fragPtr;
- for (Uint32 fid = 0; fid < tabPtr.p->totalfragments; fid++) {
- jam();
- getFragstore(tabPtr.p, fid, fragPtr);
-
- char buf[100], buf2[100];
- BaseString::snprintf(buf, sizeof(buf), " Fragment %d: noLcpReplicas==%d ",
- fid, fragPtr.p->noLcpReplicas);
-
- Uint32 num=0;
- ReplicaRecordPtr replicaPtr;
- replicaPtr.i = fragPtr.p->storedReplicas;
- do {
- ptrCheckGuard(replicaPtr, creplicaFileSize, replicaRecord);
- BaseString::snprintf(buf2, sizeof(buf2), "%s %d(on %d)=%d(%s)",
- buf, num,
- replicaPtr.p->procNode,
- replicaPtr.p->lcpIdStarted,
- replicaPtr.p->lcpOngoingFlag ? "Ongoing" : "Idle");
- BaseString::snprintf(buf, sizeof(buf), "%s", buf2);
-
- num++;
- replicaPtr.i = replicaPtr.p->nextReplica;
- } while (replicaPtr.i != RNIL);
- infoEvent(buf);
- }
- }
- }
- if(dumpState->args[0] == DumpStateOrd::EnableUndoDelayDataWrite){
- ndbout << "Dbdih:: delay write of datapages for table = "
- << dumpState->args[1]<< endl;
- // Send this dump to ACC and TUP
- EXECUTE_DIRECT(DBACC, GSN_DUMP_STATE_ORD, signal, 2);
- EXECUTE_DIRECT(DBTUP, GSN_DUMP_STATE_ORD, signal, 2);
-
- // Start immediate LCP
- c_lcpState.ctimer += (1 << c_lcpState.clcpDelay);
- return;
- }
- if (signal->theData[0] == DumpStateOrd::DihAllAllowNodeStart) {
- for (Uint32 i = 1; i < MAX_NDB_NODES; i++)
- setAllowNodeStart(i, true);
- return;
- }//if
- if (signal->theData[0] == DumpStateOrd::DihMinTimeBetweenLCP) {
- // Set time between LCP to min value
- ndbout << "Set time between LCP to min value" << endl;
- c_lcpState.clcpDelay = 0; // TimeBetweenLocalCheckpoints.min
- return;
- }
- if (signal->theData[0] == DumpStateOrd::DihMaxTimeBetweenLCP) {
- // Set time between LCP to max value
- ndbout << "Set time between LCP to max value" << endl;
- c_lcpState.clcpDelay = 31; // TimeBetweenLocalCheckpoints.max
- return;
- }
-
- if(dumpState->args[0] == 7098){
- if(signal->length() == 3){
- jam();
- infoEvent("startLcpRoundLoopLab(tabel=%d, fragment=%d)",
- signal->theData[1], signal->theData[2]);
- startLcpRoundLoopLab(signal, signal->theData[1], signal->theData[2]);
- return;
- } else {
- infoEvent("Invalid no of arguments to 7098 - startLcpRoundLoopLab -"
- " expected 2 (tableId, fragmentId)");
- }
- }
- if(dumpState->args[0] == DumpStateOrd::DihStartLcpImmediately){
- c_lcpState.ctimer += (1 << c_lcpState.clcpDelay);
- return;
- }
- }//Dbdih::execDUMP_STATE_ORD()
- void
- Dbdih::execPREP_DROP_TAB_REQ(Signal* signal){
- jamEntry();
-
- PrepDropTabReq* req = (PrepDropTabReq*)signal->getDataPtr();
-
- TabRecordPtr tabPtr;
- tabPtr.i = req->tableId;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
-
- Uint32 senderRef = req->senderRef;
- Uint32 senderData = req->senderData;
-
- PrepDropTabRef::ErrorCode err = PrepDropTabRef::OK;
- { /**
- * Check table state
- */
- bool ok = false;
- switch(tabPtr.p->tabStatus){
- case TabRecord::TS_IDLE:
- ok = true;
- jam();
- err = PrepDropTabRef::NoSuchTable;
- break;
- case TabRecord::TS_DROPPING:
- ok = true;
- jam();
- err = PrepDropTabRef::PrepDropInProgress;
- break;
- case TabRecord::TS_CREATING:
- jam();
- ok = true;
- break;
- case TabRecord::TS_ACTIVE:
- ok = true;
- jam();
- break;
- }
- ndbrequire(ok);
- }
- if(err != PrepDropTabRef::OK){
- jam();
- PrepDropTabRef* ref = (PrepDropTabRef*)signal->getDataPtrSend();
- ref->senderRef = reference();
- ref->senderData = senderData;
- ref->tableId = tabPtr.i;
- ref->errorCode = err;
- sendSignal(senderRef, GSN_PREP_DROP_TAB_REF, signal,
- PrepDropTabRef::SignalLength, JBB);
- return;
- }
- tabPtr.p->tabStatus = TabRecord::TS_DROPPING;
- tabPtr.p->m_prepDropTab.senderRef = senderRef;
- tabPtr.p->m_prepDropTab.senderData = senderData;
-
- if(isMaster()){
- /**
- * Remove from queue
- */
- NodeRecordPtr nodePtr;
- for (nodePtr.i = 1; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) {
- jam();
- ptrAss(nodePtr, nodeRecord);
- if (c_lcpState.m_participatingLQH.get(nodePtr.i)){
-
- Uint32 index = 0;
- Uint32 count = nodePtr.p->noOfQueuedChkpt;
- while(index < count){
- if(nodePtr.p->queuedChkpt[index].tableId == tabPtr.i){
- jam();
- // ndbout_c("Unqueuing %d", index);
-
- count--;
- for(Uint32 i = index; i<count; i++){
- jam();
- nodePtr.p->queuedChkpt[i] = nodePtr.p->queuedChkpt[i + 1];
- }
- } else {
- index++;
- }
- }
- nodePtr.p->noOfQueuedChkpt = count;
- }
- }
- }
-
- { /**
- * Check table lcp state
- */
-
- bool ok = false;
- switch(tabPtr.p->tabLcpStatus){
- case TabRecord::TLS_COMPLETED:
- case TabRecord::TLS_WRITING_TO_FILE:
- ok = true;
- jam();
- break;
- return;
- case TabRecord::TLS_ACTIVE:
- ok = true;
- jam();
-
- tabPtr.p->tabLcpStatus = TabRecord::TLS_COMPLETED;
-
- /**
- * First check if all fragments are done
- */
- if(checkLcpAllTablesDoneInLqh()){
- jam();
-
- ndbout_c("This is the last table");
-
- /**
- * Then check if saving of tab info is done for all tables
- */
- LcpStatus a = c_lcpState.lcpStatus;
- checkLcpCompletedLab(signal);
-
- if(a != c_lcpState.lcpStatus){
- ndbout_c("And all tables are written to already written disk");
- }
- }
- break;
- }
- ndbrequire(ok);
- }
-
- { /**
- * Send WaitDropTabReq to all LQH
- */
- WaitDropTabReq * req = (WaitDropTabReq*)signal->getDataPtrSend();
- req->tableId = tabPtr.i;
- req->senderRef = reference();
-
- NodeRecordPtr nodePtr;
- nodePtr.i = cfirstAliveNode;
- tabPtr.p->m_prepDropTab.waitDropTabCount.clearWaitingFor();
- while(nodePtr.i != RNIL){
- jam();
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
-
- tabPtr.p->m_prepDropTab.waitDropTabCount.setWaitingFor(nodePtr.i);
- sendSignal(calcLqhBlockRef(nodePtr.i), GSN_WAIT_DROP_TAB_REQ,
- signal, WaitDropTabReq::SignalLength, JBB);
-
- nodePtr.i = nodePtr.p->nextNode;
- }
- }
-
- waitDropTabWritingToFile(signal, tabPtr);
- }
- void
- Dbdih::waitDropTabWritingToFile(Signal* signal, TabRecordPtr tabPtr){
-
- if(tabPtr.p->tabLcpStatus == TabRecord::TLS_WRITING_TO_FILE){
- jam();
- signal->theData[0] = DihContinueB::WAIT_DROP_TAB_WRITING_TO_FILE;
- signal->theData[1] = tabPtr.i;
- sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 2);
- return;
- }
- ndbrequire(tabPtr.p->tabLcpStatus == TabRecord::TLS_COMPLETED);
- checkPrepDropTabComplete(signal, tabPtr);
- }
- void
- Dbdih::checkPrepDropTabComplete(Signal* signal, TabRecordPtr tabPtr){
-
- if(tabPtr.p->tabLcpStatus != TabRecord::TLS_COMPLETED){
- jam();
- return;
- }
-
- if(!tabPtr.p->m_prepDropTab.waitDropTabCount.done()){
- jam();
- return;
- }
-
- const Uint32 ref = tabPtr.p->m_prepDropTab.senderRef;
- if(ref != 0){
- PrepDropTabConf* conf = (PrepDropTabConf*)signal->getDataPtrSend();
- conf->tableId = tabPtr.i;
- conf->senderRef = reference();
- conf->senderData = tabPtr.p->m_prepDropTab.senderData;
- sendSignal(tabPtr.p->m_prepDropTab.senderRef, GSN_PREP_DROP_TAB_CONF,
- signal, PrepDropTabConf::SignalLength, JBB);
- tabPtr.p->m_prepDropTab.senderRef = 0;
- }
- }
-
- void
- Dbdih::execWAIT_DROP_TAB_REF(Signal* signal){
- jamEntry();
- WaitDropTabRef * ref = (WaitDropTabRef*)signal->getDataPtr();
-
- TabRecordPtr tabPtr;
- tabPtr.i = ref->tableId;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
-
- ndbrequire(tabPtr.p->tabStatus == TabRecord::TS_DROPPING);
- Uint32 nodeId = refToNode(ref->senderRef);
-
- ndbrequire(ref->errorCode == WaitDropTabRef::NoSuchTable ||
- ref->errorCode == WaitDropTabRef::NF_FakeErrorREF);
- tabPtr.p->m_prepDropTab.waitDropTabCount.clearWaitingFor(nodeId);
- checkPrepDropTabComplete(signal, tabPtr);
- }
- void
- Dbdih::execWAIT_DROP_TAB_CONF(Signal* signal){
- jamEntry();
- WaitDropTabConf * conf = (WaitDropTabConf*)signal->getDataPtr();
-
- TabRecordPtr tabPtr;
- tabPtr.i = conf->tableId;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
-
- ndbrequire(tabPtr.p->tabStatus == TabRecord::TS_DROPPING);
- Uint32 nodeId = refToNode(conf->senderRef);
- tabPtr.p->m_prepDropTab.waitDropTabCount.clearWaitingFor(nodeId);
- checkPrepDropTabComplete(signal, tabPtr);
- }
- void
- Dbdih::checkWaitDropTabFailedLqh(Signal* signal, Uint32 nodeId, Uint32 tableId){
-
- TabRecordPtr tabPtr;
- tabPtr.i = tableId;
- WaitDropTabConf * conf = (WaitDropTabConf*)signal->getDataPtr();
- conf->tableId = tableId;
- const Uint32 RT_BREAK = 16;
- for(Uint32 i = 0; i<RT_BREAK && tabPtr.i < ctabFileSize; i++, tabPtr.i++){
- ptrAss(tabPtr, tabRecord);
- if(tabPtr.p->tabStatus == TabRecord::TS_DROPPING){
- if(tabPtr.p->m_prepDropTab.waitDropTabCount.isWaitingFor(nodeId)){
- conf->senderRef = calcLqhBlockRef(nodeId);
- execWAIT_DROP_TAB_CONF(signal);
- tabPtr.i++;
- break;
- }
- }
- }
-
- if(tabPtr.i == ctabFileSize){
- /**
- * Finished
- */
- jam();
- return;
- }
-
- signal->theData[0] = DihContinueB::CHECK_WAIT_DROP_TAB_FAILED_LQH;
- signal->theData[1] = nodeId;
- signal->theData[2] = tabPtr.i;
- sendSignal(reference(), GSN_CONTINUEB, signal, 3, JBB);
- }
- void
- Dbdih::execNDB_TAMPER(Signal* signal)
- {
- if ((ERROR_INSERTED(7011)) &&
- (signal->theData[0] == 7012)) {
- CLEAR_ERROR_INSERT_VALUE;
- calculateKeepGciLab(signal, 0, 0);
- return;
- }//if
- SET_ERROR_INSERT_VALUE(signal->theData[0]);
- return;
- }//Dbdih::execNDB_TAMPER()
- void Dbdih::execSET_VAR_REQ(Signal* signal) {
- #if 0
- SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0];
- ConfigParamId var = setVarReq->variable();
- int val = setVarReq->value();
- switch (var) {
- case TimeBetweenLocalCheckpoints:
- c_lcpState.clcpDelay = val;
- sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB);
- break;
- case TimeBetweenGlobalCheckpoints:
- cgcpDelay = val;
- sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB);
- break;
- default:
- sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB);
- } // switch
- #endif
- }
- void Dbdih::execBLOCK_COMMIT_ORD(Signal* signal){
- BlockCommitOrd* const block = (BlockCommitOrd *)&signal->theData[0];
- jamEntry();
- #if 0
- ndbrequire(c_blockCommit == false ||
- c_blockCommitNo == block->failNo);
- #else
- if(!(c_blockCommit == false || c_blockCommitNo == block->failNo)){
- infoEvent("Possible bug in Dbdih::execBLOCK_COMMIT_ORD c_blockCommit = %d c_blockCommitNo = %d"
- " sig->failNo = %d", c_blockCommit, c_blockCommitNo, block->failNo);
- }
- #endif
- c_blockCommit = true;
- c_blockCommitNo = block->failNo;
- }
- void Dbdih::execUNBLOCK_COMMIT_ORD(Signal* signal){
- UnblockCommitOrd* const unblock = (UnblockCommitOrd *)&signal->theData[0];
- (void)unblock;
- jamEntry();
-
- if(c_blockCommit == true){
- jam();
- // ndbrequire(c_blockCommitNo == unblock->failNo);
-
- c_blockCommit = false;
- emptyverificbuffer(signal, true);
- }
- }
- void Dbdih::execSTOP_PERM_REQ(Signal* signal){
- jamEntry();
-
- StopPermReq* const req = (StopPermReq*)&signal->theData[0];
- StopPermRef* const ref = (StopPermRef*)&signal->theData[0];
-
- const Uint32 senderData = req->senderData;
- const BlockReference senderRef = req->senderRef;
- const NodeId nodeId = refToNode(senderRef);
-
- if (isMaster()) {
- /**
- * Master
- */
- jam();
- CRASH_INSERTION(7065);
- if (c_stopPermMaster.clientRef != 0) {
- jam();
- ref->senderData = senderData;
- ref->errorCode = StopPermRef::NodeShutdownInProgress;
- sendSignal(senderRef, GSN_STOP_PERM_REF, signal,
- StopPermRef::SignalLength, JBB);
- return;
- }//if
-
- if (c_nodeStartMaster.activeState) {
- jam();
- ref->senderData = senderData;
- ref->errorCode = StopPermRef::NodeStartInProgress;
- sendSignal(senderRef, GSN_STOP_PERM_REF, signal,
- StopPermRef::SignalLength, JBB);
- return;
- }//if
-
- /**
- * Lock
- */
- c_nodeStartMaster.activeState = true;
- c_stopPermMaster.clientRef = senderRef;
- c_stopPermMaster.clientData = senderData;
- c_stopPermMaster.returnValue = 0;
- c_switchReplicas.clear();
- Mutex mutex(signal, c_mutexMgr, c_switchPrimaryMutexHandle);
- Callback c = { safe_cast(&Dbdih::switch_primary_stop_node), nodeId };
- ndbrequire(mutex.lock(c));
- } else {
- /**
- * Proxy part
- */
- jam();
- CRASH_INSERTION(7066);
- if(c_stopPermProxy.clientRef != 0){
- jam();
- ref->senderData = senderData;
- ref->errorCode = StopPermRef::NodeShutdownInProgress;
- sendSignal(senderRef, GSN_STOP_PERM_REF, signal, 2, JBB);
- return;
- }//if
-
- c_stopPermProxy.clientRef = senderRef;
- c_stopPermProxy.masterRef = cmasterdihref;
- c_stopPermProxy.clientData = senderData;
-
- req->senderRef = reference();
- req->senderData = senderData;
- sendSignal(cmasterdihref, GSN_STOP_PERM_REQ, signal,
- StopPermReq::SignalLength, JBB);
- }//if
- }//Dbdih::execSTOP_PERM_REQ()
- void
- Dbdih::switch_primary_stop_node(Signal* signal, Uint32 node_id, Uint32 ret_val)
- {
- ndbrequire(ret_val == 0);
- signal->theData[0] = DihContinueB::SwitchReplica;
- signal->theData[1] = node_id;
- signal->theData[2] = 0; // table id
- signal->theData[3] = 0; // fragment id
- sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
- }
- void Dbdih::execSTOP_PERM_REF(Signal* signal)
- {
- jamEntry();
- ndbrequire(c_stopPermProxy.clientRef != 0);
- ndbrequire(c_stopPermProxy.masterRef == signal->senderBlockRef());
- sendSignal(c_stopPermProxy.clientRef, GSN_STOP_PERM_REF, signal, 2, JBB);
- c_stopPermProxy.clientRef = 0;
- }//Dbdih::execSTOP_PERM_REF()
- void Dbdih::execSTOP_PERM_CONF(Signal* signal)
- {
- jamEntry();
- ndbrequire(c_stopPermProxy.clientRef != 0);
- ndbrequire(c_stopPermProxy.masterRef == signal->senderBlockRef());
- sendSignal(c_stopPermProxy.clientRef, GSN_STOP_PERM_CONF, signal, 1, JBB);
- c_stopPermProxy.clientRef = 0;
- }//Dbdih::execSTOP_PERM_CONF()
- void Dbdih::execDIH_SWITCH_REPLICA_REQ(Signal* signal)
- {
- jamEntry();
- DihSwitchReplicaReq* const req = (DihSwitchReplicaReq*)&signal->theData[0];
- const Uint32 tableId = req->tableId;
- const Uint32 fragNo = req->fragNo;
- const BlockReference senderRef = req->senderRef;
- CRASH_INSERTION(7067);
- TabRecordPtr tabPtr;
- tabPtr.i = tableId;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
- ndbrequire(tabPtr.p->tabStatus == TabRecord::TS_ACTIVE);
- if (tabPtr.p->tabCopyStatus != TabRecord::CS_IDLE) {
- jam();
- sendSignal(reference(), GSN_DIH_SWITCH_REPLICA_REQ, signal,
- DihSwitchReplicaReq::SignalLength, JBB);
- return;
- }//if
- FragmentstorePtr fragPtr;
- getFragstore(tabPtr.p, fragNo, fragPtr);
-
- /**
- * Do funky stuff
- */
- Uint32 oldOrder[MAX_REPLICAS];
- const Uint32 noOfReplicas = extractNodeInfo(fragPtr.p, oldOrder);
-
- if (noOfReplicas < req->noOfReplicas) {
- jam();
- //---------------------------------------------------------------------
- // A crash occurred in the middle of our switch handling.
- //---------------------------------------------------------------------
- DihSwitchReplicaRef* const ref = (DihSwitchReplicaRef*)&signal->theData[0];
- ref->senderNode = cownNodeId;
- ref->errorCode = StopPermRef::NF_CausedAbortOfStopProcedure;
- sendSignal(senderRef, GSN_DIH_SWITCH_REPLICA_REF, signal,
- DihSwitchReplicaRef::SignalLength, JBB);
- }//if
- for (Uint32 i = 0; i < noOfReplicas; i++) {
- jam();
- ndbrequire(i < MAX_REPLICAS);
- fragPtr.p->activeNodes[i] = req->newNodeOrder[i];
- }//for
- /**
- * Reply
- */
- DihSwitchReplicaConf* const conf = (DihSwitchReplicaConf*)&signal->theData[0];
- conf->senderNode = cownNodeId;
- sendSignal(senderRef, GSN_DIH_SWITCH_REPLICA_CONF, signal,
- DihSwitchReplicaConf::SignalLength, JBB);
- }//Dbdih::execDIH_SWITCH_REPLICA_REQ()
- void Dbdih::execDIH_SWITCH_REPLICA_CONF(Signal* signal)
- {
- jamEntry();
- /**
- * Response to master
- */
- CRASH_INSERTION(7068);
- DihSwitchReplicaConf* const conf = (DihSwitchReplicaConf*)&signal->theData[0];
- switchReplicaReply(signal, conf->senderNode);
- }//Dbdih::execDIH_SWITCH_REPLICA_CONF()
- void Dbdih::execDIH_SWITCH_REPLICA_REF(Signal* signal)
- {
- jamEntry();
- DihSwitchReplicaRef* const ref = (DihSwitchReplicaRef*)&signal->theData[0];
- if(c_stopPermMaster.returnValue == 0){
- jam();
- c_stopPermMaster.returnValue = ref->errorCode;
- }//if
- switchReplicaReply(signal, ref->senderNode);
- }//Dbdih::execDIH_SWITCH_REPLICA_REF()
- void Dbdih::switchReplicaReply(Signal* signal,
- NodeId nodeId){
- jam();
- receiveLoopMacro(DIH_SWITCH_REPLICA_REQ, nodeId);
- //------------------------------------------------------
- // We have received all responses from the nodes. Thus
- // we have completed switching replica roles. Continue
- // with the next fragment.
- //------------------------------------------------------
- if(c_stopPermMaster.returnValue != 0){
- jam();
- c_switchReplicas.tableId = ctabFileSize + 1;
- }//if
- c_switchReplicas.fragNo++;
- signal->theData[0] = DihContinueB::SwitchReplica;
- signal->theData[1] = c_switchReplicas.nodeId;
- signal->theData[2] = c_switchReplicas.tableId;
- signal->theData[3] = c_switchReplicas.fragNo;
- sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
- }//Dbdih::switchReplicaReply()
- void
- Dbdih::switchReplica(Signal* signal,
- Uint32 nodeId,
- Uint32 tableId,
- Uint32 fragNo){
- jam();
- DihSwitchReplicaReq* const req = (DihSwitchReplicaReq*)&signal->theData[0];
- const Uint32 RT_BREAK = 64;
-
- for (Uint32 i = 0; i < RT_BREAK; i++) {
- jam();
- if (tableId >= ctabFileSize) {
- jam();
- StopPermConf* const conf = (StopPermConf*)&signal->theData[0];
- StopPermRef* const ref = (StopPermRef*)&signal->theData[0];
- /**
- * Finished with all tables
- */
- if(c_stopPermMaster.returnValue == 0) {
- jam();
- conf->senderData = c_stopPermMaster.clientData;
- sendSignal(c_stopPermMaster.clientRef, GSN_STOP_PERM_CONF,
- signal, 1, JBB);
- } else {
- jam();
- ref->senderData = c_stopPermMaster.clientData;
- ref->errorCode = c_stopPermMaster.returnValue;
- sendSignal(c_stopPermMaster.clientRef, GSN_STOP_PERM_REF, signal, 2,JBB);
- }//if
-
- /**
- * UnLock
- */
- c_nodeStartMaster.activeState = false;
- c_stopPermMaster.clientRef = 0;
- c_stopPermMaster.clientData = 0;
- c_stopPermMaster.returnValue = 0;
- Mutex mutex(signal, c_mutexMgr, c_switchPrimaryMutexHandle);
- mutex.unlock(); // ignore result
- return;
- }//if
-
- TabRecordPtr tabPtr;
- tabPtr.i = tableId;
- ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
-
- if (tabPtr.p->tabStatus != TabRecord::TS_ACTIVE) {
- jam();
- tableId++;
- fragNo = 0;
- continue;
- }//if
- if (fragNo >= tabPtr.p->totalfragments) {
- jam();
- tableId++;
- fragNo = 0;
- continue;
- }//if
- FragmentstorePtr fragPtr;
- getFragstore(tabPtr.p, fragNo, fragPtr);
-
- Uint32 oldOrder[MAX_REPLICAS];
- const Uint32 noOfReplicas = extractNodeInfo(fragPtr.p, oldOrder);
- if(oldOrder[0] != nodeId) {
- jam();
- fragNo++;
- continue;
- }//if
- req->tableId = tableId;
- req->fragNo = fragNo;
- req->noOfReplicas = noOfReplicas;
- for (Uint32 i = 0; i < (noOfReplicas - 1); i++) {
- req->newNodeOrder[i] = oldOrder[i+1];
- }//for
- req->newNodeOrder[noOfReplicas-1] = nodeId;
- req->senderRef = reference();
-
- /**
- * Initialize struct
- */
- c_switchReplicas.tableId = tableId;
- c_switchReplicas.fragNo = fragNo;
- c_switchReplicas.nodeId = nodeId;
- sendLoopMacro(DIH_SWITCH_REPLICA_REQ, sendDIH_SWITCH_REPLICA_REQ);
- return;
- }//for
- signal->theData[0] = DihContinueB::SwitchReplica;
- signal->theData[1] = nodeId;
- signal->theData[2] = tableId;
- signal->theData[3] = fragNo;
- sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
- }//Dbdih::switchReplica()
- void Dbdih::execSTOP_ME_REQ(Signal* signal)
- {
- jamEntry();
- StopMeReq* const req = (StopMeReq*)&signal->theData[0];
- const BlockReference senderRef = req->senderRef;
- const Uint32 senderData = req->senderData;
- const Uint32 nodeId = refToNode(senderRef);
- {
- /**
- * Set node dead (remove from operations)
- */
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- nodePtr.p->useInTransactions = false;
- }
- if (nodeId != getOwnNodeId()) {
- jam();
- StopMeConf * const stopMeConf = (StopMeConf *)&signal->theData[0];
- stopMeConf->senderData = senderData;
- stopMeConf->senderRef = reference();
- sendSignal(senderRef, GSN_STOP_ME_CONF, signal,
- StopMeConf::SignalLength, JBB);
- return;
- }//if
-
- /**
- * Local signal
- */
- jam();
- ndbrequire(c_stopMe.clientRef == 0);
-
- c_stopMe.clientData = senderData;
- c_stopMe.clientRef = senderRef;
-
- req->senderData = senderData;
- req->senderRef = reference();
- sendLoopMacro(STOP_ME_REQ, sendSTOP_ME_REQ);
- /**
- * Send conf to self
- */
- StopMeConf * const stopMeConf = (StopMeConf *)&signal->theData[0];
- stopMeConf->senderData = senderData;
- stopMeConf->senderRef = reference();
- sendSignal(reference(), GSN_STOP_ME_CONF, signal,
- StopMeConf::SignalLength, JBB);
- }//Dbdih::execSTOP_ME_REQ()
- void Dbdih::execSTOP_ME_REF(Signal* signal)
- {
- ndbrequire(false);
- }
- void Dbdih::execSTOP_ME_CONF(Signal* signal)
- {
- jamEntry();
- StopMeConf * const stopMeConf = (StopMeConf *)&signal->theData[0];
-
- const Uint32 senderRef = stopMeConf->senderRef;
- const Uint32 senderData = stopMeConf->senderData;
- const Uint32 nodeId = refToNode(senderRef);
- ndbrequire(c_stopMe.clientRef != 0);
- ndbrequire(c_stopMe.clientData == senderData);
- receiveLoopMacro(STOP_ME_REQ, nodeId);
- //---------------------------------------------------------
- // All STOP_ME_REQ have been received. We will send the
- // confirmation back to the requesting block.
- //---------------------------------------------------------
- stopMeConf->senderRef = reference();
- stopMeConf->senderData = c_stopMe.clientData;
- sendSignal(c_stopMe.clientRef, GSN_STOP_ME_CONF, signal,
- StopMeConf::SignalLength, JBB);
- c_stopMe.clientRef = 0;
- }//Dbdih::execSTOP_ME_CONF()
- void Dbdih::execWAIT_GCP_REQ(Signal* signal)
- {
- jamEntry();
- WaitGCPReq* const req = (WaitGCPReq*)&signal->theData[0];
- WaitGCPRef* const ref = (WaitGCPRef*)&signal->theData[0];
- WaitGCPConf* const conf = (WaitGCPConf*)&signal->theData[0];
- const Uint32 senderData = req->senderData;
- const BlockReference senderRef = req->senderRef;
- const Uint32 requestType = req->requestType;
- if(requestType == WaitGCPReq::CurrentGCI) {
- jam();
- conf->senderData = senderData;
- conf->gcp = cnewgcp;
- sendSignal(senderRef, GSN_WAIT_GCP_CONF, signal,
- WaitGCPConf::SignalLength, JBB);
- return;
- }//if
- if(isMaster()) {
- /**
- * Master
- */
- jam();
- if((requestType == WaitGCPReq::CompleteIfRunning) &&
- (cgcpStatus == GCP_READY)) {
- jam();
- conf->senderData = senderData;
- conf->gcp = coldgcp;
- sendSignal(senderRef, GSN_WAIT_GCP_CONF, signal,
- WaitGCPConf::SignalLength, JBB);
- return;
- }//if
- WaitGCPMasterPtr ptr;
- if(c_waitGCPMasterList.seize(ptr) == false){
- jam();
- ref->senderData = senderData;
- ref->errorCode = WaitGCPRef::NoWaitGCPRecords;
- sendSignal(senderRef, GSN_WAIT_GCP_REF, signal,
- WaitGCPRef::SignalLength, JBB);
- return;
- }//if
- ptr.p->clientRef = senderRef;
- ptr.p->clientData = senderData;
-
- if((requestType == WaitGCPReq::CompleteForceStart) &&
- (cgcpStatus == GCP_READY)) {
- jam();
- cstartGcpNow = true;
- }//if
- return;
- } else {
- /**
- * Proxy part
- */
- jam();
- WaitGCPProxyPtr ptr;
- if (c_waitGCPProxyList.seize(ptr) == false) {
- jam();
- ref->senderData = senderData;
- ref->errorCode = WaitGCPRef::NoWaitGCPRecords;
- sendSignal(senderRef, GSN_WAIT_GCP_REF, signal,
- WaitGCPRef::SignalLength, JBB);
- return;
- }//if
- ptr.p->clientRef = senderRef;
- ptr.p->clientData = senderData;
- ptr.p->masterRef = cmasterdihref;
- req->senderData = ptr.i;
- req->senderRef = reference();
- req->requestType = requestType;
- sendSignal(cmasterdihref, GSN_WAIT_GCP_REQ, signal,
- WaitGCPReq::SignalLength, JBB);
- return;
- }//if
- }//Dbdih::execWAIT_GCP_REQ()
- void Dbdih::execWAIT_GCP_REF(Signal* signal)
- {
- jamEntry();
- ndbrequire(!isMaster());
- WaitGCPRef* const ref = (WaitGCPRef*)&signal->theData[0];
-
- const Uint32 proxyPtr = ref->senderData;
- const Uint32 errorCode = ref->errorCode;
-
- WaitGCPProxyPtr ptr;
- ptr.i = proxyPtr;
- c_waitGCPProxyList.getPtr(ptr);
- ref->senderData = ptr.p->clientData;
- ref->errorCode = errorCode;
- sendSignal(ptr.p->clientRef, GSN_WAIT_GCP_REF, signal,
- WaitGCPRef::SignalLength, JBB);
- c_waitGCPProxyList.release(ptr);
- }//Dbdih::execWAIT_GCP_REF()
- void Dbdih::execWAIT_GCP_CONF(Signal* signal)
- {
- jamEntry();
- ndbrequire(!isMaster());
- WaitGCPConf* const conf = (WaitGCPConf*)&signal->theData[0];
- const Uint32 proxyPtr = conf->senderData;
- const Uint32 gcp = conf->gcp;
- WaitGCPProxyPtr ptr;
- ptr.i = proxyPtr;
- c_waitGCPProxyList.getPtr(ptr);
- conf->senderData = ptr.p->clientData;
- conf->gcp = gcp;
- sendSignal(ptr.p->clientRef, GSN_WAIT_GCP_CONF, signal,
- WaitGCPConf::SignalLength, JBB);
-
- c_waitGCPProxyList.release(ptr);
- }//Dbdih::execWAIT_GCP_CONF()
- void Dbdih::checkWaitGCPProxy(Signal* signal, NodeId failedNodeId)
- {
- jam();
- WaitGCPRef* const ref = (WaitGCPRef*)&signal->theData[0];
- ref->errorCode = WaitGCPRef::NF_CausedAbortOfProcedure;
- WaitGCPProxyPtr ptr;
- c_waitGCPProxyList.first(ptr);
- while(ptr.i != RNIL) {
- jam();
- const Uint32 i = ptr.i;
- const Uint32 clientData = ptr.p->clientData;
- const BlockReference clientRef = ptr.p->clientRef;
- const BlockReference masterRef = ptr.p->masterRef;
-
- c_waitGCPProxyList.next(ptr);
- if(refToNode(masterRef) == failedNodeId) {
- jam();
- c_waitGCPProxyList.release(i);
- ref->senderData = clientData;
- sendSignal(clientRef, GSN_WAIT_GCP_REF, signal,
- WaitGCPRef::SignalLength, JBB);
- }//if
- }//while
- }//Dbdih::checkWaitGCPProxy()
- void Dbdih::checkWaitGCPMaster(Signal* signal, NodeId failedNodeId)
- {
- jam();
- WaitGCPMasterPtr ptr;
- c_waitGCPMasterList.first(ptr);
- while (ptr.i != RNIL) {
- jam();
- const Uint32 i = ptr.i;
- const NodeId nodeId = refToNode(ptr.p->clientRef);
-
- c_waitGCPMasterList.next(ptr);
- if (nodeId == failedNodeId) {
- jam()
- c_waitGCPMasterList.release(i);
- }//if
- }//while
- }//Dbdih::checkWaitGCPMaster()
- void Dbdih::emptyWaitGCPMasterQueue(Signal* signal)
- {
- jam();
- WaitGCPConf* const conf = (WaitGCPConf*)&signal->theData[0];
- conf->gcp = coldgcp;
-
- WaitGCPMasterPtr ptr;
- c_waitGCPMasterList.first(ptr);
- while(ptr.i != RNIL) {
- jam();
- const Uint32 i = ptr.i;
- const Uint32 clientData = ptr.p->clientData;
- const BlockReference clientRef = ptr.p->clientRef;
- c_waitGCPMasterList.next(ptr);
- conf->senderData = clientData;
- sendSignal(clientRef, GSN_WAIT_GCP_CONF, signal,
- WaitGCPConf::SignalLength, JBB);
-
- c_waitGCPMasterList.release(i);
- }//while
- }//Dbdih::emptyWaitGCPMasterQueue()
- void Dbdih::setNodeStatus(Uint32 nodeId, NodeRecord::NodeStatus newStatus)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- nodePtr.p->nodeStatus = newStatus;
- }//Dbdih::setNodeStatus()
- Dbdih::NodeRecord::NodeStatus Dbdih::getNodeStatus(Uint32 nodeId)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- return nodePtr.p->nodeStatus;
- }//Dbdih::getNodeStatus()
- Sysfile::ActiveStatus
- Dbdih::getNodeActiveStatus(Uint32 nodeId)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- return nodePtr.p->activeStatus;
- }//Dbdih::getNodeActiveStatus()
- void
- Dbdih::setNodeActiveStatus(Uint32 nodeId, Sysfile::ActiveStatus newStatus)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- nodePtr.p->activeStatus = newStatus;
- }//Dbdih::setNodeActiveStatus()
- void Dbdih::setAllowNodeStart(Uint32 nodeId, bool newState)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- nodePtr.p->allowNodeStart = newState;
- }//Dbdih::setAllowNodeStart()
- void Dbdih::setNodeCopyCompleted(Uint32 nodeId, bool newState)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- nodePtr.p->copyCompleted = newState;
- }//Dbdih::setNodeCopyCompleted()
- bool Dbdih::getAllowNodeStart(Uint32 nodeId)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- return nodePtr.p->allowNodeStart;
- }//Dbdih::getAllowNodeStart()
- bool Dbdih::getNodeCopyCompleted(Uint32 nodeId)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- return nodePtr.p->copyCompleted;
- }//Dbdih::getNodeCopyCompleted()
- bool Dbdih::checkNodeAlive(Uint32 nodeId)
- {
- NodeRecordPtr nodePtr;
- nodePtr.i = nodeId;
- ndbrequire(nodeId > 0);
- ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
- if (nodePtr.p->nodeStatus != NodeRecord::ALIVE) {
- return false;
- } else {
- return true;
- }//if
- }//Dbdih::checkNodeAlive()
- bool Dbdih::isMaster()
- {
- return (reference() == cmasterdihref);
- }//Dbdih::isMaster()
- bool Dbdih::isActiveMaster()
- {
- return ((reference() == cmasterdihref) && (cmasterState == MASTER_ACTIVE));
- }//Dbdih::isActiveMaster()
- Dbdih::NodeRecord::NodeRecord(){
- m_nodefailSteps.clear();
- gcpstate = NodeRecord::READY;
- activeStatus = Sysfile::NS_NotDefined;
- recNODE_FAILREP = ZFALSE;
- nodeGroup = ZNIL;
- dbtcFailCompleted = ZTRUE;
- dbdictFailCompleted = ZTRUE;
- dbdihFailCompleted = ZTRUE;
- dblqhFailCompleted = ZTRUE;
- noOfStartedChkpt = 0;
- noOfQueuedChkpt = 0;
- lcpStateAtTakeOver = (MasterLCPConf::State)255;
- activeTabptr = RNIL;
- nodeStatus = NodeRecord::NOT_IN_CLUSTER;
- useInTransactions = false;
- copyCompleted = false;
- allowNodeStart = true;
- }