00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define NDBCNTR_C
00018 #include "Ndbcntr.hpp"
00019
00020 #include <ndb_limits.h>
00021 #include <ndb_version.h>
00022 #include <SimpleProperties.hpp>
00023 #include <signaldata/DictTabInfo.hpp>
00024 #include <signaldata/CreateTable.hpp>
00025 #include <signaldata/ReadNodesConf.hpp>
00026 #include <signaldata/NodeFailRep.hpp>
00027 #include <signaldata/TcKeyReq.hpp>
00028 #include <signaldata/TcKeyConf.hpp>
00029 #include <signaldata/EventReport.hpp>
00030 #include <signaldata/NodeStateSignalData.hpp>
00031 #include <signaldata/StopPerm.hpp>
00032 #include <signaldata/StopMe.hpp>
00033 #include <signaldata/WaitGCP.hpp>
00034 #include <signaldata/CheckNodeGroups.hpp>
00035 #include <signaldata/StartOrd.hpp>
00036 #include <signaldata/AbortAll.hpp>
00037 #include <signaldata/SystemError.hpp>
00038 #include <signaldata/NdbSttor.hpp>
00039 #include <signaldata/CntrStart.hpp>
00040 #include <signaldata/DumpStateOrd.hpp>
00041
00042 #include <signaldata/FsRemoveReq.hpp>
00043 #include <signaldata/ReadConfig.hpp>
00044
00045 #include <AttributeHeader.hpp>
00046 #include <Configuration.hpp>
00047 #include <DebuggerNames.hpp>
00048
00049 #include <NdbOut.hpp>
00050 #include <NdbTick.h>
00051
00057 struct BlockInfo {
00058 BlockReference Ref;
00059 Uint32 NextSP;
00060 Uint32 ErrorInsertStart;
00061 Uint32 ErrorInsertStop;
00062 };
00063
00064 static BlockInfo ALL_BLOCKS[] = {
00065 { DBTC_REF, 1 , 8000, 8035 },
00066 { DBDIH_REF, 1 , 7000, 7173 },
00067 { DBLQH_REF, 1 , 5000, 5030 },
00068 { DBACC_REF, 1 , 3000, 3999 },
00069 { DBTUP_REF, 1 , 4000, 4007 },
00070 { DBDICT_REF, 1 , 6000, 6003 },
00071 { NDBFS_REF, 0 , 2000, 2999 },
00072 { NDBCNTR_REF, 0 , 1000, 1999 },
00073 { QMGR_REF, 1 , 1, 999 },
00074 { CMVMI_REF, 1 , 9000, 9999 },
00075 { TRIX_REF, 1 , 0, 0 },
00076 { BACKUP_REF, 1 , 10000, 10999 },
00077 { DBUTIL_REF, 1 , 11000, 11999 },
00078 { SUMA_REF, 1 , 13000, 13999 },
00079 { GREP_REF, 1 , 0, 0 },
00080 { DBTUX_REF, 1 , 12000, 12999 }
00081 };
00082
00083 static const Uint32 ALL_BLOCKS_SZ = sizeof(ALL_BLOCKS)/sizeof(BlockInfo);
00084
00085
00086
00087
00088 void Ndbcntr::execCONTINUEB(Signal* signal)
00089 {
00090 jamEntry();
00091 UintR Ttemp1 = signal->theData[0];
00092 switch (Ttemp1) {
00093 case ZSTARTUP:{
00094 if(getNodeState().startLevel == NodeState::SL_STARTED){
00095 jam();
00096 return;
00097 }
00098
00099 if(cmasterNodeId == getOwnNodeId() && c_start.m_starting.isclear()){
00100 jam();
00101 trySystemRestart(signal);
00102
00103 }
00104
00105 Uint64 now = NdbTick_CurrentMillisecond();
00106 if(now > c_start.m_startFailureTimeout)
00107 {
00108 jam();
00109 Uint32 to_3= 0;
00110 const ndb_mgm_configuration_iterator * p =
00111 theConfiguration.getOwnConfigIterator();
00112 ndb_mgm_get_int_parameter(p, CFG_DB_START_FAILURE_TIMEOUT, &to_3);
00113 BaseString tmp;
00114 tmp.append("Shutting down node as total restart time exceeds "
00115 " StartFailureTimeout as set in config file ");
00116 if(to_3 == 0)
00117 tmp.append(" 0 (inifinite)");
00118 else
00119 tmp.appfmt(" %d", to_3);
00120
00121 progError(__LINE__, ERR_SYSTEM_ERROR, tmp.c_str());
00122 }
00123
00124 signal->theData[0] = ZSTARTUP;
00125 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 1);
00126 break;
00127 }
00128 case ZSHUTDOWN:
00129 jam();
00130 c_stopRec.checkTimeout(signal);
00131 break;
00132 default:
00133 jam();
00134 systemErrorLab(signal);
00135 return;
00136 break;
00137 }
00138 }
00139
00140
00141
00142
00143 void Ndbcntr::execSYSTEM_ERROR(Signal* signal)
00144 {
00145 const SystemError * const sysErr = (SystemError *)signal->getDataPtr();
00146 char buf[100];
00147 int killingNode = refToNode(sysErr->errorRef);
00148
00149 jamEntry();
00150 switch (sysErr->errorCode){
00151 case SystemError::StartInProgressError:
00152 BaseString::snprintf(buf, sizeof(buf),
00153 "Node %d killed this node because "
00154 "master start in progress error",
00155 killingNode);
00156 break;
00157
00158 case SystemError::GCPStopDetected:
00159 BaseString::snprintf(buf, sizeof(buf),
00160 "Node %d killed this node because "
00161 "GCP stop was detected",
00162 killingNode);
00163 break;
00164
00165 case SystemError::ScanfragTimeout:
00166 BaseString::snprintf(buf, sizeof(buf),
00167 "Node %d killed this node because "
00168 "a fragment scan timed out and could not be stopped",
00169 killingNode);
00170 break;
00171
00172 case SystemError::ScanfragStateError:
00173 BaseString::snprintf(buf, sizeof(buf),
00174 "Node %d killed this node because "
00175 "the state of a fragment scan was out of sync.",
00176 killingNode);
00177 break;
00178
00179 case SystemError::CopyFragRefError:
00180 BaseString::snprintf(buf, sizeof(buf),
00181 "Node %d killed this node because "
00182 "it could not copy a fragment during node restart",
00183 killingNode);
00184 break;
00185
00186 default:
00187 BaseString::snprintf(buf, sizeof(buf), "System error %d, "
00188 " this node was killed by node %d",
00189 sysErr->errorCode, killingNode);
00190 break;
00191 }
00192
00193 progError(__LINE__,
00194 ERR_SYSTEM_ERROR,
00195 buf);
00196 return;
00197 }
00198
00199 void Ndbcntr::execSTTOR(Signal* signal)
00200 {
00201 jamEntry();
00202 cstartPhase = signal->theData[1];
00203
00204 NodeState newState(NodeState::SL_STARTING, cstartPhase,
00205 (NodeState::StartType)ctypeOfStart);
00206 updateNodeState(signal, newState);
00207
00208 cndbBlocksCount = 0;
00209 cinternalStartphase = cstartPhase - 1;
00210
00211 switch (cstartPhase) {
00212 case 0:
00213 if(theConfiguration.getInitialStart()){
00214 jam();
00215 c_fsRemoveCount = 0;
00216 clearFilesystem(signal);
00217 return;
00218 }
00219 sendSttorry(signal);
00220 break;
00221 case ZSTART_PHASE_1:
00222 jam();
00223 startPhase1Lab(signal);
00224 break;
00225 case ZSTART_PHASE_2:
00226 jam();
00227 startPhase2Lab(signal);
00228 break;
00229 case ZSTART_PHASE_3:
00230 jam();
00231 startPhase3Lab(signal);
00232 break;
00233 case ZSTART_PHASE_4:
00234 jam();
00235 startPhase4Lab(signal);
00236 break;
00237 case ZSTART_PHASE_5:
00238 jam();
00239 startPhase5Lab(signal);
00240 break;
00241 case 6:
00242 jam();
00243 getNodeGroup(signal);
00244
00245 break;
00246 case ZSTART_PHASE_8:
00247 jam();
00248 startPhase8Lab(signal);
00249 break;
00250 case ZSTART_PHASE_9:
00251 jam();
00252 startPhase9Lab(signal);
00253 break;
00254 default:
00255 jam();
00256 sendSttorry(signal);
00257 break;
00258 }
00259 }
00260
00261 void
00262 Ndbcntr::getNodeGroup(Signal* signal){
00263 jam();
00264 CheckNodeGroups * sd = (CheckNodeGroups*)signal->getDataPtrSend();
00265 sd->requestType = CheckNodeGroups::Direct | CheckNodeGroups::GetNodeGroup;
00266 EXECUTE_DIRECT(DBDIH, GSN_CHECKNODEGROUPSREQ, signal,
00267 CheckNodeGroups::SignalLength);
00268 jamEntry();
00269 c_nodeGroup = sd->output;
00270 sendSttorry(signal);
00271 }
00272
00273
00274
00275
00276 void Ndbcntr::execNDB_STTORRY(Signal* signal)
00277 {
00278 jamEntry();
00279 switch (cstartPhase) {
00280 case ZSTART_PHASE_2:
00281 jam();
00282 ph2GLab(signal);
00283 return;
00284 break;
00285 case ZSTART_PHASE_3:
00286 jam();
00287 ph3ALab(signal);
00288 return;
00289 break;
00290 case ZSTART_PHASE_4:
00291 jam();
00292 ph4BLab(signal);
00293 return;
00294 break;
00295 case ZSTART_PHASE_5:
00296 jam();
00297 ph5ALab(signal);
00298 return;
00299 break;
00300 case ZSTART_PHASE_6:
00301 jam();
00302 ph6ALab(signal);
00303 return;
00304 break;
00305 case ZSTART_PHASE_7:
00306 jam();
00307 ph6BLab(signal);
00308 return;
00309 break;
00310 case ZSTART_PHASE_8:
00311 jam();
00312 ph7ALab(signal);
00313 return;
00314 break;
00315 case ZSTART_PHASE_9:
00316 jam();
00317 ph8ALab(signal);
00318 return;
00319 break;
00320 default:
00321 jam();
00322 systemErrorLab(signal);
00323 return;
00324 break;
00325 }
00326 }
00327
00328 void Ndbcntr::startPhase1Lab(Signal* signal)
00329 {
00330 jamEntry();
00331
00332 initData(signal);
00333
00334 cdynamicNodeId = 0;
00335
00336 NdbBlocksRecPtr ndbBlocksPtr;
00337 ndbBlocksPtr.i = 0;
00338 ptrAss(ndbBlocksPtr, ndbBlocksRec);
00339 ndbBlocksPtr.p->blockref = DBLQH_REF;
00340 ndbBlocksPtr.i = 1;
00341 ptrAss(ndbBlocksPtr, ndbBlocksRec);
00342 ndbBlocksPtr.p->blockref = DBDICT_REF;
00343 ndbBlocksPtr.i = 2;
00344 ptrAss(ndbBlocksPtr, ndbBlocksRec);
00345 ndbBlocksPtr.p->blockref = DBTUP_REF;
00346 ndbBlocksPtr.i = 3;
00347 ptrAss(ndbBlocksPtr, ndbBlocksRec);
00348 ndbBlocksPtr.p->blockref = DBACC_REF;
00349 ndbBlocksPtr.i = 4;
00350 ptrAss(ndbBlocksPtr, ndbBlocksRec);
00351 ndbBlocksPtr.p->blockref = DBTC_REF;
00352 ndbBlocksPtr.i = 5;
00353 ptrAss(ndbBlocksPtr, ndbBlocksRec);
00354 ndbBlocksPtr.p->blockref = DBDIH_REF;
00355 sendSttorry(signal);
00356 return;
00357 }
00358
00359 void Ndbcntr::execREAD_NODESREF(Signal* signal)
00360 {
00361 jamEntry();
00362 systemErrorLab(signal);
00363 return;
00364 }
00365
00366
00367
00368
00369
00370 void Ndbcntr::execNDB_STARTREF(Signal* signal)
00371 {
00372 jamEntry();
00373 systemErrorLab(signal);
00374 return;
00375 }
00376
00377
00378
00379
00380 void Ndbcntr::startPhase2Lab(Signal* signal)
00381 {
00382 c_start.m_lastGci = 0;
00383 c_start.m_lastGciNodeId = getOwnNodeId();
00384
00385 signal->theData[0] = reference();
00386 sendSignal(DBDIH_REF, GSN_DIH_RESTARTREQ, signal, 1, JBB);
00387 return;
00388 }
00389
00390
00391
00392
00393 void Ndbcntr::execDIH_RESTARTCONF(Signal* signal)
00394 {
00395 jamEntry();
00396
00397 c_start.m_lastGci = signal->theData[1];
00398 ctypeOfStart = NodeState::ST_SYSTEM_RESTART;
00399 ph2ALab(signal);
00400 return;
00401 }
00402
00403
00404
00405
00406 void Ndbcntr::execDIH_RESTARTREF(Signal* signal)
00407 {
00408 jamEntry();
00409 ctypeOfStart = NodeState::ST_INITIAL_START;
00410 ph2ALab(signal);
00411 return;
00412 }
00413
00414 void Ndbcntr::ph2ALab(Signal* signal)
00415 {
00416
00417
00418
00419
00420
00421 signal->theData[0] = reference();
00422 sendSignal(QMGR_REF, GSN_READ_NODESREQ, signal, 1, JBB);
00423 return;
00424 }
00425
00426 inline
00427 Uint64
00428 setTimeout(Uint64 time, Uint32 timeoutValue){
00429 if(timeoutValue == 0)
00430 return ~(Uint64)0;
00431 return time + timeoutValue;
00432 }
00433
00434
00435
00436
00437 void Ndbcntr::execREAD_NODESCONF(Signal* signal)
00438 {
00439 jamEntry();
00440 const ReadNodesConf * readNodes = (ReadNodesConf *)&signal->theData[0];
00441
00442 cmasterNodeId = readNodes->masterNodeId;
00443 cdynamicNodeId = readNodes->ndynamicId;
00444
00448 c_allDefinedNodes.assign(NdbNodeBitmask::Size, readNodes->allNodes);
00449 c_clusterNodes.assign(NdbNodeBitmask::Size, readNodes->clusterNodes);
00450
00451 Uint32 to_1 = 30000;
00452 Uint32 to_2 = 0;
00453 Uint32 to_3 = 0;
00454
00455 const ndb_mgm_configuration_iterator * p =
00456 theConfiguration.getOwnConfigIterator();
00457
00458 ndbrequire(p != 0);
00459 ndb_mgm_get_int_parameter(p, CFG_DB_START_PARTIAL_TIMEOUT, &to_1);
00460 ndb_mgm_get_int_parameter(p, CFG_DB_START_PARTITION_TIMEOUT, &to_2);
00461 ndb_mgm_get_int_parameter(p, CFG_DB_START_FAILURE_TIMEOUT, &to_3);
00462
00463 c_start.m_startTime = NdbTick_CurrentMillisecond();
00464 c_start.m_startPartialTimeout = setTimeout(c_start.m_startTime, to_1);
00465 c_start.m_startPartitionedTimeout = setTimeout(c_start.m_startTime, to_2);
00466 c_start.m_startFailureTimeout = setTimeout(c_start.m_startTime, to_3);
00467
00468 UpgradeStartup::sendCmAppChg(* this, signal, 0);
00469
00470 sendCntrStartReq(signal);
00471
00472 signal->theData[0] = ZSTARTUP;
00473 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 1);
00474
00475 return;
00476 }
00477
00478 void
00479 Ndbcntr::execCM_ADD_REP(Signal* signal){
00480 jamEntry();
00481 c_clusterNodes.set(signal->theData[0]);
00482 }
00483
00484 void
00485 Ndbcntr::sendCntrStartReq(Signal * signal){
00486 jamEntry();
00487
00488 CntrStartReq * req = (CntrStartReq*)signal->getDataPtrSend();
00489 req->startType = ctypeOfStart;
00490 req->lastGci = c_start.m_lastGci;
00491 req->nodeId = getOwnNodeId();
00492 sendSignal(calcNdbCntrBlockRef(cmasterNodeId), GSN_CNTR_START_REQ,
00493 signal, CntrStartReq::SignalLength, JBB);
00494 }
00495
00496 void
00497 Ndbcntr::execCNTR_START_REF(Signal * signal){
00498 jamEntry();
00499 const CntrStartRef * ref = (CntrStartRef*)signal->getDataPtr();
00500
00501 switch(ref->errorCode){
00502 case CntrStartRef::NotMaster:
00503 jam();
00504 cmasterNodeId = ref->masterNodeId;
00505 sendCntrStartReq(signal);
00506 return;
00507 }
00508 ndbrequire(false);
00509 }
00510
00511 void
00512 Ndbcntr::StartRecord::reset(){
00513 m_starting.clear();
00514 m_waiting.clear();
00515 m_withLog.clear();
00516 m_withoutLog.clear();
00517 m_lastGci = m_lastGciNodeId = 0;
00518 m_startPartialTimeout = ~0;
00519 m_startPartitionedTimeout = ~0;
00520 m_startFailureTimeout = ~0;
00521
00522 m_logNodesCount = 0;
00523 }
00524
00525 void
00526 Ndbcntr::execCNTR_START_CONF(Signal * signal){
00527 jamEntry();
00528 const CntrStartConf * conf = (CntrStartConf*)signal->getDataPtr();
00529
00530 cnoStartNodes = conf->noStartNodes;
00531 ctypeOfStart = (NodeState::StartType)conf->startType;
00532 c_start.m_lastGci = conf->startGci;
00533 cmasterNodeId = conf->masterNodeId;
00534 NdbNodeBitmask tmp;
00535 tmp.assign(NdbNodeBitmask::Size, conf->startedNodes);
00536 c_startedNodes.bitOR(tmp);
00537 c_start.m_starting.assign(NdbNodeBitmask::Size, conf->startingNodes);
00538 ph2GLab(signal);
00539
00540 UpgradeStartup::sendCmAppChg(* this, signal, 2);
00541 }
00542
00554 #define PARALLELL_NR 0
00555
00556 #if PARALLELL_NR
00557 const bool parallellNR = true;
00558 #else
00559 const bool parallellNR = false;
00560 #endif
00561
00562 void
00563 Ndbcntr::execCNTR_START_REP(Signal* signal){
00564 jamEntry();
00565 Uint32 nodeId = signal->theData[0];
00566 c_startedNodes.set(nodeId);
00567 c_start.m_starting.clear(nodeId);
00568
00569 if(!c_start.m_starting.isclear()){
00570 jam();
00571 return;
00572 }
00573
00574 if(cmasterNodeId != getOwnNodeId()){
00575 jam();
00576 c_start.reset();
00577 return;
00578 }
00579
00580 if(c_start.m_waiting.isclear()){
00581 jam();
00582 c_start.reset();
00583 return;
00584 }
00585
00586 startWaitingNodes(signal);
00587 }
00588
00589 void
00590 Ndbcntr::execCNTR_START_REQ(Signal * signal){
00591 jamEntry();
00592 const CntrStartReq * req = (CntrStartReq*)signal->getDataPtr();
00593
00594 const Uint32 nodeId = req->nodeId;
00595 const Uint32 lastGci = req->lastGci;
00596 const NodeState::StartType st = (NodeState::StartType)req->startType;
00597
00598 if(cmasterNodeId == 0){
00599 jam();
00600
00601 sendSignalWithDelay(reference(), GSN_CNTR_START_REQ, signal, 100,
00602 signal->getLength());
00603 return;
00604 }
00605
00606 if(cmasterNodeId != getOwnNodeId()){
00607 jam();
00608 sendCntrStartRef(signal, nodeId, CntrStartRef::NotMaster);
00609 return;
00610 }
00611
00612 const NodeState & nodeState = getNodeState();
00613 switch(nodeState.startLevel){
00614 case NodeState::SL_NOTHING:
00615 case NodeState::SL_CMVMI:
00616 jam();
00617 ndbrequire(false);
00618 case NodeState::SL_STARTING:
00619 case NodeState::SL_STARTED:
00620 jam();
00621 break;
00622
00623 case NodeState::SL_STOPPING_1:
00624 case NodeState::SL_STOPPING_2:
00625 case NodeState::SL_STOPPING_3:
00626 case NodeState::SL_STOPPING_4:
00627 jam();
00628 sendCntrStartRef(signal, nodeId, CntrStartRef::StopInProgress);
00629 return;
00630 }
00631
00635 const bool starting = (nodeState.startLevel != NodeState::SL_STARTED);
00636
00637 c_start.m_waiting.set(nodeId);
00638 switch(st){
00639 case NodeState::ST_INITIAL_START:
00640 jam();
00641 c_start.m_withoutLog.set(nodeId);
00642 break;
00643 case NodeState::ST_SYSTEM_RESTART:
00644 jam();
00645 c_start.m_withLog.set(nodeId);
00646 if(starting && lastGci > c_start.m_lastGci){
00647 jam();
00648 CntrStartRef * ref = (CntrStartRef*)signal->getDataPtrSend();
00649 ref->errorCode = CntrStartRef::NotMaster;
00650 ref->masterNodeId = nodeId;
00651 NodeReceiverGroup rg (NDBCNTR, c_start.m_waiting);
00652 sendSignal(rg, GSN_CNTR_START_REF, signal,
00653 CntrStartRef::SignalLength, JBB);
00654 return;
00655 }
00656 if(starting){
00657 jam();
00658 Uint32 i = c_start.m_logNodesCount++;
00659 c_start.m_logNodes[i].m_nodeId = nodeId;
00660 c_start.m_logNodes[i].m_lastGci = req->lastGci;
00661 }
00662 break;
00663 case NodeState::ST_NODE_RESTART:
00664 case NodeState::ST_INITIAL_NODE_RESTART:
00665 case NodeState::ST_ILLEGAL_TYPE:
00666 ndbrequire(false);
00667 }
00668
00669 const bool startInProgress = !c_start.m_starting.isclear();
00670
00671 if((starting && startInProgress) || (startInProgress && !parallellNR)){
00672 jam();
00673
00674
00675 return;
00676 }
00677
00678 if(starting){
00679 jam();
00680 trySystemRestart(signal);
00681 } else {
00682 jam();
00683 startWaitingNodes(signal);
00684 }
00685 return;
00686 }
00687
00688 void
00689 Ndbcntr::startWaitingNodes(Signal * signal){
00690
00691 #if ! PARALLELL_NR
00692 const Uint32 nodeId = c_start.m_waiting.find(0);
00693 const Uint32 Tref = calcNdbCntrBlockRef(nodeId);
00694 ndbrequire(nodeId != c_start.m_waiting.NotFound);
00695
00696 NodeState::StartType nrType = NodeState::ST_NODE_RESTART;
00697 if(c_start.m_withoutLog.get(nodeId)){
00698 jam();
00699 nrType = NodeState::ST_INITIAL_NODE_RESTART;
00700 }
00701
00705 CntrStartConf * conf = (CntrStartConf*)signal->getDataPtrSend();
00706 conf->noStartNodes = 1;
00707 conf->startType = nrType;
00708 conf->startGci = ~0;
00709 conf->masterNodeId = getOwnNodeId();
00710 BitmaskImpl::clear(NdbNodeBitmask::Size, conf->startingNodes);
00711 BitmaskImpl::set(NdbNodeBitmask::Size, conf->startingNodes, nodeId);
00712 c_startedNodes.copyto(NdbNodeBitmask::Size, conf->startedNodes);
00713 sendSignal(Tref, GSN_CNTR_START_CONF, signal,
00714 CntrStartConf::SignalLength, JBB);
00715
00716 c_start.m_waiting.clear(nodeId);
00717 c_start.m_withLog.clear(nodeId);
00718 c_start.m_withoutLog.clear(nodeId);
00719 c_start.m_starting.set(nodeId);
00720 #else
00721
00722
00723 c_start.m_starting = c_start.m_waiting;
00724 c_start.m_waiting.clear();
00725
00726 CntrStartConf * conf = (CntrStartConf*)signal->getDataPtrSend();
00727 conf->noStartNodes = 1;
00728 conf->startGci = ~0;
00729 conf->masterNodeId = getOwnNodeId();
00730 c_start.m_starting.copyto(NdbNodeBitmask::Size, conf->startingNodes);
00731 c_startedNodes.copyto(NdbNodeBitmask::Size, conf->startedNodes);
00732
00733 char buf[100];
00734 if(!c_start.m_withLog.isclear()){
00735 jam();
00736 ndbout_c("Starting nodes w/ log: %s", c_start.m_withLog.getText(buf));
00737
00738 NodeReceiverGroup rg(NDBCNTR, c_start.m_withLog);
00739 conf->startType = NodeState::ST_NODE_RESTART;
00740
00741 sendSignal(rg, GSN_CNTR_START_CONF, signal,
00742 CntrStartConf::SignalLength, JBB);
00743 }
00744
00745 if(!c_start.m_withoutLog.isclear()){
00746 jam();
00747 ndbout_c("Starting nodes wo/ log: %s", c_start.m_withoutLog.getText(buf));
00748 NodeReceiverGroup rg(NDBCNTR, c_start.m_withoutLog);
00749 conf->startType = NodeState::ST_INITIAL_NODE_RESTART;
00750
00751 sendSignal(rg, GSN_CNTR_START_CONF, signal,
00752 CntrStartConf::SignalLength, JBB);
00753 }
00754
00755 c_start.m_waiting.clear();
00756 c_start.m_withLog.clear();
00757 c_start.m_withoutLog.clear();
00758 #endif
00759 }
00760
00761 void
00762 Ndbcntr::sendCntrStartRef(Signal * signal,
00763 Uint32 nodeId, CntrStartRef::ErrorCode code){
00764 CntrStartRef * ref = (CntrStartRef*)signal->getDataPtrSend();
00765 ref->errorCode = code;
00766 ref->masterNodeId = cmasterNodeId;
00767 sendSignal(calcNdbCntrBlockRef(nodeId), GSN_CNTR_START_REF, signal,
00768 CntrStartRef::SignalLength, JBB);
00769 }
00770
00771 CheckNodeGroups::Output
00772 Ndbcntr::checkNodeGroups(Signal* signal, const NdbNodeBitmask & mask){
00773 CheckNodeGroups* sd = (CheckNodeGroups*)&signal->theData[0];
00774 sd->blockRef = reference();
00775 sd->requestType = CheckNodeGroups::Direct | CheckNodeGroups::ArbitCheck;
00776 sd->mask = mask;
00777 EXECUTE_DIRECT(DBDIH, GSN_CHECKNODEGROUPSREQ, signal,
00778 CheckNodeGroups::SignalLength);
00779 jamEntry();
00780 return (CheckNodeGroups::Output)sd->output;
00781 }
00782
00783 bool
00784 Ndbcntr::trySystemRestart(Signal* signal){
00788 const bool allNodes = c_start.m_waiting.equal(c_allDefinedNodes);
00789 const bool allClusterNodes = c_start.m_waiting.equal(c_clusterNodes);
00790 const Uint64 now = NdbTick_CurrentMillisecond();
00791
00792 if(!allClusterNodes){
00793 jam();
00794 return false;
00795 }
00796
00797 if(!allNodes && c_start.m_startPartialTimeout > now){
00798 jam();
00799 return false;
00800 }
00801
00802 NodeState::StartType srType = NodeState::ST_SYSTEM_RESTART;
00803 if(c_start.m_waiting.equal(c_start.m_withoutLog)){
00804 if(!allNodes){
00805 jam();
00806 return false;
00807 }
00808 jam();
00809 srType = NodeState::ST_INITIAL_START;
00810 c_start.m_starting = c_start.m_withoutLog;
00811 c_start.m_withoutLog.clear();
00812 } else {
00813
00814 CheckNodeGroups::Output wLog = checkNodeGroups(signal, c_start.m_withLog);
00815
00816 switch (wLog) {
00817 case CheckNodeGroups::Win:
00818 jam();
00819 break;
00820 case CheckNodeGroups::Lose:
00821 jam();
00822
00823 ndbrequire(!allNodes);
00824 return false;
00825 case CheckNodeGroups::Partitioning:
00826 jam();
00827 bool allowPartition = (c_start.m_startPartitionedTimeout != (Uint64)~0);
00828
00829 if(allNodes){
00830 if(allowPartition){
00831 jam();
00832 break;
00833 }
00834 ndbrequire(false);
00835 }
00836
00837 if(c_start.m_startPartitionedTimeout > now){
00838 jam();
00839 return false;
00840 }
00841 break;
00842 }
00843
00844
00845
00846 c_start.m_starting = c_start.m_withLog;
00847 c_start.m_withLog.clear();
00848 }
00849
00853 CntrStartConf * conf = (CntrStartConf*)signal->getDataPtr();
00854 conf->noStartNodes = c_start.m_starting.count();
00855 conf->startType = srType;
00856 conf->startGci = c_start.m_lastGci;
00857 conf->masterNodeId = c_start.m_lastGciNodeId;
00858 c_start.m_starting.copyto(NdbNodeBitmask::Size, conf->startingNodes);
00859 c_startedNodes.copyto(NdbNodeBitmask::Size, conf->startedNodes);
00860
00861 ndbrequire(c_start.m_lastGciNodeId == getOwnNodeId());
00862
00863 NodeReceiverGroup rg(NDBCNTR, c_start.m_starting);
00864 sendSignal(rg, GSN_CNTR_START_CONF, signal, CntrStartConf::SignalLength,JBB);
00865
00866 c_start.m_waiting.bitANDC(c_start.m_starting);
00867
00868 return true;
00869 }
00870
00871 void Ndbcntr::ph2GLab(Signal* signal)
00872 {
00873 if (cndbBlocksCount < ZNO_NDB_BLOCKS) {
00874 jam();
00875 sendNdbSttor(signal);
00876 return;
00877 }
00878 sendSttorry(signal);
00879 return;
00880 }
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 void Ndbcntr::startPhase3Lab(Signal* signal)
00897 {
00898 ph3ALab(signal);
00899 return;
00900 }
00901
00902
00903
00904
00905 void Ndbcntr::ph3ALab(Signal* signal)
00906 {
00907 if (cndbBlocksCount < ZNO_NDB_BLOCKS) {
00908 jam();
00909 sendNdbSttor(signal);
00910 return;
00911 }
00912
00913 sendSttorry(signal);
00914 return;
00915 }
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928 void Ndbcntr::startPhase4Lab(Signal* signal)
00929 {
00930 ph4ALab(signal);
00931 }
00932
00933
00934 void Ndbcntr::ph4ALab(Signal* signal)
00935 {
00936 ph4BLab(signal);
00937 return;
00938 }
00939
00940
00941
00942
00943 void Ndbcntr::ph4BLab(Signal* signal)
00944 {
00945
00946
00947
00948 if (cndbBlocksCount < ZNO_NDB_BLOCKS) {
00949 jam();
00950 sendNdbSttor(signal);
00951 return;
00952 }
00953 if ((ctypeOfStart == NodeState::ST_NODE_RESTART) ||
00954 (ctypeOfStart == NodeState::ST_INITIAL_NODE_RESTART)) {
00955 jam();
00956 sendSttorry(signal);
00957 return;
00958 }
00959 waitpoint41Lab(signal);
00960 return;
00961 }
00962
00963 void Ndbcntr::waitpoint41Lab(Signal* signal)
00964 {
00965 if (getOwnNodeId() == cmasterNodeId) {
00966 jam();
00967
00968
00969
00970
00971 cnoWaitrep++;
00972 if (cnoWaitrep == cnoStartNodes) {
00973 jam();
00974 cnoWaitrep = 0;
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986 signal->theData[0] = reference();
00987 signal->theData[1] = ctypeOfStart;
00988 sendSignal(DBDIH_REF, GSN_NDB_STARTREQ, signal, 2, JBB);
00989 }
00990 } else {
00991 jam();
00992
00993
00994
00995
00996
00997
00998 signal->theData[0] = getOwnNodeId();
00999 signal->theData[1] = ZWAITPOINT_4_1;
01000 sendSignal(calcNdbCntrBlockRef(cmasterNodeId),
01001 GSN_CNTR_WAITREP, signal, 2, JBB);
01002 }
01003 return;
01004 }
01005
01006
01007
01008
01009 void Ndbcntr::execNDB_STARTCONF(Signal* signal)
01010 {
01011 jamEntry();
01012
01013 NodeReceiverGroup rg(NDBCNTR, c_start.m_starting);
01014 signal->theData[0] = getOwnNodeId();
01015 signal->theData[1] = ZWAITPOINT_4_2;
01016 sendSignal(rg, GSN_CNTR_WAITREP, signal, 2, JBB);
01017 return;
01018 }
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030 void Ndbcntr::startPhase5Lab(Signal* signal)
01031 {
01032 ph5ALab(signal);
01033 return;
01034 }
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047 void Ndbcntr::ph5ALab(Signal* signal)
01048 {
01049 if (cndbBlocksCount < ZNO_NDB_BLOCKS) {
01050 jam();
01051 sendNdbSttor(signal);
01052 return;
01053 }
01054
01055 cstartPhase = cstartPhase + 1;
01056 cinternalStartphase = cstartPhase - 1;
01057 if (getOwnNodeId() == cmasterNodeId) {
01058 switch(ctypeOfStart){
01059 case NodeState::ST_INITIAL_START:
01060 jam();
01061
01062
01063
01064
01065 createSystableLab(signal, 0);
01066 return;
01067 case NodeState::ST_SYSTEM_RESTART:
01068 jam();
01069 waitpoint52Lab(signal);
01070 return;
01071 case NodeState::ST_NODE_RESTART:
01072 case NodeState::ST_INITIAL_NODE_RESTART:
01073 jam();
01074 break;
01075 case NodeState::ST_ILLEGAL_TYPE:
01076 jam();
01077 break;
01078 }
01079 ndbrequire(false);
01080 }
01081
01085 NdbSttor * const req = (NdbSttor*)signal->getDataPtrSend();
01086 switch(ctypeOfStart){
01087 case NodeState::ST_NODE_RESTART:
01088 case NodeState::ST_INITIAL_NODE_RESTART:
01089 jam();
01090
01091
01092
01093
01094 req->senderRef = reference();
01095 req->nodeId = getOwnNodeId();
01096 req->internalStartPhase = cinternalStartphase;
01097 req->typeOfStart = ctypeOfStart;
01098 req->masterNodeId = cmasterNodeId;
01099
01100
01101 #ifdef TRACE_STTOR
01102 ndbout_c("sending NDB_STTOR(%d) to DIH", cinternalStartphase);
01103 #endif
01104 sendSignal(DBDIH_REF, GSN_NDB_STTOR, signal,
01105 NdbSttor::SignalLength, JBB);
01106 return;
01107 case NodeState::ST_INITIAL_START:
01108 case NodeState::ST_SYSTEM_RESTART:
01109 jam();
01110
01111
01112
01113
01114
01115
01116
01117
01118 signal->theData[0] = getOwnNodeId();
01119 signal->theData[1] = ZWAITPOINT_5_2;
01120 sendSignal(calcNdbCntrBlockRef(cmasterNodeId),
01121 GSN_CNTR_WAITREP, signal, 2, JBB);
01122 return;
01123 default:
01124 ndbrequire(false);
01125 }
01126 }
01127
01128 void Ndbcntr::waitpoint52Lab(Signal* signal)
01129 {
01130 cnoWaitrep = cnoWaitrep + 1;
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143 if (cnoWaitrep == cnoStartNodes) {
01144 jam();
01145 cnoWaitrep = 0;
01146
01147 NdbSttor * const req = (NdbSttor*)signal->getDataPtrSend();
01148 req->senderRef = reference();
01149 req->nodeId = getOwnNodeId();
01150 req->internalStartPhase = cinternalStartphase;
01151 req->typeOfStart = ctypeOfStart;
01152 req->masterNodeId = cmasterNodeId;
01153 #ifdef TRACE_STTOR
01154 ndbout_c("sending NDB_STTOR(%d) to DIH", cinternalStartphase);
01155 #endif
01156 sendSignal(DBDIH_REF, GSN_NDB_STTOR, signal,
01157 NdbSttor::SignalLength, JBB);
01158 }
01159 return;
01160 }
01161
01162
01163
01164
01165 void Ndbcntr::ph6ALab(Signal* signal)
01166 {
01167 if ((ctypeOfStart == NodeState::ST_NODE_RESTART) ||
01168 (ctypeOfStart == NodeState::ST_INITIAL_NODE_RESTART)) {
01169 jam();
01170 waitpoint51Lab(signal);
01171 return;
01172 }
01173
01174 NodeReceiverGroup rg(NDBCNTR, c_start.m_starting);
01175 rg.m_nodes.clear(getOwnNodeId());
01176 signal->theData[0] = getOwnNodeId();
01177 signal->theData[1] = ZWAITPOINT_5_1;
01178 sendSignal(rg, GSN_CNTR_WAITREP, signal, 2, JBB);
01179
01180 waitpoint51Lab(signal);
01181 return;
01182 }
01183
01184 void Ndbcntr::waitpoint51Lab(Signal* signal)
01185 {
01186 cstartPhase = cstartPhase + 1;
01187
01188
01189
01190
01191
01192 cinternalStartphase = cstartPhase - 1;
01193 cndbBlocksCount = 0;
01194 ph6BLab(signal);
01195 return;
01196 }
01197
01198 void Ndbcntr::ph6BLab(Signal* signal)
01199 {
01200
01201
01202 if (cndbBlocksCount < ZNO_NDB_BLOCKS) {
01203 jam();
01204 sendNdbSttor(signal);
01205 return;
01206 }
01207 if ((ctypeOfStart == NodeState::ST_NODE_RESTART) ||
01208 (ctypeOfStart == NodeState::ST_INITIAL_NODE_RESTART)) {
01209 jam();
01210 sendSttorry(signal);
01211 return;
01212 }
01213 waitpoint61Lab(signal);
01214 }
01215
01216 void Ndbcntr::waitpoint61Lab(Signal* signal)
01217 {
01218 if (getOwnNodeId() == cmasterNodeId) {
01219 jam();
01220 cnoWaitrep6++;
01221 if (cnoWaitrep6 == cnoStartNodes) {
01222 jam();
01223 NodeReceiverGroup rg(NDBCNTR, c_start.m_starting);
01224 rg.m_nodes.clear(getOwnNodeId());
01225 signal->theData[0] = getOwnNodeId();
01226 signal->theData[1] = ZWAITPOINT_6_2;
01227 sendSignal(rg, GSN_CNTR_WAITREP, signal, 2, JBB);
01228 sendSttorry(signal);
01229 }
01230 } else {
01231 jam();
01232 signal->theData[0] = getOwnNodeId();
01233 signal->theData[1] = ZWAITPOINT_6_1;
01234 sendSignal(calcNdbCntrBlockRef(cmasterNodeId), GSN_CNTR_WAITREP, signal, 2, JBB);
01235 }
01236 }
01237
01238
01239 void Ndbcntr::startPhase8Lab(Signal* signal)
01240 {
01241 cinternalStartphase = cstartPhase - 1;
01242 cndbBlocksCount = 0;
01243 ph7ALab(signal);
01244 }
01245
01246 void Ndbcntr::ph7ALab(Signal* signal)
01247 {
01248 while (cndbBlocksCount < ZNO_NDB_BLOCKS) {
01249 jam();
01250 sendNdbSttor(signal);
01251 return;
01252 }
01253 if ((ctypeOfStart == NodeState::ST_NODE_RESTART) ||
01254 (ctypeOfStart == NodeState::ST_INITIAL_NODE_RESTART)) {
01255 jam();
01256 sendSttorry(signal);
01257 return;
01258 }
01259 waitpoint71Lab(signal);
01260 }
01261
01262 void Ndbcntr::waitpoint71Lab(Signal* signal)
01263 {
01264 if (getOwnNodeId() == cmasterNodeId) {
01265 jam();
01266 cnoWaitrep7++;
01267 if (cnoWaitrep7 == cnoStartNodes) {
01268 jam();
01269 NodeReceiverGroup rg(NDBCNTR, c_start.m_starting);
01270 rg.m_nodes.clear(getOwnNodeId());
01271 signal->theData[0] = getOwnNodeId();
01272 signal->theData[1] = ZWAITPOINT_7_2;
01273 sendSignal(rg, GSN_CNTR_WAITREP, signal, 2, JBB);
01274 sendSttorry(signal);
01275 }
01276 } else {
01277 jam();
01278 signal->theData[0] = getOwnNodeId();
01279 signal->theData[1] = ZWAITPOINT_7_1;
01280 sendSignal(calcNdbCntrBlockRef(cmasterNodeId), GSN_CNTR_WAITREP, signal, 2, JBB);
01281 }
01282 }
01283
01284
01285 void Ndbcntr::startPhase9Lab(Signal* signal)
01286 {
01287 cinternalStartphase = cstartPhase - 1;
01288 cndbBlocksCount = 0;
01289 ph8ALab(signal);
01290 }
01291
01292 void Ndbcntr::ph8ALab(Signal* signal)
01293 {
01294
01295
01296
01297
01298 sendSttorry(signal);
01299 resetStartVariables(signal);
01300 return;
01301 }
01302
01303
01304
01305
01306 void Ndbcntr::execCNTR_WAITREP(Signal* signal)
01307 {
01308 Uint16 twaitPoint;
01309
01310 jamEntry();
01311 twaitPoint = signal->theData[1];
01312 switch (twaitPoint) {
01313 case ZWAITPOINT_4_1:
01314 jam();
01315 waitpoint41Lab(signal);
01316 break;
01317 case ZWAITPOINT_4_2:
01318 jam();
01319 sendSttorry(signal);
01320 break;
01321 case ZWAITPOINT_5_1:
01322 jam();
01323 waitpoint51Lab(signal);
01324 break;
01325 case ZWAITPOINT_5_2:
01326 jam();
01327 waitpoint52Lab(signal);
01328 break;
01329 case ZWAITPOINT_6_1:
01330 jam();
01331 waitpoint61Lab(signal);
01332 break;
01333 case ZWAITPOINT_6_2:
01334 jam();
01335 sendSttorry(signal);
01336 break;
01337 case ZWAITPOINT_7_1:
01338 jam();
01339 waitpoint71Lab(signal);
01340 break;
01341 case ZWAITPOINT_7_2:
01342 jam();
01343 sendSttorry(signal);
01344 break;
01345 default:
01346 jam();
01347 systemErrorLab(signal);
01348 break;
01349 }
01350 }
01351
01352
01353
01354
01355 void Ndbcntr::execNODE_FAILREP(Signal* signal)
01356 {
01357 jamEntry();
01358
01359 const NodeFailRep * nodeFail = (NodeFailRep *)&signal->theData[0];
01360 NdbNodeBitmask allFailed;
01361 allFailed.assign(NdbNodeBitmask::Size, nodeFail->theNodes);
01362
01363 NdbNodeBitmask failedStarted = c_startedNodes;
01364 NdbNodeBitmask failedStarting = c_start.m_starting;
01365 NdbNodeBitmask failedWaiting = c_start.m_waiting;
01366
01367 failedStarted.bitAND(allFailed);
01368 failedStarting.bitAND(allFailed);
01369 failedWaiting.bitAND(allFailed);
01370
01371 const bool tMasterFailed = allFailed.get(cmasterNodeId);
01372 const bool tStarted = !failedStarted.isclear();
01373 const bool tStarting = !failedStarting.isclear();
01374 const bool tWaiting = !failedWaiting.isclear();
01375
01376 if(tMasterFailed){
01377 jam();
01381 cmasterNodeId = nodeFail->masterNodeId;
01382 }
01383
01387 c_start.m_starting.bitANDC(allFailed);
01388 c_start.m_waiting.bitANDC(allFailed);
01389 c_start.m_withLog.bitANDC(allFailed);
01390 c_start.m_withoutLog.bitANDC(allFailed);
01391 c_clusterNodes.bitANDC(allFailed);
01392 c_startedNodes.bitANDC(allFailed);
01393
01394 const NodeState & st = getNodeState();
01395 if(st.startLevel == st.SL_STARTING){
01396 jam();
01397
01398 const Uint32 phase = st.starting.startPhase;
01399
01400 const bool tStartConf = (phase > 2) || (phase == 2 && cndbBlocksCount > 0);
01401
01402 if(tMasterFailed){
01403 progError(__LINE__,
01404 ERR_SR_OTHERNODEFAILED,
01405 "Unhandled node failure during restart");
01406 }
01407
01408 if(tStartConf && tStarting){
01409
01410 progError(__LINE__,
01411 ERR_SR_OTHERNODEFAILED,
01412 "Unhandled node failure of starting node during restart");
01413 }
01414
01415 if(tStartConf && tStarted){
01416
01417 progError(__LINE__,
01418 ERR_SR_OTHERNODEFAILED,
01419 "Unhandled node failure of started node during restart");
01420 }
01421
01422 Uint32 nodeId = 0;
01423 while(!allFailed.isclear()){
01424 nodeId = allFailed.find(nodeId + 1);
01425 allFailed.clear(nodeId);
01426 signal->theData[0] = nodeId;
01427 sendSignal(QMGR_REF, GSN_NDB_FAILCONF, signal, 1, JBB);
01428 }
01429
01430 return;
01431 }
01432
01433 ndbrequire(!allFailed.get(getOwnNodeId()));
01434
01435 NodeFailRep * rep = (NodeFailRep *)&signal->theData[0];
01436 rep->masterNodeId = cmasterNodeId;
01437
01438 sendSignal(DBTC_REF, GSN_NODE_FAILREP, signal,
01439 NodeFailRep::SignalLength, JBB);
01440
01441 sendSignal(DBLQH_REF, GSN_NODE_FAILREP, signal,
01442 NodeFailRep::SignalLength, JBB);
01443
01444 sendSignal(DBDIH_REF, GSN_NODE_FAILREP, signal,
01445 NodeFailRep::SignalLength, JBB);
01446
01447 sendSignal(DBDICT_REF, GSN_NODE_FAILREP, signal,
01448 NodeFailRep::SignalLength, JBB);
01449
01450 sendSignal(BACKUP_REF, GSN_NODE_FAILREP, signal,
01451 NodeFailRep::SignalLength, JBB);
01452
01453 sendSignal(SUMA_REF, GSN_NODE_FAILREP, signal,
01454 NodeFailRep::SignalLength, JBB);
01455
01456 sendSignal(GREP_REF, GSN_NODE_FAILREP, signal,
01457 NodeFailRep::SignalLength, JBB);
01458
01459 Uint32 nodeId = 0;
01460 while(!allFailed.isclear()){
01461 nodeId = allFailed.find(nodeId + 1);
01462 allFailed.clear(nodeId);
01463 signal->theData[0] = NDB_LE_NODE_FAILREP;
01464 signal->theData[1] = nodeId;
01465 signal->theData[2] = 0;
01466 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);
01467 }
01468
01469 return;
01470 }
01471
01472
01473
01474
01475 void Ndbcntr::execREAD_NODESREQ(Signal* signal)
01476 {
01477 jamEntry();
01478
01479
01480
01481
01482
01483
01484 BlockReference TuserBlockref = signal->theData[0];
01485 ReadNodesConf * const readNodes = (ReadNodesConf *)&signal->theData[0];
01486
01492 NdbNodeBitmask tmp1;
01493 tmp1.bitOR(c_startedNodes);
01494 if(!getNodeState().getNodeRestartInProgress()){
01495 tmp1.bitOR(c_start.m_starting);
01496 } else {
01497 tmp1.set(getOwnNodeId());
01498 }
01499
01500 NdbNodeBitmask tmp2;
01501 tmp2.bitOR(c_allDefinedNodes);
01502 tmp2.bitANDC(tmp1);
01506 tmp2.copyto(NdbNodeBitmask::Size, readNodes->inactiveNodes);
01507 c_allDefinedNodes.copyto(NdbNodeBitmask::Size, readNodes->allNodes);
01508 c_clusterNodes.copyto(NdbNodeBitmask::Size, readNodes->clusterNodes);
01509 c_startedNodes.copyto(NdbNodeBitmask::Size, readNodes->startedNodes);
01510 c_start.m_starting.copyto(NdbNodeBitmask::Size, readNodes->startingNodes);
01511
01512 readNodes->noOfNodes = c_allDefinedNodes.count();
01513 readNodes->masterNodeId = cmasterNodeId;
01514 readNodes->ndynamicId = cdynamicNodeId;
01515 if (cstartPhase > ZSTART_PHASE_2) {
01516 jam();
01517 sendSignal(TuserBlockref, GSN_READ_NODESCONF, signal,
01518 ReadNodesConf::SignalLength, JBB);
01519
01520 } else {
01521 jam();
01522 signal->theData[0] = ZNOT_AVAILABLE;
01523 sendSignal(TuserBlockref, GSN_READ_NODESREF, signal, 1, JBB);
01524 }
01525 }
01526
01527
01528
01529
01530 void Ndbcntr::systemErrorLab(Signal* signal)
01531 {
01532 progError(0, 0);
01533 return;
01534 }
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546 void Ndbcntr::createSystableLab(Signal* signal, unsigned index)
01547 {
01548 if (index >= g_sysTableCount) {
01549 ndbassert(index == g_sysTableCount);
01550 startInsertTransactions(signal);
01551 return;
01552 }
01553 const SysTable& table = *g_sysTableList[index];
01554 Uint32 propPage[256];
01555 LinearWriter w(propPage, 256);
01556
01557
01558
01559 w.first();
01560 w.add(DictTabInfo::TableName, table.name);
01561 w.add(DictTabInfo::TableLoggedFlag, table.tableLoggedFlag);
01562
01563
01564
01565 w.add(DictTabInfo::FragmentTypeVal, (Uint32)table.fragmentType);
01566
01567
01568 w.add(DictTabInfo::NoOfAttributes, (Uint32)table.columnCount);
01569
01570
01571
01572 w.add(DictTabInfo::TableTypeVal, (Uint32)table.tableType);
01573
01574 for (unsigned i = 0; i < table.columnCount; i++) {
01575 const SysColumn& column = table.columnList[i];
01576 ndbassert(column.pos == i);
01577 w.add(DictTabInfo::AttributeName, column.name);
01578 w.add(DictTabInfo::AttributeId, (Uint32)column.pos);
01579 w.add(DictTabInfo::AttributeKeyFlag, (Uint32)column.keyFlag);
01580
01581 w.add(DictTabInfo::AttributeNullableFlag, (Uint32)column.nullable);
01582 w.add(DictTabInfo::AttributeExtType, (Uint32)column.type);
01583 w.add(DictTabInfo::AttributeExtLength, (Uint32)column.length);
01584 w.add(DictTabInfo::AttributeEnd, (Uint32)true);
01585 }
01586 w.add(DictTabInfo::TableEnd, (Uint32)true);
01587
01588 Uint32 length = w.getWordsUsed();
01589 LinearSectionPtr ptr[3];
01590 ptr[0].p = &propPage[0];
01591 ptr[0].sz = length;
01592
01593 CreateTableReq* const req = (CreateTableReq*)signal->getDataPtrSend();
01594 req->senderData = index;
01595 req->senderRef = reference();
01596 sendSignal(DBDICT_REF, GSN_CREATE_TABLE_REQ, signal,
01597 CreateTableReq::SignalLength, JBB, ptr, 1);
01598 return;
01599 }
01600
01601 void Ndbcntr::execCREATE_TABLE_REF(Signal* signal)
01602 {
01603 jamEntry();
01604 progError(0,0);
01605 return;
01606 }
01607
01608 void Ndbcntr::execCREATE_TABLE_CONF(Signal* signal)
01609 {
01610 jamEntry();
01611 CreateTableConf * const conf = (CreateTableConf*)signal->getDataPtrSend();
01612
01613 ndbrequire(conf->senderData < g_sysTableCount);
01614 const SysTable& table = *g_sysTableList[conf->senderData];
01615 table.tableId = conf->tableId;
01616 createSystableLab(signal, conf->senderData + 1);
01617
01618 return;
01619 }
01620
01621
01622
01623
01624 void Ndbcntr::startInsertTransactions(Signal* signal)
01625 {
01626 jamEntry();
01627
01628 ckey = 1;
01629 ctransidPhase = ZTRUE;
01630 signal->theData[0] = 0;
01631 signal->theData[1] = reference();
01632 sendSignal(DBTC_REF, GSN_TCSEIZEREQ, signal, 2, JBB);
01633 return;
01634 }
01635
01636
01637
01638
01639 void Ndbcntr::execTCSEIZECONF(Signal* signal)
01640 {
01641 jamEntry();
01642 ctcConnectionP = signal->theData[1];
01643 crSystab7Lab(signal);
01644 return;
01645 }
01646
01647 const unsigned int RowsPerCommit = 16;
01648 void Ndbcntr::crSystab7Lab(Signal* signal)
01649 {
01650 UintR tkey;
01651 UintR Tmp;
01652
01653 TcKeyReq * const tcKeyReq = (TcKeyReq *)&signal->theData[0];
01654
01655 UintR reqInfo_Start = 0;
01656 tcKeyReq->setOperationType(reqInfo_Start, ZINSERT);
01657 tcKeyReq->setKeyLength (reqInfo_Start, 1);
01658 tcKeyReq->setAIInTcKeyReq (reqInfo_Start, 5);
01659 tcKeyReq->setAbortOption (reqInfo_Start, TcKeyReq::AbortOnError);
01660
01661
01662 cresponses = 0;
01663 const UintR guard0 = ckey + (RowsPerCommit - 1);
01664 for (Tmp = ckey; Tmp <= guard0; Tmp++) {
01665 UintR reqInfo = reqInfo_Start;
01666 if (Tmp == ckey) {
01667 jam();
01668 tcKeyReq->setStartFlag(reqInfo, 1);
01669 }
01670 if (Tmp == guard0) {
01671 jam();
01672 tcKeyReq->setCommitFlag(reqInfo, 1);
01673 tcKeyReq->setExecuteFlag(reqInfo, 1);
01674 }
01675 if (ctransidPhase == ZTRUE) {
01676 jam();
01677 tkey = 0;
01678 tkey = tkey - Tmp;
01679 } else {
01680 jam();
01681 tkey = Tmp;
01682 }
01683
01684 tcKeyReq->apiConnectPtr = ctcConnectionP;
01685 tcKeyReq->attrLen = 5;
01686 tcKeyReq->tableId = g_sysTable_SYSTAB_0.tableId;
01687 tcKeyReq->requestInfo = reqInfo;
01688 tcKeyReq->tableSchemaVersion = ZSYSTAB_VERSION;
01689 tcKeyReq->transId1 = 0;
01690 tcKeyReq->transId2 = ckey;
01691
01692
01693
01694
01695
01696 Uint32* tKeyDataPtr = &tcKeyReq->scanInfo;
01697 Uint32* tAIDataPtr = &tKeyDataPtr[1];
01698
01699 tKeyDataPtr[0] = tkey;
01700
01701 AttributeHeader::init(&tAIDataPtr[0], 0, 1);
01702 tAIDataPtr[1] = tkey;
01703 AttributeHeader::init(&tAIDataPtr[2], 1, 2);
01704 tAIDataPtr[3] = (tkey << 16);
01705 tAIDataPtr[4] = 1;
01706 sendSignal(DBTC_REF, GSN_TCKEYREQ, signal,
01707 TcKeyReq::StaticLength + 6, JBB);
01708 }
01709 ckey = ckey + RowsPerCommit;
01710 return;
01711 }
01712
01713
01714
01715
01716 void Ndbcntr::execTCKEYCONF(Signal* signal)
01717 {
01718 const TcKeyConf * const keyConf = (TcKeyConf *)&signal->theData[0];
01719
01720 jamEntry();
01721 cgciSystab = keyConf->gci;
01722 UintR confInfo = keyConf->confInfo;
01723
01724 if (TcKeyConf::getMarkerFlag(confInfo)){
01725 Uint32 transId1 = keyConf->transId1;
01726 Uint32 transId2 = keyConf->transId2;
01727 signal->theData[0] = transId1;
01728 signal->theData[1] = transId2;
01729 sendSignal(DBTC_REF, GSN_TC_COMMIT_ACK, signal, 2, JBB);
01730 }
01731
01732 cresponses = cresponses + TcKeyConf::getNoOfOperations(confInfo);
01733 if (TcKeyConf::getCommitFlag(confInfo)){
01734 jam();
01735 ndbrequire(cresponses == RowsPerCommit);
01736
01737 crSystab8Lab(signal);
01738 return;
01739 }
01740 return;
01741 }
01742
01743 void Ndbcntr::crSystab8Lab(Signal* signal)
01744 {
01745 if (ckey < ZSIZE_SYSTAB) {
01746 jam();
01747 crSystab7Lab(signal);
01748 return;
01749 } else if (ctransidPhase == ZTRUE) {
01750 jam();
01751 ckey = 1;
01752 ctransidPhase = ZFALSE;
01753 crSystab7Lab(signal);
01754 return;
01755 }
01756 signal->theData[0] = ctcConnectionP;
01757 signal->theData[1] = reference();
01758 signal->theData[2] = 0;
01759 sendSignal(DBTC_REF, GSN_TCRELEASEREQ, signal, 2, JBB);
01760 return;
01761 }
01762
01763
01764
01765
01766 void Ndbcntr::execTCRELEASECONF(Signal* signal)
01767 {
01768 jamEntry();
01769 waitpoint52Lab(signal);
01770 return;
01771 }
01772
01773 void Ndbcntr::crSystab9Lab(Signal* signal)
01774 {
01775 signal->theData[1] = reference();
01776 sendSignalWithDelay(DBDIH_REF, GSN_GETGCIREQ, signal, 100, 2);
01777 return;
01778 }
01779
01780
01781
01782
01783 void Ndbcntr::execGETGCICONF(Signal* signal)
01784 {
01785 jamEntry();
01786
01787 #ifndef NO_GCP
01788 if (signal->theData[1] < cgciSystab) {
01789 jam();
01790
01791
01792
01793
01794 crSystab9Lab(signal);
01795 return;
01796 }
01797 #endif
01798 waitpoint52Lab(signal);
01799 return;
01800 }
01801
01802 void Ndbcntr::execTCKEYREF(Signal* signal)
01803 {
01804 jamEntry();
01805 systemErrorLab(signal);
01806 return;
01807 }
01808
01809 void Ndbcntr::execTCROLLBACKREP(Signal* signal)
01810 {
01811 jamEntry();
01812 systemErrorLab(signal);
01813 return;
01814 }
01815
01816 void Ndbcntr::execTCRELEASEREF(Signal* signal)
01817 {
01818 jamEntry();
01819 systemErrorLab(signal);
01820 return;
01821 }
01822
01823 void Ndbcntr::execTCSEIZEREF(Signal* signal)
01824 {
01825 jamEntry();
01826 systemErrorLab(signal);
01827 return;
01828 }
01829
01830
01831
01832
01833
01834 void Ndbcntr::initData(Signal* signal)
01835 {
01836 c_start.reset();
01837 cmasterNodeId = 0;
01838 cnoStartNodes = 0;
01839 cnoWaitrep = 0;
01840 }
01841
01842
01843
01844
01845
01846 void Ndbcntr::resetStartVariables(Signal* signal)
01847 {
01848 cnoStartNodes = 0;
01849 cnoWaitrep6 = cnoWaitrep7 = 0;
01850 }
01851
01852
01853
01854
01855
01856
01857 void Ndbcntr::sendNdbSttor(Signal* signal)
01858 {
01859 NdbBlocksRecPtr ndbBlocksPtr;
01860
01861 ndbBlocksPtr.i = cndbBlocksCount;
01862 ptrCheckGuard(ndbBlocksPtr, ZSIZE_NDB_BLOCKS_REC, ndbBlocksRec);
01863
01864 NdbSttor * const req = (NdbSttor*)signal->getDataPtrSend();
01865 req->senderRef = reference();
01866 req->nodeId = getOwnNodeId();
01867 req->internalStartPhase = cinternalStartphase;
01868 req->typeOfStart = ctypeOfStart;
01869 req->masterNodeId = cmasterNodeId;
01870
01871 for (int i = 0; i < 16; i++) {
01872
01873 req->config[i] = 0x88776655;
01874
01875 }
01876
01877
01878 #ifdef TRACE_STTOR
01879 ndbout_c("sending NDB_STTOR(%d) to %s",
01880 cinternalStartphase,
01881 getBlockName( refToBlock(ndbBlocksPtr.p->blockref)));
01882 #endif
01883 sendSignal(ndbBlocksPtr.p->blockref, GSN_NDB_STTOR, signal, 22, JBB);
01884 cndbBlocksCount++;
01885 }
01886
01887
01888
01889
01890 void Ndbcntr::sendSttorry(Signal* signal)
01891 {
01892 signal->theData[3] = ZSTART_PHASE_1;
01893 signal->theData[4] = ZSTART_PHASE_2;
01894 signal->theData[5] = ZSTART_PHASE_3;
01895 signal->theData[6] = ZSTART_PHASE_4;
01896 signal->theData[7] = ZSTART_PHASE_5;
01897 signal->theData[8] = ZSTART_PHASE_6;
01898
01899 signal->theData[9] = ZSTART_PHASE_8;
01900 signal->theData[10] = ZSTART_PHASE_9;
01901 signal->theData[11] = ZSTART_PHASE_END;
01902 sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 12, JBB);
01903 }
01904
01905 void
01906 Ndbcntr::execDUMP_STATE_ORD(Signal* signal)
01907 {
01908 DumpStateOrd * const & dumpState = (DumpStateOrd *)&signal->theData[0];
01909 if(signal->theData[0] == 13){
01910 infoEvent("Cntr: cstartPhase = %d, cinternalStartphase = %d, block = %d",
01911 cstartPhase, cinternalStartphase, cndbBlocksCount);
01912 infoEvent("Cntr: cmasterNodeId = %d", cmasterNodeId);
01913 }
01914
01915 if (dumpState->args[0] == DumpStateOrd::NdbcntrTestStopOnError){
01916 if (theConfiguration.stopOnError() == true)
01917 ((Configuration&)theConfiguration).stopOnError(false);
01918
01919 const BlockReference tblockref = calcNdbCntrBlockRef(getOwnNodeId());
01920
01921 SystemError * const sysErr = (SystemError*)&signal->theData[0];
01922 sysErr->errorCode = SystemError::TestStopOnError;
01923 sysErr->errorRef = reference();
01924 sendSignal(tblockref, GSN_SYSTEM_ERROR, signal,
01925 SystemError::SignalLength, JBA);
01926 }
01927
01928
01929 }
01930
01931 void Ndbcntr::execSET_VAR_REQ(Signal* signal) {
01932 #if 0
01933 SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0];
01934 ConfigParamId var = setVarReq->variable();
01935
01936 switch (var) {
01937 case TimeToWaitAlive:
01938
01939 sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB);
01940 break;
01941
01942 default:
01943 sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB);
01944 }
01945 #endif
01946 }
01947
01948 void Ndbcntr::updateNodeState(Signal* signal, const NodeState& newState) const{
01949 NodeStateRep * const stateRep = (NodeStateRep *)&signal->theData[0];
01950
01951 stateRep->nodeState = newState;
01952 stateRep->nodeState.masterNodeId = cmasterNodeId;
01953 stateRep->nodeState.setNodeGroup(c_nodeGroup);
01954
01955 for(Uint32 i = 0; i<ALL_BLOCKS_SZ; i++){
01956 sendSignal(ALL_BLOCKS[i].Ref, GSN_NODE_STATE_REP, signal,
01957 NodeStateRep::SignalLength, JBB);
01958 }
01959 }
01960
01961 void
01962 Ndbcntr::execRESUME_REQ(Signal* signal){
01963
01964
01965
01966 jamEntry();
01967
01968
01969 NodeState newState(NodeState::SL_STARTED);
01970 updateNodeState(signal, newState);
01971 c_stopRec.stopReq.senderRef=0;
01972 }
01973
01974 void
01975 Ndbcntr::execSTOP_REQ(Signal* signal){
01976 StopReq * const req = (StopReq *)&signal->theData[0];
01977 StopRef * const ref = (StopRef *)&signal->theData[0];
01978 Uint32 singleuser = req->singleuser;
01979 jamEntry();
01980 Uint32 senderData = req->senderData;
01981 BlockReference senderRef = req->senderRef;
01982 bool abort = StopReq::getStopAbort(req->requestInfo);
01983
01984 if(getNodeState().startLevel < NodeState::SL_STARTED ||
01985 abort && !singleuser){
01991 jam();
01992 const Uint32 reqInfo = req->requestInfo;
01993 if(StopReq::getPerformRestart(reqInfo)){
01994 jam();
01995 StartOrd * startOrd = (StartOrd *)&signal->theData[0];
01996 startOrd->restartInfo = reqInfo;
01997 sendSignal(CMVMI_REF, GSN_START_ORD, signal, 1, JBA);
01998 } else {
01999 jam();
02000 sendSignal(CMVMI_REF, GSN_STOP_ORD, signal, 1, JBA);
02001 }
02002 return;
02003 }
02004
02005 if(c_stopRec.stopReq.senderRef != 0 && !singleuser){
02006 jam();
02010 if(StopReq::getSystemStop(req->requestInfo)){
02011 jam();
02012 sendSignalWithDelay(reference(), GSN_STOP_REQ, signal, 100,
02013 StopReq::SignalLength);
02014 return;
02015 }
02016
02020 if(StopReq::getSystemStop(c_stopRec.stopReq.requestInfo))
02021 ref->errorCode = StopRef::SystemShutdownInProgress;
02022 else
02023 ref->errorCode = StopRef::NodeShutdownInProgress;
02024 ref->senderData = senderData;
02025 sendSignal(senderRef, GSN_STOP_REF, signal, StopRef::SignalLength, JBB);
02026 return;
02027 }
02028
02029 c_stopRec.stopReq = * req;
02030 c_stopRec.stopInitiatedTime = NdbTick_CurrentMillisecond();
02031
02032 if(StopReq::getSystemStop(c_stopRec.stopReq.requestInfo) && !singleuser) {
02033 jam();
02034 if(StopReq::getPerformRestart(c_stopRec.stopReq.requestInfo)){
02035 ((Configuration&)theConfiguration).stopOnError(false);
02036 }
02037 }
02038 if(!singleuser) {
02039 if(!c_stopRec.checkNodeFail(signal)){
02040 jam();
02041 return;
02042 }
02043 }
02044
02045 signal->theData[0] = NDB_LE_NDBStopStarted;
02046 signal->theData[1] = StopReq::getSystemStop(c_stopRec.stopReq.requestInfo) ? 1 : 0;
02047 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
02048
02049 NodeState newState(NodeState::SL_STOPPING_1,
02050 StopReq::getSystemStop(c_stopRec.stopReq.requestInfo));
02051
02052 if(singleuser) {
02053 newState.setSingleUser(true);
02054 newState.setSingleUserApi(c_stopRec.stopReq.singleUserApi);
02055 }
02056 updateNodeState(signal, newState);
02057 signal->theData[0] = ZSHUTDOWN;
02058 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 1);
02059 }
02060
02061 void
02062 Ndbcntr::StopRecord::checkTimeout(Signal* signal){
02063 jamEntry();
02064
02065 if(!cntr.getNodeState().getSingleUserMode())
02066 if(!checkNodeFail(signal)){
02067 jam();
02068 return;
02069 }
02070
02071 switch(cntr.getNodeState().startLevel){
02072 case NodeState::SL_STOPPING_1:
02073 checkApiTimeout(signal);
02074 break;
02075 case NodeState::SL_STOPPING_2:
02076 checkTcTimeout(signal);
02077 break;
02078 case NodeState::SL_STOPPING_3:
02079 checkLqhTimeout_1(signal);
02080 break;
02081 case NodeState::SL_STOPPING_4:
02082 checkLqhTimeout_2(signal);
02083 break;
02084 case NodeState::SL_SINGLEUSER:
02085 break;
02086 default:
02087 ndbrequire(false);
02088 }
02089 }
02090
02091 bool
02092 Ndbcntr::StopRecord::checkNodeFail(Signal* signal){
02093 jam();
02094 if(StopReq::getSystemStop(stopReq.requestInfo)){
02095 jam();
02096 return true;
02097 }
02098
02102 NodeBitmask ndbMask;
02103 ndbMask.assign(cntr.c_startedNodes);
02104 ndbMask.clear(cntr.getOwnNodeId());
02105
02106 CheckNodeGroups* sd = (CheckNodeGroups*)&signal->theData[0];
02107 sd->blockRef = cntr.reference();
02108 sd->requestType = CheckNodeGroups::Direct | CheckNodeGroups::ArbitCheck;
02109 sd->mask = ndbMask;
02110 cntr.EXECUTE_DIRECT(DBDIH, GSN_CHECKNODEGROUPSREQ, signal,
02111 CheckNodeGroups::SignalLength);
02112 jamEntry();
02113 switch (sd->output) {
02114 case CheckNodeGroups::Win:
02115 case CheckNodeGroups::Partitioning:
02116 return true;
02117 break;
02118 }
02119
02120 StopRef * const ref = (StopRef *)&signal->theData[0];
02121
02122 ref->senderData = stopReq.senderData;
02123 ref->errorCode = StopRef::NodeShutdownWouldCauseSystemCrash;
02124
02125 const BlockReference bref = stopReq.senderRef;
02126 cntr.sendSignal(bref, GSN_STOP_REF, signal, StopRef::SignalLength, JBB);
02127
02128 stopReq.senderRef = 0;
02129
02130 NodeState newState(NodeState::SL_STARTED);
02131
02132 cntr.updateNodeState(signal, newState);
02133
02134 signal->theData[0] = NDB_LE_NDBStopAborted;
02135 cntr.sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 1, JBB);
02136
02137 return false;
02138 }
02139
02140 void
02141 Ndbcntr::StopRecord::checkApiTimeout(Signal* signal){
02142 const Int32 timeout = stopReq.apiTimeout;
02143 const NDB_TICKS alarm = stopInitiatedTime + (NDB_TICKS)timeout;
02144 const NDB_TICKS now = NdbTick_CurrentMillisecond();
02145 if((timeout >= 0 && now >= alarm)){
02146
02147 jam();
02148 NodeState newState(NodeState::SL_STOPPING_2,
02149 StopReq::getSystemStop(stopReq.requestInfo));
02150 if(stopReq.singleuser) {
02151 newState.setSingleUser(true);
02152 newState.setSingleUserApi(stopReq.singleUserApi);
02153 }
02154 cntr.updateNodeState(signal, newState);
02155
02156 stopInitiatedTime = now;
02157 }
02158
02159 signal->theData[0] = ZSHUTDOWN;
02160 cntr.sendSignalWithDelay(cntr.reference(), GSN_CONTINUEB, signal, 100, 1);
02161 }
02162
02163 void
02164 Ndbcntr::StopRecord::checkTcTimeout(Signal* signal){
02165 const Int32 timeout = stopReq.transactionTimeout;
02166 const NDB_TICKS alarm = stopInitiatedTime + (NDB_TICKS)timeout;
02167 const NDB_TICKS now = NdbTick_CurrentMillisecond();
02168 if((timeout >= 0 && now >= alarm)){
02169
02170 jam();
02171 if(stopReq.getSystemStop(stopReq.requestInfo) || stopReq.singleuser){
02172 jam();
02173 if(stopReq.singleuser)
02174 {
02175 jam();
02176 AbortAllReq * req = (AbortAllReq*)&signal->theData[0];
02177 req->senderRef = cntr.reference();
02178 req->senderData = 12;
02179 cntr.sendSignal(DBTC_REF, GSN_ABORT_ALL_REQ, signal,
02180 AbortAllReq::SignalLength, JBB);
02181 }
02182 else
02183 {
02184 WaitGCPReq * req = (WaitGCPReq*)&signal->theData[0];
02185 req->senderRef = cntr.reference();
02186 req->senderData = 12;
02187 req->requestType = WaitGCPReq::CompleteForceStart;
02188 cntr.sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal,
02189 WaitGCPReq::SignalLength, JBB);
02190 }
02191 } else {
02192 jam();
02193 StopPermReq * req = (StopPermReq*)&signal->theData[0];
02194 req->senderRef = cntr.reference();
02195 req->senderData = 12;
02196 cntr.sendSignal(DBDIH_REF, GSN_STOP_PERM_REQ, signal,
02197 StopPermReq::SignalLength, JBB);
02198 }
02199 return;
02200 }
02201 signal->theData[0] = ZSHUTDOWN;
02202 cntr.sendSignalWithDelay(cntr.reference(), GSN_CONTINUEB, signal, 100, 1);
02203 }
02204
02205 void Ndbcntr::execSTOP_PERM_REF(Signal* signal){
02206
02207
02208 jamEntry();
02209
02210 signal->theData[0] = ZSHUTDOWN;
02211 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 1);
02212 }
02213
02214 void Ndbcntr::execSTOP_PERM_CONF(Signal* signal){
02215 jamEntry();
02216
02217 AbortAllReq * req = (AbortAllReq*)&signal->theData[0];
02218 req->senderRef = reference();
02219 req->senderData = 12;
02220 sendSignal(DBTC_REF, GSN_ABORT_ALL_REQ, signal,
02221 AbortAllReq::SignalLength, JBB);
02222 }
02223
02224 void Ndbcntr::execABORT_ALL_CONF(Signal* signal){
02225 jamEntry();
02226 if(c_stopRec.stopReq.singleuser) {
02227 jam();
02228 NodeState newState(NodeState::SL_SINGLEUSER);
02229 newState.setSingleUser(true);
02230 newState.setSingleUserApi(c_stopRec.stopReq.singleUserApi);
02231 updateNodeState(signal, newState);
02232 c_stopRec.stopInitiatedTime = NdbTick_CurrentMillisecond();
02233
02234 }
02235 else
02236 {
02237 jam();
02238 NodeState newState(NodeState::SL_STOPPING_3,
02239 StopReq::getSystemStop(c_stopRec.stopReq.requestInfo));
02240 updateNodeState(signal, newState);
02241
02242 c_stopRec.stopInitiatedTime = NdbTick_CurrentMillisecond();
02243
02244 signal->theData[0] = ZSHUTDOWN;
02245 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 1);
02246 }
02247 }
02248
02249 void Ndbcntr::execABORT_ALL_REF(Signal* signal){
02250 jamEntry();
02251 ndbrequire(false);
02252 }
02253
02254 void
02255 Ndbcntr::StopRecord::checkLqhTimeout_1(Signal* signal){
02256 const Int32 timeout = stopReq.readOperationTimeout;
02257 const NDB_TICKS alarm = stopInitiatedTime + (NDB_TICKS)timeout;
02258 const NDB_TICKS now = NdbTick_CurrentMillisecond();
02259
02260 if((timeout >= 0 && now >= alarm)){
02261
02262 jam();
02263
02264 ChangeNodeStateReq * req = (ChangeNodeStateReq*)&signal->theData[0];
02265
02266 NodeState newState(NodeState::SL_STOPPING_4,
02267 StopReq::getSystemStop(stopReq.requestInfo));
02268 req->nodeState = newState;
02269 req->senderRef = cntr.reference();
02270 req->senderData = 12;
02271 cntr.sendSignal(DBLQH_REF, GSN_CHANGE_NODE_STATE_REQ, signal, 2, JBB);
02272 return;
02273 }
02274 signal->theData[0] = ZSHUTDOWN;
02275 cntr.sendSignalWithDelay(cntr.reference(), GSN_CONTINUEB, signal, 100, 1);
02276 }
02277
02278 void Ndbcntr::execCHANGE_NODE_STATE_CONF(Signal* signal){
02279 jamEntry();
02280 signal->theData[0] = reference();
02281 signal->theData[1] = 12;
02282 sendSignal(DBDIH_REF, GSN_STOP_ME_REQ, signal, 2, JBB);
02283 }
02284
02285 void Ndbcntr::execSTOP_ME_REF(Signal* signal){
02286 jamEntry();
02287 ndbrequire(false);
02288 }
02289
02290
02291 void Ndbcntr::execSTOP_ME_CONF(Signal* signal){
02292 jamEntry();
02293
02294 NodeState newState(NodeState::SL_STOPPING_4,
02295 StopReq::getSystemStop(c_stopRec.stopReq.requestInfo));
02296 updateNodeState(signal, newState);
02297
02298 c_stopRec.stopInitiatedTime = NdbTick_CurrentMillisecond();
02299 signal->theData[0] = ZSHUTDOWN;
02300 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 1);
02301 }
02302
02303 void
02304 Ndbcntr::StopRecord::checkLqhTimeout_2(Signal* signal){
02305 const Int32 timeout = stopReq.operationTimeout;
02306 const NDB_TICKS alarm = stopInitiatedTime + (NDB_TICKS)timeout;
02307 const NDB_TICKS now = NdbTick_CurrentMillisecond();
02308
02309 if((timeout >= 0 && now >= alarm)){
02310
02311 jam();
02312 if(StopReq::getPerformRestart(stopReq.requestInfo)){
02313 jam();
02314 StartOrd * startOrd = (StartOrd *)&signal->theData[0];
02315 startOrd->restartInfo = stopReq.requestInfo;
02316 cntr.sendSignal(CMVMI_REF, GSN_START_ORD, signal, 2, JBA);
02317 } else {
02318 jam();
02319 cntr.sendSignal(CMVMI_REF, GSN_STOP_ORD, signal, 1, JBA);
02320 }
02321 return;
02322 }
02323 signal->theData[0] = ZSHUTDOWN;
02324 cntr.sendSignalWithDelay(cntr.reference(), GSN_CONTINUEB, signal, 100, 1);
02325 }
02326
02327 void Ndbcntr::execWAIT_GCP_REF(Signal* signal){
02328 jamEntry();
02329
02330
02331
02332 WaitGCPReq * req = (WaitGCPReq*)&signal->theData[0];
02333 req->senderRef = reference();
02334 req->senderData = 12;
02335 req->requestType = WaitGCPReq::CompleteForceStart;
02336 sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal,
02337 WaitGCPReq::SignalLength, JBB);
02338 }
02339
02340 void Ndbcntr::execWAIT_GCP_CONF(Signal* signal){
02341 jamEntry();
02342
02343 ndbrequire(StopReq::getSystemStop(c_stopRec.stopReq.requestInfo));
02344 NodeState newState(NodeState::SL_STOPPING_3, true);
02345
02349 NodeStateRep * rep = (NodeStateRep *)&signal->theData[0];
02350 rep->nodeState = newState;
02351 rep->nodeState.masterNodeId = cmasterNodeId;
02352 rep->nodeState.setNodeGroup(c_nodeGroup);
02353 EXECUTE_DIRECT(QMGR, GSN_NODE_STATE_REP, signal, NodeStateRep::SignalLength);
02354
02355 if(StopReq::getPerformRestart(c_stopRec.stopReq.requestInfo)){
02356 jam();
02357 StartOrd * startOrd = (StartOrd *)&signal->theData[0];
02358 startOrd->restartInfo = c_stopRec.stopReq.requestInfo;
02359 sendSignalWithDelay(CMVMI_REF, GSN_START_ORD, signal, 500,
02360 StartOrd::SignalLength);
02361 } else {
02362 jam();
02363 sendSignalWithDelay(CMVMI_REF, GSN_STOP_ORD, signal, 500, 1);
02364 }
02365 return;
02366 }
02367
02368 void Ndbcntr::execSTTORRY(Signal* signal){
02369 jamEntry();
02370 c_missra.execSTTORRY(signal);
02371 }
02372
02373 void Ndbcntr::execREAD_CONFIG_CONF(Signal* signal){
02374 jamEntry();
02375 c_missra.execREAD_CONFIG_CONF(signal);
02376 }
02377
02378 void Ndbcntr::execSTART_ORD(Signal* signal){
02379 jamEntry();
02380 ndbrequire(NO_OF_BLOCKS == ALL_BLOCKS_SZ);
02381 c_missra.execSTART_ORD(signal);
02382 }
02383
02384 void
02385 Ndbcntr::clearFilesystem(Signal* signal){
02386 FsRemoveReq * req = (FsRemoveReq *)signal->getDataPtrSend();
02387 req->userReference = reference();
02388 req->userPointer = 0;
02389 req->directory = 1;
02390 req->ownDirectory = 1;
02391 FsOpenReq::setVersion(req->fileNumber, 3);
02392 FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_CTL);
02393 FsOpenReq::v1_setDisk(req->fileNumber, c_fsRemoveCount);
02394 sendSignal(NDBFS_REF, GSN_FSREMOVEREQ, signal,
02395 FsRemoveReq::SignalLength, JBA);
02396 c_fsRemoveCount++;
02397 }
02398
02399 void
02400 Ndbcntr::execFSREMOVEREF(Signal* signal){
02401 jamEntry();
02402 ndbrequire(0);
02403 }
02404
02405 void
02406 Ndbcntr::execFSREMOVECONF(Signal* signal){
02407 jamEntry();
02408 if(c_fsRemoveCount == 13){
02409 jam();
02410 sendSttorry(signal);
02411 } else {
02412 jam();
02413 ndbrequire(c_fsRemoveCount < 13);
02414 clearFilesystem(signal);
02415 }
02416 }
02417
02418 void Ndbcntr::Missra::execSTART_ORD(Signal* signal){
02419 signal->theData[0] = NDB_LE_NDBStartStarted;
02420 signal->theData[1] = NDB_VERSION;
02421 cntr.sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
02422
02423 currentBlockIndex = 0;
02424 sendNextREAD_CONFIG_REQ(signal);
02425 }
02426
02427 void Ndbcntr::Missra::sendNextREAD_CONFIG_REQ(Signal* signal){
02428
02429 if(currentBlockIndex < ALL_BLOCKS_SZ){
02430 jam();
02431
02432 ReadConfigReq * req = (ReadConfigReq*)signal->getDataPtrSend();
02433 req->senderData = 0;
02434 req->senderRef = cntr.reference();
02435 req->noOfParameters = 0;
02436
02437 const BlockReference ref = ALL_BLOCKS[currentBlockIndex].Ref;
02438
02439 #if 0
02440 ndbout_c("sending READ_CONFIG_REQ to %s(ref=%x index=%d)",
02441 getBlockName( refToBlock(ref)),
02442 ref,
02443 currentBlockIndex);
02444 #endif
02445
02446 cntr.sendSignal(ref, GSN_READ_CONFIG_REQ, signal,
02447 ReadConfigReq::SignalLength, JBB);
02448 return;
02449 }
02450
02454 currentStartPhase = 0;
02455 for(Uint32 i = 0; i<NO_OF_BLOCKS; i++){
02456 if(ALL_BLOCKS[i].NextSP < currentStartPhase)
02457 currentStartPhase = ALL_BLOCKS[i].NextSP;
02458 }
02459
02460 currentBlockIndex = 0;
02461 sendNextSTTOR(signal);
02462 }
02463
02464 void Ndbcntr::Missra::execREAD_CONFIG_CONF(Signal* signal){
02465 const ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtr();
02466
02467 const Uint32 ref = conf->senderRef;
02468 ndbrequire(refToBlock(ALL_BLOCKS[currentBlockIndex].Ref) == refToBlock(ref));
02469
02470 currentBlockIndex++;
02471 sendNextREAD_CONFIG_REQ(signal);
02472 }
02473
02474 void Ndbcntr::Missra::execSTTORRY(Signal* signal){
02475 const BlockReference ref = signal->senderBlockRef();
02476 ndbrequire(refToBlock(ref) == refToBlock(ALL_BLOCKS[currentBlockIndex].Ref));
02477
02481 for (Uint32 i = 3; i < 25; i++){
02482 jam();
02483 if (signal->theData[i] > currentStartPhase){
02484 jam();
02485 ALL_BLOCKS[currentBlockIndex].NextSP = signal->theData[i];
02486 break;
02487 }
02488 }
02489
02490 currentBlockIndex++;
02491 sendNextSTTOR(signal);
02492 }
02493
02494 void Ndbcntr::Missra::sendNextSTTOR(Signal* signal){
02495
02496 for(; currentStartPhase < 255 ; currentStartPhase++){
02497 jam();
02498
02499 const Uint32 start = currentBlockIndex;
02500
02501 for(; currentBlockIndex < ALL_BLOCKS_SZ; currentBlockIndex++){
02502 jam();
02503 if(ALL_BLOCKS[currentBlockIndex].NextSP == currentStartPhase){
02504 jam();
02505 signal->theData[0] = 0;
02506 signal->theData[1] = currentStartPhase;
02507 signal->theData[2] = 0;
02508 signal->theData[3] = 0;
02509 signal->theData[4] = 0;
02510 signal->theData[5] = 0;
02511 signal->theData[6] = 0;
02512 signal->theData[7] = cntr.ctypeOfStart;
02513
02514 const BlockReference ref = ALL_BLOCKS[currentBlockIndex].Ref;
02515
02516 #ifdef MAX_STARTPHASE
02517 ndbrequire(currentStartPhase <= MAX_STARTPHASE);
02518 #endif
02519
02520 #ifdef TRACE_STTOR
02521 ndbout_c("sending STTOR(%d) to %s(ref=%x index=%d)",
02522 currentStartPhase,
02523 getBlockName( refToBlock(ref)),
02524 ref,
02525 currentBlockIndex);
02526 #endif
02527
02528 cntr.sendSignal(ref, GSN_STTOR, signal, 8, JBB);
02529
02530 return;
02531 }
02532 }
02533
02534 currentBlockIndex = 0;
02535
02536 if(start != 0){
02540 jam();
02541 signal->theData[0] = NDB_LE_StartPhaseCompleted;
02542 signal->theData[1] = currentStartPhase;
02543 signal->theData[2] = cntr.ctypeOfStart;
02544 cntr.sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);
02545 }
02546 }
02547
02548 signal->theData[0] = NDB_LE_NDBStartCompleted;
02549 signal->theData[1] = NDB_VERSION;
02550 cntr.sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
02551
02552 NodeState newState(NodeState::SL_STARTED);
02553 cntr.updateNodeState(signal, newState);
02554
02558 UpgradeStartup::sendCmAppChg(cntr, signal, 3);
02559
02560 NdbNodeBitmask nodes = cntr.c_clusterNodes;
02561 Uint32 node = 0;
02562 while((node = nodes.find(node+1)) != NdbNodeBitmask::NotFound){
02563 if(cntr.getNodeInfo(node).m_version < MAKE_VERSION(3,5,0)){
02564 nodes.clear(node);
02565 }
02566 }
02567
02568 NodeReceiverGroup rg(NDBCNTR, nodes);
02569 signal->theData[0] = cntr.getOwnNodeId();
02570 cntr.sendSignal(rg, GSN_CNTR_START_REP, signal, 1, JBB);
02571 }
02572
02576 void
02577 UpgradeStartup::sendCmAppChg(Ndbcntr& cntr, Signal* signal, Uint32 startLevel){
02578
02579 if(cntr.getNodeInfo(cntr.cmasterNodeId).m_version >= MAKE_VERSION(3,5,0)){
02580 jam();
02581 return;
02582 }
02583
02588 signal->theData[0] = startLevel;
02589 signal->theData[1] = cntr.getOwnNodeId();
02590 signal->theData[2] = 3 | ('N' << 8);
02591 signal->theData[3] = 'D' | ('B' << 8);
02592 signal->theData[4] = 0;
02593 signal->theData[5] = 0;
02594 signal->theData[6] = 0;
02595 signal->theData[7] = 0;
02596 signal->theData[8] = 0;
02597 signal->theData[9] = 0;
02598 signal->theData[10] = 0;
02599 signal->theData[11] = 0;
02600
02601 NdbNodeBitmask nodes = cntr.c_clusterNodes;
02602 nodes.clear(cntr.getOwnNodeId());
02603 Uint32 node = 0;
02604 while((node = nodes.find(node+1)) != NdbNodeBitmask::NotFound){
02605 if(cntr.getNodeInfo(node).m_version < MAKE_VERSION(3,5,0)){
02606 cntr.sendSignal(cntr.calcQmgrBlockRef(node),
02607 GSN_CM_APPCHG, signal, 12, JBB);
02608 } else {
02609 cntr.c_startedNodes.set(node);
02610 }
02611 }
02612 }
02613
02614 void
02615 UpgradeStartup::execCM_APPCHG(SimulatedBlock & block, Signal* signal){
02616 Uint32 state = signal->theData[0];
02617 Uint32 nodeId = signal->theData[1];
02618 if(block.number() == QMGR){
02619 Ndbcntr& cntr = * (Ndbcntr*)globalData.getBlock(CNTR);
02620 switch(state){
02621 case 0:
02622 break;
02623 case 2:
02624 break;
02625 case 3:
02626 cntr.c_startedNodes.set(nodeId);
02627
02628 Uint32 recv = cntr.c_startedNodes.count();
02629 Uint32 cnt = cntr.c_clusterNodes.count();
02630 if(recv + 1 == cnt){
02634 sendCntrMasterReq(cntr, signal, 0);
02635 }
02636 return;
02637 }
02638 }
02639 block.progError(0,0);
02640 }
02641
02642 void
02643 UpgradeStartup::sendCntrMasterReq(Ndbcntr& cntr, Signal* signal, Uint32 n){
02644 Uint32 node = cntr.c_startedNodes.find(n);
02645 if(node != NdbNodeBitmask::NotFound &&
02646 (node == cntr.getOwnNodeId() ||
02647 cntr.getNodeInfo(node).m_version >= MAKE_VERSION(3,5,0))){
02648 node = cntr.c_startedNodes.find(node+1);
02649 }
02650
02651 if(node == NdbNodeBitmask::NotFound){
02652 cntr.progError(0,0);
02653 }
02654
02655 CntrMasterReq * const cntrMasterReq = (CntrMasterReq*)&signal->theData[0];
02656 cntr.c_clusterNodes.copyto(NdbNodeBitmask::Size, cntrMasterReq->theNodes);
02657 NdbNodeBitmask::clear(cntrMasterReq->theNodes, cntr.getOwnNodeId());
02658 cntrMasterReq->userBlockRef = 0;
02659 cntrMasterReq->userNodeId = cntr.getOwnNodeId();
02660 cntrMasterReq->typeOfStart = NodeState::ST_INITIAL_NODE_RESTART;
02661 cntrMasterReq->noRestartNodes = cntr.c_clusterNodes.count() - 1;
02662 cntr.sendSignal(cntr.calcNdbCntrBlockRef(node), GSN_CNTR_MASTERREQ,
02663 signal, CntrMasterReq::SignalLength, JBB);
02664 }
02665
02666 void
02667 UpgradeStartup::execCNTR_MASTER_REPLY(SimulatedBlock & block, Signal* signal){
02668 Uint32 gsn = signal->header.theVerId_signalNumber;
02669 Uint32 node = refToNode(signal->getSendersBlockRef());
02670 if(block.number() == CNTR){
02671 Ndbcntr& cntr = (Ndbcntr&)block;
02672 switch(gsn){
02673 case GSN_CNTR_MASTERREF:
02674 sendCntrMasterReq(cntr, signal, node + 1);
02675 return;
02676 break;
02677 case GSN_CNTR_MASTERCONF:{
02678 CntrStartConf* conf = (CntrStartConf*)signal->getDataPtrSend();
02679 conf->startGci = 0;
02680 conf->masterNodeId = node;
02681 conf->noStartNodes = 1;
02682 conf->startType = NodeState::ST_INITIAL_NODE_RESTART;
02683 NodeBitmask mask;
02684 mask.clear();
02685 mask.copyto(NdbNodeBitmask::Size, conf->startedNodes);
02686 mask.clear();
02687 mask.set(cntr.getOwnNodeId());
02688 mask.copyto(NdbNodeBitmask::Size, conf->startingNodes);
02689 cntr.execCNTR_START_CONF(signal);
02690 return;
02691 }
02692 }
02693 }
02694 block.progError(0,0);
02695 }