1 /* 2 Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef QMGR_H 26 #define QMGR_H 27 28 29 #include <pc.hpp> 30 #include <NdbTick.h> 31 #include <NdbGetRUsage.h> 32 #include <SimulatedBlock.hpp> 33 #include <NodeBitmask.hpp> 34 #include <SignalCounter.hpp> 35 #include <ProcessInfo.hpp> 36 37 #include <signaldata/EventReport.hpp> 38 #include <signaldata/ArbitSignalData.hpp> 39 #include <signaldata/CmRegSignalData.hpp> 40 #include <signaldata/ApiRegSignalData.hpp> 41 #include <signaldata/FailRep.hpp> 42 #include <signaldata/AllocNodeId.hpp> 43 44 #include <RequestTracker.hpp> 45 #include <signaldata/StopReq.hpp> 46 #include <ndb_limits.h> 47 #include "../ndbcntr/Ndbcntr.hpp" 48 49 #include "timer.hpp" 50 51 #define JAM_FILE_ID 362 52 53 54 #ifdef QMGR_C 55 56 /* Delay values, ms -----------------------------*/ 57 #define ZDELAY_REGREQ 1000 58 59 /* Type of refuse in CM_NODEINFOREF -------------*/ 60 #define ZNOT_RUNNING 0 61 62 /* Type of continue in CONTINUEB ----------------*/ 63 #define ZREGREQ_TIMELIMIT 0 64 #define ZHB_HANDLING 1 65 #define ZREGREQ_MASTER_TIMELIMIT 2 66 #define ZAPI_HB_HANDLING 3 67 #define ZTIMER_HANDLING 4 68 #define ZARBIT_HANDLING 5 69 #define ZSTART_FAILURE_LIMIT 6 70 #define ZNOTIFY_STATE_CHANGE 7 71 #define ZCHECK_MULTI_TRP_CONNECT 8 72 #define ZRESEND_GET_NUM_MULTI_TRP_REQ 9 73 #define ZSWITCH_MULTI_TRP 10 74 75 /* Error Codes ------------------------------*/ 76 #define ZERRTOOMANY 1101 77 #define ZERRALREADYREG 1102 78 #define ZERRNHMISSING 1103 79 #define ZERRNLMISSING 1104 80 #define ZERRAPPMISSING 1105 81 #define ZERROR_NOT_IN_CFGFILE 1106 82 #define ZERROR_TIMEOUT 1107 83 #define ZERROR_NOT_ZINIT 1108 84 #define ZERROR_NODEINFOREF 1109 85 #define ZERROR_NOTLOCALQMGR 1110 86 #define ZERROR_NOTRUNNING 1111 87 #define ZCOULD_NOT_OCCUR_ERROR 1112 88 #define ZTIME_OUT_ERROR 1113 89 #define ZERROR_NOT_DEAD 1114 90 #define ZDECLARED_FAIL_ERROR 1115 91 #define ZOWN_NODE_ERROR 1116 92 #define ZWRONG_STATE_ERROR 1117 93 #define ZNODE_ZERO_ERROR 1118 94 #define ZWRONG_NODE_ERROR 1119 95 96 #endif 97 98 #define QMGR_MAX_FAIL_STATE_BLOCKS 5 99 100 class Qmgr : public SimulatedBlock { 101 public: 102 // State values 103 enum QmgrState { 104 Q_NOT_ACTIVE = 0, 105 Q_ACTIVE = 1 106 }; 107 108 enum FailState { 109 NORMAL = 0, 110 WAITING_FOR_CLOSECOMCONF_ACTIVE = 1, /* Node had phase ZAPI_ACTIVE */ 111 WAITING_FOR_CLOSECOMCONF_NOTACTIVE = 2, /* Node had phase != ZAPI_ACTIVE */ 112 WAITING_FOR_API_FAILCONF = 3, 113 WAITING_FOR_NDB_FAILCONF = 6 114 }; 115 116 enum Phase { 117 ZINIT = 1, /* All nodes start in phase INIT */ 118 ZSTARTING = 2, /* Node is connecting to cluster */ 119 ZRUNNING = 3, /* Node is running in the cluster */ 120 ZPREPARE_FAIL = 4, /* PREPARATION FOR FAILURE */ 121 ZFAIL_CLOSING = 5, /* API/NDB IS DISCONNECTING */ 122 ZAPI_ACTIVE = 6, /* API IS RUNNING IN NODE */ 123 ZAPI_INACTIVE = 7, /* Inactive API */ 124 ZAPI_ACTIVATION_ONGOING = 8 /* API is being activated */ 125 }; 126 127 struct StartRecord { StartRecordQmgr::StartRecord128 StartRecord() {} resetQmgr::StartRecord129 void reset(){ 130 m_startKey++; 131 m_startNode = 0; 132 m_gsn = RNIL; 133 m_nodes.clearWaitingFor(); 134 } 135 Uint32 m_startKey; 136 Uint32 m_startNode; 137 Uint64 m_startTimeout; 138 139 Uint32 m_gsn; 140 SignalCounter m_nodes; 141 Uint32 m_latest_gci; 142 143 Uint32 m_start_type; 144 NdbNodeBitmask m_skip_nodes; 145 NdbNodeBitmask m_starting_nodes; 146 NdbNodeBitmask m_starting_nodes_w_log; 147 NdbNodeBitmask m_no_nodegroup_nodes; 148 149 Uint16 m_president_candidate; 150 Uint32 m_president_candidate_gci; 151 Uint16 m_regReqReqSent; 152 Uint16 m_regReqReqRecv; 153 Uint32 m_node_gci[MAX_NDB_NODES]; 154 } c_start; 155 156 NdbNodeBitmask c_definedNodes; // DB nodes in config 157 NdbNodeBitmask c_clusterNodes; // DB nodes in cluster 158 NodeBitmask c_connectedNodes; // All kinds of connected nodes 159 160 /** 161 * Nodes which we're checking for partitioned cluster 162 * 163 * i.e. nodes that connect to use, when we already have elected president 164 */ 165 NdbNodeBitmask c_readnodes_nodes; 166 167 Uint32 c_maxDynamicId; 168 169 struct ConnectCheckRec 170 { 171 bool m_enabled; // Config set && all node version OK 172 bool m_active; // Connectivity check underway? 173 Timer m_timer; // Check timer object 174 Uint32 m_currentRound; // Last round started 175 Uint32 m_tick; // Periods elapsed in current check 176 NdbNodeBitmask m_nodesPinged; // Nodes sent a NodePingReq in round 177 NdbNodeBitmask m_nodesWaiting; // Nodes which have not sent a response 178 NdbNodeBitmask m_nodesFailedDuring; // Nodes which failed during check 179 NdbNodeBitmask m_nodesSuspect; // Nodes with suspect connectivity 180 ConnectCheckRecQmgr::ConnectCheckRec181 ConnectCheckRec() 182 { 183 m_enabled = false; 184 m_active = false; 185 m_currentRound = 0; 186 m_tick = 0; 187 m_nodesPinged.clear(); 188 m_nodesWaiting.clear(); 189 m_nodesFailedDuring.clear(); 190 m_nodesSuspect.clear(); 191 } 192 193 void reportNodeConnect(Uint32 nodeId); 194 /* reportNodeFailure. 195 * return code true means the connect check is completed 196 */ 197 bool reportNodeFailure(Uint32 nodeId); 198 getEnabledQmgr::ConnectCheckRec199 bool getEnabled() const { 200 if (m_enabled) 201 { 202 assert(m_timer.getDelay() > 0); 203 } 204 return m_enabled; 205 } 206 }; 207 208 ConnectCheckRec m_connectivity_check; 209 210 // Records 211 struct NodeRec { 212 /* 213 * Dynamic id is received from president. Lower half is next 214 * c_maxDynamicId and upper half is hbOrder. Heartbeat circle is 215 * ordered by full dynamic id. When president fails, only the lower 216 * half of dynamic id is used by other nodes to agree on next 217 * president (the one with minimum value). 218 */ 219 UintR ndynamicId; 220 /* 221 * HeartbeatOrder from config.ini. Takes effect when this node 222 * becomes president and starts handing out dynamic ids to starting 223 * nodes. To define a new order, two rolling restarts is required. 224 */ 225 Uint32 hbOrder; 226 Phase phase; 227 228 bool m_initial_set_up_multi_trp_done; 229 bool m_is_in_same_nodegroup; 230 bool m_is_multi_trp_setup; 231 bool m_is_get_num_multi_trp_active; 232 bool m_is_activate_trp_ready_for_me; 233 bool m_is_activate_trp_ready_for_other; 234 bool m_is_freeze_thread_completed; 235 bool m_is_ready_to_switch_trp; 236 bool m_is_preparing_switch_trp; 237 bool m_is_using_multi_trp; 238 bool m_set_up_multi_trp_started; 239 Uint8 m_used_num_multi_trps; 240 Uint32 m_num_activated_trps; 241 BlockReference m_multi_trp_blockref; 242 Uint32 m_check_multi_trp_connect_loop_count; 243 Uint32 m_count_multi_trp_ref; 244 245 QmgrState sendPrepFailReqStatus; 246 QmgrState sendCommitFailReqStatus; 247 QmgrState sendPresToStatus; 248 FailState failState; 249 BlockReference blockRef; 250 Uint64 m_secret; 251 NDB_TICKS m_alloc_timeout; 252 Uint16 m_failconf_blocks[QMGR_MAX_FAIL_STATE_BLOCKS]; 253 NodeRecQmgr::NodeRec254 NodeRec() { bzero(m_failconf_blocks, sizeof(m_failconf_blocks)); } 255 }; /* p2c: size = 52 bytes */ 256 257 typedef Ptr<NodeRec> NodeRecPtr; 258 259 enum ArbitState { 260 ARBIT_NULL = 0, 261 ARBIT_INIT = 1, // create new ticket 262 ARBIT_FIND = 2, // find candidate arbitrator node 263 ARBIT_PREP1 = 3, // PREP db nodes with null ticket 264 ARBIT_PREP2 = 4, // PREP db nodes with current ticket 265 ARBIT_START = 5, // START arbitrator API thread 266 ARBIT_RUN = 6, // running with arbitrator 267 ARBIT_CHOOSE = 7, // ask arbitrator after network partition 268 ARBIT_CRASH = 8 // crash ourselves 269 }; 270 271 struct ArbitRec { ArbitRecQmgr::ArbitRec272 ArbitRec() {} 273 274 enum Method { 275 DISABLED = ARBIT_METHOD_DISABLED, // Arbitration disabled 276 METHOD_DEFAULT = ARBIT_METHOD_DEFAULT, // Default arbitration 277 // Delay commit to give "external" time to arbitrate 278 METHOD_EXTERNAL = ARBIT_METHOD_WAITEXTERNAL 279 } method; 280 281 ArbitState state; // state 282 bool newstate; // flag to initialize new state 283 unsigned thread; // identifies a continueB "thread" 284 NodeId node; // current arbitrator candidate 285 ArbitTicket ticket; // ticket 286 NodeBitmask apiMask[1+2]; // arbitrators 0=all 1,2=per rank 287 NdbNodeBitmask newMask; // new nodes to process in RUN state 288 Uint8 sendCount; // control send/recv of signals 289 Uint8 recvCount; 290 NdbNodeBitmask recvMask; // left to recv 291 Uint32 code; // code field from signal 292 Uint32 failureNr; // cfailureNr at arbitration start 293 Uint32 timeout; // timeout for CHOOSE state 294 NDB_TICKS timestamp; // timestamp for checking timeouts 295 matchQmgr::ArbitRec296 inline bool match(ArbitSignalData* sd) { 297 return 298 node == sd->node && 299 ticket.match(sd->ticket); 300 } 301 setTimestampQmgr::ArbitRec302 inline void setTimestamp() { 303 timestamp = NdbTick_getCurrentTicks(); 304 } 305 getTimediffQmgr::ArbitRec306 inline Uint64 getTimediff() { 307 const NDB_TICKS now = NdbTick_getCurrentTicks(); 308 return NdbTick_Elapsed(timestamp, now).milliSec(); 309 } 310 }; 311 312 /* State values for handling ENABLE_COMREQ / ENABLE_COMCONF. */ 313 enum EnableComState { 314 ENABLE_COM_CM_ADD_COMMIT = 0, 315 ENABLE_COM_CM_COMMIT_NEW = 1, 316 ENABLE_COM_API_REGREQ = 2 317 }; 318 319 struct NodeFailRec 320 { 321 NdbNodeBitmask nodes; 322 Uint32 failureNr; 323 Uint16 president; 324 }; 325 326 public: 327 Qmgr(Block_context&); 328 virtual ~Qmgr(); 329 330 private: 331 BLOCK_DEFINES(Qmgr); 332 333 // Transit signals 334 void execDEBUG_SIG(Signal* signal); 335 void execCONTINUEB(Signal* signal); 336 void execCM_HEARTBEAT(Signal* signal); 337 void execCM_ADD(Signal* signal); 338 void execCM_ACKADD(Signal* signal); 339 void execCM_REGREQ(Signal* signal); 340 void execCM_REGCONF(Signal* signal); 341 void execCM_REGREF(Signal* signal); 342 void execCM_NODEINFOREQ(Signal* signal); 343 void execCM_NODEINFOCONF(Signal* signal); 344 void execCM_NODEINFOREF(Signal* signal); 345 void execPREP_FAILREQ(Signal* signal); 346 void execPREP_FAILCONF(Signal* signal); 347 void execPREP_FAILREF(Signal* signal); 348 void execCOMMIT_FAILREQ(Signal* signal); 349 void execCOMMIT_FAILCONF(Signal* signal); 350 void execFAIL_REP(Signal* signal); 351 void execPRES_TOREQ(Signal* signal); 352 void execPRES_TOCONF(Signal* signal); 353 void execDISCONNECT_REP(Signal* signal); 354 void execSYSTEM_ERROR(Signal* signal); 355 void execSTOP_REQ(Signal* signal); 356 357 // Received signals 358 void execDUMP_STATE_ORD(Signal* signal); 359 void execCONNECT_REP(Signal* signal); 360 void execNDB_FAILCONF(Signal* signal); 361 void execNF_COMPLETEREP(Signal*); 362 void execREAD_CONFIG_REQ(Signal* signal); 363 void execSTTOR(Signal* signal); 364 void execCM_INFOCONF(Signal* signal); 365 void execCLOSE_COMCONF(Signal* signal); 366 void execAPI_REGREQ(Signal* signal); 367 void execAPI_FAILCONF(Signal* signal); 368 void execREAD_NODESREQ(Signal* signal); 369 void execAPI_FAILREQ(Signal* signal); 370 371 void execREAD_NODESREF(Signal* signal); 372 void execREAD_NODESCONF(Signal* signal); 373 374 void execDIH_RESTARTREF(Signal* signal); 375 void execDIH_RESTARTCONF(Signal* signal); 376 377 void execSET_UP_MULTI_TRP_REQ(Signal*); 378 void execGET_NUM_MULTI_TRP_REQ(Signal*); 379 void execGET_NUM_MULTI_TRP_CONF(Signal*); 380 void execGET_NUM_MULTI_TRP_REF(Signal*); 381 void execFREEZE_ACTION_REQ(Signal*); 382 void execFREEZE_THREAD_CONF(Signal*); 383 void execACTIVATE_TRP_REQ(Signal*); 384 void execACTIVATE_TRP_CONF(Signal*); 385 void execSWITCH_MULTI_TRP_REQ(Signal*); 386 void execSWITCH_MULTI_TRP_CONF(Signal*); 387 void execSWITCH_MULTI_TRP_REF(Signal*); 388 389 void execAPI_VERSION_REQ(Signal* signal); 390 void execAPI_BROADCAST_REP(Signal* signal); 391 392 void execNODE_FAILREP(Signal *); 393 void execALLOC_NODEID_REQ(Signal *); 394 void execALLOC_NODEID_CONF(Signal *); 395 void execALLOC_NODEID_REF(Signal *); 396 void completeAllocNodeIdReq(Signal *); 397 void execENABLE_COMCONF(Signal *signal); 398 void handleEnableComAddCommit(Signal *signal, Uint32 node); 399 void handleEnableComCommitNew(Signal *signal); 400 void handleEnableComApiRegreq(Signal *signal, Uint32 node); 401 void sendApiRegConf(Signal *signal, Uint32 node); 402 403 void execSTART_ORD(Signal*); 404 void execSYNC_THREAD_VIA_CONF(Signal*); 405 406 // Arbitration signals 407 void execARBIT_CFG(Signal* signal); 408 void execARBIT_PREPREQ(Signal* signal); 409 void execARBIT_PREPCONF(Signal* signal); 410 void execARBIT_PREPREF(Signal* signal); 411 void execARBIT_STARTCONF(Signal* signal); 412 void execARBIT_STARTREF(Signal* signal); 413 void execARBIT_CHOOSECONF(Signal* signal); 414 void execARBIT_CHOOSEREF(Signal* signal); 415 void execARBIT_STOPREP(Signal* signal); 416 417 void execUPGRADE_PROTOCOL_ORD(Signal*); 418 419 // Connectivity check signals 420 void execNODE_PINGREQ(Signal* signal); 421 void execNODE_PINGCONF(Signal* signal); 422 423 // Ndbinfo signal 424 void execDBINFO_SCANREQ(Signal *signal); 425 426 // ProcessInfo Report signal 427 void execPROCESSINFO_REP(Signal *signal); 428 429 // NDBCNTR informing us our node is fully started 430 void execNODE_STARTED_REP(Signal *signal); 431 432 // NDBCNTR node state change 433 void execNODE_STATE_REP(Signal *signal); 434 void handleStateChange(Signal* signal, const Uint32 nodeId); 435 436 // Statement blocks 437 void check_readnodes_reply(Signal* signal, Uint32 nodeId, Uint32 gsn); 438 Uint32 check_startup(Signal* signal); 439 440 void api_failed(Signal* signal, Uint32 aFailedNode); 441 void node_failed(Signal* signal, Uint16 aFailedNode); 442 void checkStartInterface(Signal* signal, NDB_TICKS now); 443 void failReport(Signal* signal, 444 Uint16 aFailedNode, 445 UintR aSendFailRep, 446 FailRep::FailCause failCause, 447 Uint16 sourceNode); 448 void findNeighbours(Signal* signal, Uint32 from); 449 Uint16 translateDynamicIdToNodeId(Signal* signal, UintR TdynamicId); 450 451 void initData(Signal* signal); 452 void sendCloseComReq(Signal* signal, BlockReference TBRef, Uint16 TfailNo); 453 void sendPrepFailReq(Signal* signal, Uint16 aNode); 454 void sendApiFailReq(Signal* signal, Uint16 aFailedNode, bool sumaOnly); 455 void sendApiRegRef(Signal*, Uint32 ref, ApiRegRef::ErrorCode); 456 457 // Generated statement blocks 458 void startphase1(Signal* signal); 459 void electionWon(Signal* signal); 460 void cmInfoconf010Lab(Signal* signal); 461 462 void apiHbHandlingLab(Signal* signal, NDB_TICKS now); 463 void timerHandlingLab(Signal* signal); 464 void hbReceivedLab(Signal* signal); 465 void sendCmRegrefLab(Signal* signal, BlockReference ref, 466 CmRegRef::ErrorCode, Uint32 remote_node_version); 467 void systemErrorBecauseOtherNodeFailed(Signal* signal, Uint32 line, NodeId); 468 [[noreturn]] void systemErrorLab(Signal* signal, 469 Uint32 line, 470 const char* message = NULL); 471 void prepFailReqLab(Signal* signal); 472 void prepFailConfLab(Signal* signal); 473 void prepFailRefLab(Signal* signal); 474 void commitFailReqLab(Signal* signal); 475 void commitFailConfLab(Signal* signal); 476 void failReportLab(Signal* signal, Uint16 aFailedNode, 477 FailRep::FailCause aFailCause, 478 Uint16 sourceNode); 479 void sendCommitFailReq(Signal* signal); 480 void presToConfLab(Signal* signal); 481 void sendSttorryLab(Signal* signal, bool first_phase); 482 void sttor020Lab(Signal* signal); 483 void closeComConfLab(Signal* signal); 484 void apiRegReqLab(Signal* signal); 485 void regreqTimeLimitLab(Signal* signal); 486 void regreqTimeMasterLimitLab(Signal* signal); 487 void cmRegreq010Lab(Signal* signal); 488 void cmRegconf010Lab(Signal* signal); 489 void sttor010Lab(Signal* signal); 490 void sendHeartbeat(Signal* signal); 491 void checkHeartbeat(Signal* signal); 492 void setHbDelay(UintR aHbDelay); 493 void setHbApiDelay(UintR aHbApiDelay); 494 void setArbitTimeout(UintR aArbitTimeout); 495 void setCCDelay(UintR aCCDelay); 496 497 // Interface to arbitration module 498 void handleArbitStart(Signal* signal); 499 void handleArbitApiFail(Signal* signal, Uint16 nodeId); 500 void handleArbitNdbAdd(Signal* signal, Uint16 nodeId); 501 void handleArbitCheck(Signal* signal); 502 503 // Private arbitration routines 504 Uint32 getArbitDelay(); 505 Uint32 getArbitTimeout(); 506 void startArbitThread(Signal* signal); 507 void runArbitThread(Signal* signal); 508 void stateArbitInit(Signal* signal); 509 void stateArbitFind(Signal* signal); 510 void stateArbitPrep(Signal* signal); 511 void stateArbitStart(Signal* signal); 512 void stateArbitRun(Signal* signal); 513 void stateArbitChoose(Signal* signal); 514 void stateArbitCrash(Signal* signal); 515 Uint32 count_previously_alive_nodes(); 516 void computeArbitNdbMask(NodeBitmaskPOD& aMask); 517 void computeArbitNdbMask(NdbNodeBitmaskPOD& aMask); 518 void computeNonDiedNdbMask(NdbNodeBitmaskPOD& aMask); 519 void reportArbitEvent(Signal* signal, Ndb_logevent_type type, 520 const NodeBitmask mask = NodeBitmask()); 521 522 // Interface to Connectivity Check 523 void startConnectivityCheck(Signal* signal, Uint32 reason, Uint32 node); 524 void checkConnectivityTimeSignal(Signal* signal); 525 void connectivityCheckCompleted(Signal* signal); 526 bool isNodeConnectivitySuspect(Uint32 nodeId) const; 527 void handleFailFromSuspect(Signal* signal, 528 Uint32 reason, 529 Uint16 aFailedNode, 530 Uint16 sourceNode); 531 532 // Initialisation 533 void initData(); 534 void initRecords(); 535 536 // Transit signals 537 // Variables 538 539 bool checkAPIVersion(NodeId, Uint32 nodeVersion, Uint32 ownVersion) const; 540 bool checkNDBVersion(NodeId, Uint32 nodeVersion, Uint32 ownVersion) const; 541 542 void cmAddPrepare(Signal* signal, NodeRecPtr nodePtr, const NodeRec* self); 543 void sendCmAckAdd(Signal *, Uint32 nodeId, CmAdd::RequestType); 544 void joinedCluster(Signal* signal, NodeRecPtr nodePtr); 545 void sendCmRegReq(Signal * signal, Uint32 nodeId); 546 void sendCmNodeInfoReq(Signal* signal, Uint32 nodeId, const NodeRec * self); 547 ProcessInfo * getProcessInfo(Uint32 nodeId); 548 549 private: 550 void sendPrepFailReqRef(Signal* signal, 551 Uint32 dstBlockRef, 552 GlobalSignalNumber gsn, 553 Uint32 blockRef, 554 Uint32 failNo, 555 const NdbNodeBitmask& nodes); 556 557 void handleApiCloseComConf(Signal* signal); 558 void add_failconf_block(NodeRecPtr, Uint32 block); 559 bool remove_failconf_block(NodeRecPtr, Uint32 block); 560 bool is_empty_failconf_block(NodeRecPtr) const; 561 562 /* Wait this time until we try to join the */ 563 /* cluster again */ 564 565 /**** Common stored variables ****/ 566 567 NodeRec *nodeRec; 568 ArbitRec arbitRec; 569 static constexpr Uint32 MAX_DATA_NODE_FAILURES = MAX_DATA_NODE_ID; 570 NodeFailRec *nodeFailRec; 571 572 /* Block references ------------------------------*/ 573 BlockReference cpdistref; /* Dist. ref of president */ 574 575 /* Node numbers. ---------------------------------*/ 576 Uint16 cneighbourl; /* Node no. of lower neighbour */ 577 Uint16 cneighbourh; /* Node no. of higher neighbour */ 578 Uint16 cpresident; /* Node no. of president */ 579 580 /* Counters --------------------------------------*/ 581 Uint16 cnoOfNodes; /* Static node counter */ 582 /* Status flags ----------------------------------*/ 583 584 Uint32 c_restartPartialTimeout; 585 Uint32 c_restartPartitionedTimeout; 586 Uint32 c_restartFailureTimeout; 587 Uint32 c_restartNoNodegroupTimeout; 588 NDB_TICKS c_start_election_time; 589 590 Uint16 creadyDistCom; 591 592 Uint16 cdelayRegreq; 593 Uint16 cpresidentAlive; 594 Uint16 c_allow_api_connect; 595 UintR chbApiDelay; 596 597 UintR ccommitFailureNr; 598 UintR cprepareFailureNr; 599 UintR ctoFailureNr; 600 UintR cfailureNr; 601 602 QmgrState ctoStatus; 603 bool cHbSent; 604 605 Timer interface_check_timer; 606 Timer hb_check_timer; 607 Timer hb_send_timer; 608 Timer hb_api_timer; 609 610 Int16 processInfoNodeIndex[MAX_NODES]; 611 ProcessInfo * receivedProcessInfo; 612 Uint16 max_api_node_id; 613 614 NdbNodeBitmask cfailedNodes; 615 NdbNodeBitmask cprepFailedNodes; 616 NdbNodeBitmask ccommitFailedNodes; 617 618 struct OpAllocNodeIdReq { 619 RequestTracker m_tracker; 620 AllocNodeIdReq m_req; 621 Uint32 m_connectCount; 622 Uint32 m_error; 623 }; 624 625 struct OpAllocNodeIdReq opAllocNodeIdReq; 626 627 struct StopReqRec { 628 Uint32 senderRef; 629 Uint32 senderData; 630 Uint32 requestInfo; 631 NdbNodeBitmask nodes; 632 }; 633 634 StopReqRec c_stopReq; 635 bool check_multi_node_shutdown(Signal* signal); 636 637 void recompute_version_info(Uint32 type); 638 void recompute_version_info(Uint32 type, Uint32 version); 639 void execNODE_VERSION_REP(Signal* signal); 640 void sendApiVersionRep(Signal* signal, NodeRecPtr nodePtr); 641 void sendVersionedDb(NodeReceiverGroup rg, 642 GlobalSignalNumber gsn, 643 Signal* signal, 644 Uint32 length, 645 JobBufferLevel jbuf, 646 Uint32 minversion); 647 void get_node_group_mask(Signal*, NdbNodeBitmask&); 648 bool get_num_multi_trps(Signal*, bool&); 649 void create_multi_transporter(NodeId); 650 void connect_multi_transporter(Signal*, NodeId); 651 void check_connect_multi_transporter(Signal*, NodeId); 652 void send_get_num_multi_trp_req(Signal*, NodeId); 653 void send_switch_multi_transporter(Signal*, NodeId, bool); 654 void switch_multi_transporter(Signal*, NodeId); 655 void check_switch_completed(Signal*, NodeId); 656 void check_no_multi_trp(Signal*, NodeId); 657 void check_more_trp_switch_nodes(Signal*); 658 void handle_activate_trp_req(Signal*, Uint32); 659 bool check_all_multi_trp_nodes_connected(); 660 bool select_node_id_for_switch(NodeId&, bool); 661 662 bool m_micro_gcp_enabled; 663 664 // user-defined hbOrder must set all values non-zero and distinct 665 int check_hb_order_config(); 666 bool m_hb_order_config_used; 667 668 #ifdef ERROR_INSERT 669 Uint32 nodeFailCount; 670 #endif 671 672 struct ndb_rusage m_timer_handling_rusage; 673 Uint32 m_num_multi_trps; 674 Uint32 m_get_num_multi_trps_sent; 675 bool m_initial_set_up_multi_trp_done; 676 Uint32 m_current_switch_multi_trp_node; 677 BlockReference m_ref_set_up_multi_trp_req; 678 Ndbcntr* c_ndbcntr; 679 get_hb_count(Uint32 nodeId) const680 Uint32 get_hb_count(Uint32 nodeId) const { 681 return globalData.get_hb_count(nodeId); 682 } 683 set_hb_count(Uint32 nodeId)684 Uint32& set_hb_count(Uint32 nodeId) { 685 return globalData.set_hb_count(nodeId); 686 } 687 688 void execISOLATE_ORD(Signal* signal); 689 690 void sendReadLocalSysfile(Signal*); 691 void execREAD_LOCAL_SYSFILE_CONF(Signal*); 692 bool is_multi_socket_setup_active(Uint32 node_id, bool locked); 693 void complete_multi_trp_setup(Signal*, bool); 694 void dec_get_num_multi_trps_sent(NodeId); 695 void inc_get_num_multi_trps_sent(NodeId); 696 }; 697 #undef JAM_FILE_ID 698 699 #endif 700