24 #include <SimulatedBlock.hpp>
25 #include <NodeBitmask.hpp>
26 #include <SignalCounter.hpp>
28 #include <signaldata/EventReport.hpp>
29 #include <signaldata/ArbitSignalData.hpp>
30 #include <signaldata/CmRegSignalData.hpp>
31 #include <signaldata/ApiRegSignalData.hpp>
32 #include <signaldata/FailRep.hpp>
33 #include <signaldata/AllocNodeId.hpp>
35 #include <RequestTracker.hpp>
36 #include <signaldata/StopReq.hpp>
43 #define ZDELAY_REGREQ 1000
46 #define ZNOT_RUNNING 0
49 #define ZREGREQ_TIMELIMIT 0
50 #define ZHB_HANDLING 1
51 #define ZREGREQ_MASTER_TIMELIMIT 2
52 #define ZAPI_HB_HANDLING 3
53 #define ZTIMER_HANDLING 4
54 #define ZARBIT_HANDLING 5
55 #define ZSTART_FAILURE_LIMIT 6
58 #define ZERRTOOMANY 1101
59 #define ZERRALREADYREG 1102
60 #define ZERRNHMISSING 1103
61 #define ZERRNLMISSING 1104
62 #define ZERRAPPMISSING 1105
63 #define ZERROR_NOT_IN_CFGFILE 1106
64 #define ZERROR_TIMEOUT 1107
65 #define ZERROR_NOT_ZINIT 1108
66 #define ZERROR_NODEINFOREF 1109
67 #define ZERROR_NOTLOCALQMGR 1110
68 #define ZERROR_NOTRUNNING 1111
69 #define ZCOULD_NOT_OCCUR_ERROR 1112
70 #define ZTIME_OUT_ERROR 1113
71 #define ZERROR_NOT_DEAD 1114
72 #define ZDECLARED_FAIL_ERROR 1115
73 #define ZOWN_NODE_ERROR 1116
74 #define ZWRONG_STATE_ERROR 1117
75 #define ZNODE_ZERO_ERROR 1118
76 #define ZWRONG_NODE_ERROR 1119
80 #define QMGR_MAX_FAIL_STATE_BLOCKS 5
92 WAITING_FOR_CLOSECOMCONF_ACTIVE = 1,
93 WAITING_FOR_CLOSECOMCONF_NOTACTIVE = 2,
94 WAITING_FOR_API_FAILCONF = 3,
95 WAITING_FOR_NDB_FAILCONF = 6
114 m_nodes.clearWaitingFor();
118 Uint64 m_startTimeout;
130 Uint16 m_president_candidate;
131 Uint32 m_president_candidate_gci;
132 Uint16 m_regReqReqSent;
133 Uint16 m_regReqReqRecv;
134 Uint32 m_node_gci[MAX_NDB_NODES];
148 Uint32 c_maxDynamicId;
155 Uint32 m_currentRound;
168 m_nodesPinged.
clear();
169 m_nodesWaiting.
clear();
170 m_nodesFailedDuring.
clear();
171 m_nodesSuspect.
clear();
174 void reportNodeConnect(Uint32 nodeId);
178 bool reportNodeFailure(Uint32 nodeId);
180 bool getEnabled()
const {
183 assert(m_timer.getDelay() > 0);
209 QmgrState sendPrepFailReqStatus;
210 QmgrState sendCommitFailReqStatus;
211 QmgrState sendPresToStatus;
213 BlockReference blockRef;
215 Uint64 m_alloc_timeout;
216 Uint16 m_failconf_blocks[QMGR_MAX_FAIL_STATE_BLOCKS];
218 NodeRec() { bzero(m_failconf_blocks,
sizeof(m_failconf_blocks)); }
239 DISABLED = ARBIT_METHOD_DISABLED,
240 METHOD_DEFAULT = ARBIT_METHOD_DEFAULT,
242 METHOD_EXTERNAL = ARBIT_METHOD_WAITEXTERNAL
263 ticket.match(sd->ticket);
266 inline void setTimestamp() {
267 timestamp = NdbTick_CurrentMillisecond();
270 inline NDB_TICKS getTimediff() {
271 NDB_TICKS now = NdbTick_CurrentMillisecond();
272 return now < timestamp ? 0 : now - timestamp;
277 enum EnableComState {
278 ENABLE_COM_CM_ADD_COMMIT = 0,
279 ENABLE_COM_CM_COMMIT_NEW = 1,
280 ENABLE_COM_API_REGREQ = 2
291 void execDEBUG_SIG(
Signal* signal);
292 void execCONTINUEB(
Signal* signal);
293 void execCM_HEARTBEAT(
Signal* signal);
294 void execCM_ADD(
Signal* signal);
295 void execCM_ACKADD(
Signal* signal);
296 void execCM_REGREQ(
Signal* signal);
297 void execCM_REGCONF(
Signal* signal);
298 void execCM_REGREF(
Signal* signal);
299 void execCM_NODEINFOREQ(
Signal* signal);
300 void execCM_NODEINFOCONF(
Signal* signal);
301 void execCM_NODEINFOREF(
Signal* signal);
302 void execPREP_FAILREQ(
Signal* signal);
303 void execPREP_FAILCONF(
Signal* signal);
304 void execPREP_FAILREF(
Signal* signal);
305 void execCOMMIT_FAILREQ(
Signal* signal);
306 void execCOMMIT_FAILCONF(
Signal* signal);
307 void execFAIL_REP(
Signal* signal);
308 void execPRES_TOREQ(
Signal* signal);
309 void execPRES_TOCONF(
Signal* signal);
310 void execDISCONNECT_REP(
Signal* signal);
311 void execSYSTEM_ERROR(
Signal* signal);
312 void execSTOP_REQ(
Signal* signal);
315 void execDUMP_STATE_ORD(
Signal* signal);
316 void execCONNECT_REP(
Signal* signal);
317 void execNDB_FAILCONF(
Signal* signal);
318 void execNF_COMPLETEREP(
Signal*);
319 void execREAD_CONFIG_REQ(
Signal* signal);
320 void execSTTOR(
Signal* signal);
321 void execCM_INFOCONF(
Signal* signal);
322 void execCLOSE_COMCONF(
Signal* signal);
323 void execAPI_REGREQ(
Signal* signal);
324 void execAPI_FAILCONF(
Signal* signal);
325 void execREAD_NODESREQ(
Signal* signal);
326 void execAPI_FAILREQ(
Signal* signal);
328 void execREAD_NODESREF(
Signal* signal);
329 void execREAD_NODESCONF(
Signal* signal);
331 void execDIH_RESTARTREF(
Signal* signal);
332 void execDIH_RESTARTCONF(
Signal* signal);
334 void execAPI_VERSION_REQ(
Signal* signal);
335 void execAPI_BROADCAST_REP(
Signal* signal);
337 void execNODE_FAILREP(
Signal *);
338 void execALLOC_NODEID_REQ(
Signal *);
339 void execALLOC_NODEID_CONF(
Signal *);
340 void execALLOC_NODEID_REF(
Signal *);
341 void completeAllocNodeIdReq(
Signal *);
342 void execENABLE_COMCONF(
Signal *signal);
343 void handleEnableComAddCommit(
Signal *signal, Uint32 node);
344 void handleEnableComCommitNew(
Signal *signal);
345 void handleEnableComApiRegreq(
Signal *signal, Uint32 node);
346 void sendApiRegConf(
Signal *signal, Uint32 node);
348 void execSTART_ORD(
Signal*);
351 void execARBIT_CFG(
Signal* signal);
352 void execARBIT_PREPREQ(
Signal* signal);
353 void execARBIT_PREPCONF(
Signal* signal);
354 void execARBIT_PREPREF(
Signal* signal);
355 void execARBIT_STARTCONF(
Signal* signal);
356 void execARBIT_STARTREF(
Signal* signal);
357 void execARBIT_CHOOSECONF(
Signal* signal);
358 void execARBIT_CHOOSEREF(
Signal* signal);
359 void execARBIT_STOPREP(
Signal* signal);
361 void execUPGRADE_PROTOCOL_ORD(
Signal*);
364 void execNODE_PINGREQ(
Signal* signal);
365 void execNODE_PINGCONF(
Signal* signal);
368 void check_readnodes_reply(
Signal* signal, Uint32 nodeId, Uint32 gsn);
369 Uint32 check_startup(
Signal* signal);
371 void api_failed(
Signal* signal, Uint32 aFailedNode);
372 void node_failed(
Signal* signal, Uint16 aFailedNode);
373 void checkStartInterface(
Signal* signal, Uint64 now);
374 void failReport(
Signal* signal,
377 FailRep::FailCause failCause,
379 void findNeighbours(
Signal* signal, Uint32 from);
380 Uint16 translateDynamicIdToNodeId(
Signal* signal, UintR TdynamicId);
382 void initData(
Signal* signal);
383 void sendCloseComReq(
Signal* signal, BlockReference TBRef, Uint16 TfailNo);
384 void sendPrepFailReq(
Signal* signal, Uint16 aNode);
385 void sendApiFailReq(
Signal* signal, Uint16 aFailedNode,
bool sumaOnly);
386 void sendApiRegRef(
Signal*, Uint32 ref, ApiRegRef::ErrorCode);
389 void startphase1(
Signal* signal);
390 void electionWon(
Signal* signal);
391 void cmInfoconf010Lab(
Signal* signal);
393 void apiHbHandlingLab(
Signal* signal, Uint64 now);
394 void timerHandlingLab(
Signal* signal);
395 void hbReceivedLab(
Signal* signal);
396 void sendCmRegrefLab(
Signal* signal, BlockReference ref,
397 CmRegRef::ErrorCode);
398 void systemErrorBecauseOtherNodeFailed(
Signal* signal, Uint32 line, NodeId);
399 void systemErrorLab(
Signal* signal, Uint32 line,
401 void prepFailReqLab(
Signal* signal);
402 void prepFailConfLab(
Signal* signal);
403 void prepFailRefLab(
Signal* signal);
404 void commitFailReqLab(
Signal* signal);
405 void commitFailConfLab(
Signal* signal);
406 void failReportLab(
Signal* signal, Uint16 aFailedNode,
407 FailRep::FailCause aFailCause,
409 void sendCommitFailReq(
Signal* signal);
410 void presToConfLab(
Signal* signal);
411 void sendSttorryLab(
Signal* signal);
412 void sttor020Lab(
Signal* signal);
413 void closeComConfLab(
Signal* signal);
414 void apiRegReqLab(
Signal* signal);
415 void regreqTimeLimitLab(
Signal* signal);
416 void regreqTimeMasterLimitLab(
Signal* signal);
417 void cmRegreq010Lab(
Signal* signal);
418 void cmRegconf010Lab(
Signal* signal);
419 void sttor010Lab(
Signal* signal);
420 void sendHeartbeat(
Signal* signal);
421 void checkHeartbeat(
Signal* signal);
422 void setHbDelay(UintR aHbDelay);
423 void setHbApiDelay(UintR aHbApiDelay);
424 void setArbitTimeout(UintR aArbitTimeout);
425 void setCCDelay(UintR aCCDelay);
428 void handleArbitStart(
Signal* signal);
429 void handleArbitApiFail(
Signal* signal, Uint16 nodeId);
430 void handleArbitNdbAdd(
Signal* signal, Uint16 nodeId);
431 void handleArbitCheck(
Signal* signal);
434 Uint32 getArbitDelay();
435 Uint32 getArbitTimeout();
436 void startArbitThread(
Signal* signal);
437 void runArbitThread(
Signal* signal);
438 void stateArbitInit(
Signal* signal);
439 void stateArbitFind(
Signal* signal);
440 void stateArbitPrep(
Signal* signal);
441 void stateArbitStart(
Signal* signal);
442 void stateArbitRun(
Signal* signal);
443 void stateArbitChoose(
Signal* signal);
444 void stateArbitCrash(
Signal* signal);
451 void startConnectivityCheck(
Signal* signal, Uint32 reason, Uint32 node);
452 void checkConnectivityTimeSignal(
Signal* signal);
453 void connectivityCheckCompleted(
Signal* signal);
454 bool isNodeConnectivitySuspect(Uint32 nodeId)
const;
455 void handleFailFromSuspect(
Signal* signal,
467 bool checkAPIVersion(NodeId, Uint32 nodeVersion, Uint32 ownVersion)
const;
468 bool checkNDBVersion(NodeId, Uint32 nodeVersion, Uint32 ownVersion)
const;
470 void cmAddPrepare(
Signal* signal, NodeRecPtr nodePtr,
const NodeRec*
self);
471 void sendCmAckAdd(
Signal *, Uint32 nodeId, CmAdd::RequestType);
472 void joinedCluster(
Signal* signal, NodeRecPtr nodePtr);
473 void sendCmRegReq(
Signal * signal, Uint32 nodeId);
474 void sendCmNodeInfoReq(
Signal* signal, Uint32 nodeId,
const NodeRec *
self);
477 void sendPrepFailReqRef(
Signal* signal,
479 GlobalSignalNumber gsn,
483 const NodeId theNodes[]);
485 void handleApiCloseComConf(
Signal* signal);
486 void add_failconf_block(NodeRecPtr, Uint32
block);
487 bool remove_failconf_block(NodeRecPtr, Uint32
block);
488 bool is_empty_failconf_block(NodeRecPtr)
const;
499 BlockReference cpdistref;
510 Uint32 c_restartPartialTimeout;
511 Uint32 c_restartPartionedTimeout;
512 Uint32 c_restartFailureTimeout;
513 Uint32 c_restartNoNodegroupTimeout;
514 Uint64 c_start_election_time;
516 Uint16 creadyDistCom;
519 Uint16 cpresidentAlive;
520 Uint16 cnoFailedNodes;
521 Uint16 cnoPrepFailedNodes;
522 Uint16 cnoCommitFailedNodes;
523 Uint16 cactivateApiCheck;
524 Uint16 c_allow_api_connect;
527 UintR ccommitFailureNr;
528 UintR cprepareFailureNr;
534 NDB_TICKS clatestTransactionCheck;
536 Timer interface_check_timer;
537 Timer hb_check_timer;
542 Uint16 cfailedNodes[MAX_NDB_NODES];
543 Uint16 cprepFailedNodes[MAX_NDB_NODES];
544 Uint16 ccommitFailedNodes[MAX_NDB_NODES];
546 struct OpAllocNodeIdReq {
549 Uint32 m_connectCount;
553 struct OpAllocNodeIdReq opAllocNodeIdReq;
556 bool check_multi_node_shutdown(
Signal* signal);
558 void recompute_version_info(Uint32 type);
559 void recompute_version_info(Uint32 type, Uint32 version);
560 void execNODE_VERSION_REP(
Signal* signal);
561 void sendApiVersionRep(
Signal* signal, NodeRecPtr nodePtr);
563 GlobalSignalNumber gsn,
569 bool m_micro_gcp_enabled;
572 int check_hb_order_config();
573 bool m_hb_order_config_used;
576 Uint32 nodeFailCount;